chore: change LlmRequest.config's default value to be types.GenerateContentConfig() instead of None

PiperOrigin-RevId: 789792582
This commit is contained in:
Xuan Yang
2025-08-01 09:35:42 -07:00
committed by Copybara-Service
parent 16a15c8709
commit 041f04e89c
5 changed files with 8 additions and 7 deletions
+3 -1
View File
@@ -45,7 +45,9 @@ class LlmRequest(BaseModel):
contents: list[types.Content] = Field(default_factory=list)
"""The contents to send to the model."""
config: Optional[types.GenerateContentConfig] = None
config: types.GenerateContentConfig = Field(
default_factory=types.GenerateContentConfig
)
live_connect_config: types.LiveConnectConfig = types.LiveConnectConfig()
"""Additional config for the generate content request.
@@ -1505,7 +1505,6 @@ async def test_computer_use_with_no_config():
contents=[
types.Content(role="user", parts=[types.Part.from_text(text="Hello")])
],
config=None,
)
# Should not raise an exception
+1 -1
View File
@@ -62,7 +62,7 @@ async def test_process_llm_request_no_declaration():
tool_context=tool_context, llm_request=llm_request
)
assert llm_request.config is None
assert llm_request.config == types.GenerateContentConfig()
@pytest.mark.asyncio
@@ -322,12 +322,12 @@ class TestGoogleSearchTool:
)
@pytest.mark.asyncio
async def test_process_llm_request_with_none_config(self):
async def test_process_llm_request_with_no_config(self):
"""Test processing LLM request with None config."""
tool = GoogleSearchTool()
tool_context = await _create_tool_context()
llm_request = LlmRequest(model='gemini-2.0-flash', config=None)
llm_request = LlmRequest(model='gemini-2.0-flash')
await tool.process_llm_request(
tool_context=tool_context, llm_request=llm_request
@@ -242,12 +242,12 @@ class TestUrlContextTool:
)
@pytest.mark.asyncio
async def test_process_llm_request_with_none_config(self):
async def test_process_llm_request_with_no_config(self):
"""Test processing LLM request with None config."""
tool = UrlContextTool()
tool_context = await _create_tool_context()
llm_request = LlmRequest(model='gemini-2.0-flash', config=None)
llm_request = LlmRequest(model='gemini-2.0-flash')
await tool.process_llm_request(
tool_context=tool_context, llm_request=llm_request