Skip to content
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

feat(api): add additional instructions for runs #995

Merged
merged 1 commit into from
Dec 19, 2023
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
22 changes: 18 additions & 4 deletions src/openai/resources/beta/threads/runs/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def create(
thread_id: str,
*,
assistant_id: str,
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
Expand All @@ -61,8 +62,13 @@ def create(
[assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
execute this run.

instructions: Override the default system message of the assistant. This is useful for
modifying the behavior on a per-run basis.
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
is useful for modifying the behavior on a per-run basis without overriding other
instructions.

instructions: Overrides the
[instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
of the assistant. This is useful for modifying the behavior on a per-run basis.

metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
for storing additional information about the object in a structured format. Keys
Expand Down Expand Up @@ -91,6 +97,7 @@ def create(
body=maybe_transform(
{
"assistant_id": assistant_id,
"additional_instructions": additional_instructions,
"instructions": instructions,
"metadata": metadata,
"model": model,
Expand Down Expand Up @@ -332,6 +339,7 @@ async def create(
thread_id: str,
*,
assistant_id: str,
additional_instructions: Optional[str] | NotGiven = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
Expand All @@ -351,8 +359,13 @@ async def create(
[assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
execute this run.

instructions: Override the default system message of the assistant. This is useful for
modifying the behavior on a per-run basis.
additional_instructions: Appends additional instructions at the end of the instructions for the run. This
is useful for modifying the behavior on a per-run basis without overriding other
instructions.

instructions: Overrides the
[instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
of the assistant. This is useful for modifying the behavior on a per-run basis.

metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
for storing additional information about the object in a structured format. Keys
Expand Down Expand Up @@ -381,6 +394,7 @@ async def create(
body=maybe_transform(
{
"assistant_id": assistant_id,
"additional_instructions": additional_instructions,
"instructions": instructions,
"metadata": metadata,
"model": model,
Expand Down
14 changes: 11 additions & 3 deletions src/openai/types/beta/threads/run_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ class RunCreateParams(TypedDict, total=False):
execute this run.
"""

instructions: Optional[str]
"""Override the default system message of the assistant.
additional_instructions: Optional[str]
"""Appends additional instructions at the end of the instructions for the run.

This is useful for modifying the behavior on a per-run basis.
This is useful for modifying the behavior on a per-run basis without overriding
other instructions.
"""

instructions: Optional[str]
"""
Overrides the
[instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
of the assistant. This is useful for modifying the behavior on a per-run basis.
"""

metadata: Optional[object]
Expand Down
2 changes: 2 additions & 0 deletions tests/api_resources/beta/threads/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
run = client.beta.threads.runs.create(
"string",
assistant_id="string",
additional_instructions="string",
instructions="string",
metadata={},
model="string",
Expand Down Expand Up @@ -180,6 +181,7 @@ async def test_method_create_with_all_params(self, client: AsyncOpenAI) -> None:
run = await client.beta.threads.runs.create(
"string",
assistant_id="string",
additional_instructions="string",
instructions="string",
metadata={},
model="string",
Expand Down