Skip to content

feat(api): add support for filtering messages by run_id #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/openai/resources/beta/threads/messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def list(
before: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
run_id: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -230,6 +231,8 @@ def list(
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
order and `desc` for descending order.

run_id: Filter messages by the run ID that generated them.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -255,6 +258,7 @@ def list(
"before": before,
"limit": limit,
"order": order,
"run_id": run_id,
},
message_list_params.MessageListParams,
),
Expand Down Expand Up @@ -432,6 +436,7 @@ def list(
before: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
run_id: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -459,6 +464,8 @@ def list(
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
order and `desc` for descending order.

run_id: Filter messages by the run ID that generated them.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -484,6 +491,7 @@ def list(
"before": before,
"limit": limit,
"order": order,
"run_id": run_id,
},
message_list_params.MessageListParams,
),
Expand Down
3 changes: 3 additions & 0 deletions src/openai/types/beta/threads/message_list_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ class MessageListParams(TypedDict, total=False):

`asc` for ascending order and `desc` for descending order.
"""

run_id: str
"""Filter messages by the run ID that generated them."""
2 changes: 2 additions & 0 deletions tests/api_resources/beta/threads/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def test_method_list_with_all_params(self, client: OpenAI) -> None:
before="string",
limit=0,
order="asc",
run_id="string",
)
assert_matches_type(SyncCursorPage[Message], message, path=["response"])

Expand Down Expand Up @@ -410,6 +411,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> N
before="string",
limit=0,
order="asc",
run_id="string",
)
assert_matches_type(AsyncCursorPage[Message], message, path=["response"])

Expand Down