Python: Request cancellation sample (#459)

* request cancellation via tasks

* fix missing kwargs
This commit is contained in:
peterychang
2025-08-20 15:56:26 -04:00
committed by GitHub
Unverified
parent 011edfe420
commit feb4e908ae
3 changed files with 20 additions and 51 deletions
@@ -90,7 +90,7 @@ def _tool_call_non_streaming(
response: ChatResponse | None = None
fcc_messages: list[ChatMessage] = []
for attempt_idx in range(getattr(self, "__maximum_iterations_per_request", 10)):
response = await func(self, messages=messages, chat_options=chat_options)
response = await func(self, messages=messages, chat_options=chat_options, **kwargs)
# if there are function calls, we will handle them first
function_results = {
it.call_id for it in response.messages[0].contents if isinstance(it, FunctionResultContent)