1414
1515from __future__ import annotations
1616
17- from collections .abc import AsyncGenerator as ABCAsyncGenerator
18- import inspect
19- from typing import get_origin
2017from typing import Optional
2118
2219from google .genai import types
2522from pydantic import Field
2623
2724from ..tools .base_tool import BaseTool
28- from ..tools .function_tool import FunctionTool
2925
3026
3127def _find_tool_with_function_declarations (
@@ -70,13 +66,13 @@ class LlmRequest(BaseModel):
7066 config : types .GenerateContentConfig = Field (
7167 default_factory = types .GenerateContentConfig
7268 )
69+ live_connect_config : types .LiveConnectConfig = Field (
70+ default_factory = types .LiveConnectConfig
71+ )
7372 """Additional config for the generate content request.
7473
7574 tools in generate_content_config should not be set.
7675 """
77- live_connect_config : Optional [types .LiveConnectConfig ] = None
78- """Live connection config.
79- """
8076 tools_dict : dict [str , BaseTool ] = Field (default_factory = dict , exclude = True )
8177 """The tools dictionary."""
8278
@@ -103,23 +99,7 @@ def append_tools(self, tools: list[BaseTool]) -> None:
10399 return
104100 declarations = []
105101 for tool in tools :
106- if self .live_connect_config is not None :
107- # ignore response for tools that returns AsyncGenerator that the model
108- # can't understand yet even though the model can't handle it, streaming
109- # tools can handle it.
110- # to check type, use typing.collections.abc.AsyncGenerator and not
111- # typing.AsyncGenerator
112- is_async_generator_return = False
113- if isinstance (tool , FunctionTool ):
114- signature = inspect .signature (tool .func )
115- is_async_generator_return = (
116- get_origin (signature .return_annotation ) is ABCAsyncGenerator
117- )
118- declaration = tool ._get_declaration (
119- ignore_return_declaration = is_async_generator_return
120- )
121- else :
122- declaration = tool ._get_declaration ()
102+ declaration = tool ._get_declaration ()
123103 if declaration :
124104 declarations .append (declaration )
125105 self .tools_dict [tool .name ] = tool
0 commit comments