Skip to content

Commit 041f04e

Browse files
xuanyang15copybara-github
authored andcommitted
chore: change LlmRequest.config's default value to be types.GenerateContentConfig() instead of None
PiperOrigin-RevId: 789792582
1 parent 16a15c8 commit 041f04e

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/google/adk/models/llm_request.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class LlmRequest(BaseModel):
4545
contents: list[types.Content] = Field(default_factory=list)
4646
"""The contents to send to the model."""
4747

48-
config: Optional[types.GenerateContentConfig] = None
48+
config: types.GenerateContentConfig = Field(
49+
default_factory=types.GenerateContentConfig
50+
)
4951
live_connect_config: types.LiveConnectConfig = types.LiveConnectConfig()
5052
"""Additional config for the generate content request.
5153

tests/unittests/models/test_google_llm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,6 @@ async def test_computer_use_with_no_config():
15051505
contents=[
15061506
types.Content(role="user", parts=[types.Part.from_text(text="Hello")])
15071507
],
1508-
config=None,
15091508
)
15101509

15111510
# Should not raise an exception

tests/unittests/tools/test_base_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def test_process_llm_request_no_declaration():
6262
tool_context=tool_context, llm_request=llm_request
6363
)
6464

65-
assert llm_request.config is None
65+
assert llm_request.config == types.GenerateContentConfig()
6666

6767

6868
@pytest.mark.asyncio

tests/unittests/tools/test_google_search_tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ async def test_process_llm_request_with_empty_model_raises_error(self):
322322
)
323323

324324
@pytest.mark.asyncio
325-
async def test_process_llm_request_with_none_config(self):
325+
async def test_process_llm_request_with_no_config(self):
326326
"""Test processing LLM request with None config."""
327327
tool = GoogleSearchTool()
328328
tool_context = await _create_tool_context()
329329

330-
llm_request = LlmRequest(model='gemini-2.0-flash', config=None)
330+
llm_request = LlmRequest(model='gemini-2.0-flash')
331331

332332
await tool.process_llm_request(
333333
tool_context=tool_context, llm_request=llm_request

tests/unittests/tools/test_url_context_tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ async def test_process_llm_request_with_empty_model_raises_error(self):
242242
)
243243

244244
@pytest.mark.asyncio
245-
async def test_process_llm_request_with_none_config(self):
245+
async def test_process_llm_request_with_no_config(self):
246246
"""Test processing LLM request with None config."""
247247
tool = UrlContextTool()
248248
tool_context = await _create_tool_context()
249249

250-
llm_request = LlmRequest(model='gemini-2.0-flash', config=None)
250+
llm_request = LlmRequest(model='gemini-2.0-flash')
251251

252252
await tool.process_llm_request(
253253
tool_context=tool_context, llm_request=llm_request

0 commit comments

Comments
 (0)