Python: improved loading (#202)

* improved loading

* updated openai folder imports

* fixed import
This commit is contained in:
Eduard van Valkenburg
2025-07-18 21:17:30 +02:00
committed by GitHub
Unverified
parent fc999e2be8
commit 9287572b0d
19 changed files with 201 additions and 252 deletions
@@ -34,6 +34,13 @@ TChatClientBase = TypeVar("TChatClientBase", bound="ChatClientBase")
logger = get_logger()
__all__ = [
"ChatClient",
"ChatClientBase",
"EmbeddingGenerator",
"use_tool_calling",
]
# region: Tool Calling Functions and Decorators
@@ -88,7 +95,8 @@ def _prepare_tools_and_tool_choice(chat_options: ChatOptions) -> None:
chat_options.tool_choice = ChatToolMode.NONE.mode
return
chat_options.tools = [
(_tool_to_json_schema_spec(t) if isinstance(t, AITool) else t) for t in chat_options._ai_tools or []
(_tool_to_json_schema_spec(t) if isinstance(t, AITool) else t)
for t in chat_options._ai_tools or [] # type: ignore[reportPrivateUsage]
]
if not chat_options.tools:
chat_options.tool_choice = ChatToolMode.NONE.mode
@@ -126,7 +134,7 @@ def _tool_call_non_streaming(func: TInnerGetResponse) -> TInnerGetResponse:
_auto_invoke_function(
function_call,
custom_args=kwargs,
tool_map={t.name: t for t in chat_options._ai_tools or [] if isinstance(t, AIFunction)},
tool_map={t.name: t for t in chat_options._ai_tools or [] if isinstance(t, AIFunction)}, # type: ignore[reportPrivateUsage]
sequence_index=seq_idx,
request_index=attempt_idx,
)
@@ -203,7 +211,7 @@ def _tool_call_streaming(func: TInnerGetStreamingResponse) -> TInnerGetStreaming
_auto_invoke_function(
function_call,
custom_args=kwargs,
tool_map={t.name: t for t in chat_options._ai_tools or [] if isinstance(t, AIFunction)},
tool_map={t.name: t for t in chat_options._ai_tools or [] if isinstance(t, AIFunction)}, # type: ignore[reportPrivateUsage]
sequence_index=seq_idx,
request_index=attempt_idx,
)