A helper to create a run an poll for a terminal state. More information on Run lifecycles can be found here: https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
(
self,
*,
assistant_id: str,
include: List[RunStepInclude] | Omit = omit,
additional_instructions: Optional[str] | Omit = omit,
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
instructions: Optional[str] | Omit = omit,
max_completion_tokens: Optional[int] | Omit = omit,
max_prompt_tokens: Optional[int] | Omit = omit,
metadata: Optional[Metadata] | Omit = omit,
model: Union[str, ChatModel, None] | Omit = omit,
parallel_tool_calls: bool | Omit = omit,
reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
temperature: Optional[float] | Omit = omit,
tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
top_p: Optional[float] | Omit = omit,
truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
poll_interval_ms: int | Omit = omit,
thread_id: str,
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
)
| 838 | |
| 839 | @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API") |
| 840 | def create_and_poll( |
| 841 | self, |
| 842 | *, |
| 843 | assistant_id: str, |
| 844 | include: List[RunStepInclude] | Omit = omit, |
| 845 | additional_instructions: Optional[str] | Omit = omit, |
| 846 | additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit, |
| 847 | instructions: Optional[str] | Omit = omit, |
| 848 | max_completion_tokens: Optional[int] | Omit = omit, |
| 849 | max_prompt_tokens: Optional[int] | Omit = omit, |
| 850 | metadata: Optional[Metadata] | Omit = omit, |
| 851 | model: Union[str, ChatModel, None] | Omit = omit, |
| 852 | parallel_tool_calls: bool | Omit = omit, |
| 853 | reasoning_effort: Optional[ReasoningEffort] | Omit = omit, |
| 854 | response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit, |
| 855 | temperature: Optional[float] | Omit = omit, |
| 856 | tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit, |
| 857 | tools: Optional[Iterable[AssistantToolParam]] | Omit = omit, |
| 858 | top_p: Optional[float] | Omit = omit, |
| 859 | truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit, |
| 860 | poll_interval_ms: int | Omit = omit, |
| 861 | thread_id: str, |
| 862 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 863 | # The extra values given here take precedence over values defined on the client or passed to this method. |
| 864 | extra_headers: Headers | None = None, |
| 865 | extra_query: Query | None = None, |
| 866 | extra_body: Body | None = None, |
| 867 | timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 868 | ) -> Run: |
| 869 | """ |
| 870 | A helper to create a run an poll for a terminal state. More information on Run |
| 871 | lifecycles can be found here: |
| 872 | https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps |
| 873 | """ |
| 874 | run = self.create( # pyright: ignore[reportDeprecated] |
| 875 | thread_id=thread_id, |
| 876 | assistant_id=assistant_id, |
| 877 | include=include, |
| 878 | additional_instructions=additional_instructions, |
| 879 | additional_messages=additional_messages, |
| 880 | instructions=instructions, |
| 881 | max_completion_tokens=max_completion_tokens, |
| 882 | max_prompt_tokens=max_prompt_tokens, |
| 883 | metadata=metadata, |
| 884 | model=model, |
| 885 | response_format=response_format, |
| 886 | temperature=temperature, |
| 887 | tool_choice=tool_choice, |
| 888 | parallel_tool_calls=parallel_tool_calls, |
| 889 | reasoning_effort=reasoning_effort, |
| 890 | # We assume we are not streaming when polling |
| 891 | stream=False, |
| 892 | tools=tools, |
| 893 | truncation_strategy=truncation_strategy, |
| 894 | top_p=top_p, |
| 895 | extra_headers=extra_headers, |
| 896 | extra_query=extra_query, |
| 897 | extra_body=extra_body, |