Skip to content

Commit 7ec8800

Browse files
committed
address comments
1 parent df9ffca commit 7ec8800

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/strands/models/gemini.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GeminiConfig(TypedDict, total=False):
4343
"""
4444

4545
model_id: Required[str]
46-
params: Optional[dict[str, Any]]
46+
params: dict[str, Any]
4747

4848
def __init__(
4949
self,
@@ -183,9 +183,9 @@ def _format_request_tools(self, tool_specs: Optional[list[ToolSpec]]) -> list[ge
183183
genai.types.Tool(
184184
function_declarations=[
185185
genai.types.FunctionDeclaration(
186-
name=tool_spec["name"],
187186
description=tool_spec["description"],
188-
parameters=tool_spec["inputSchema"]["json"],
187+
name=tool_spec["name"],
188+
parameters_json_schema=tool_spec["inputSchema"]["json"],
189189
)
190190
for tool_spec in tool_specs or []
191191
],

tests/strands/models/test_gemini.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def messages():
3434
return [{"role": "user", "content": [{"text": "test"}]}]
3535

3636

37+
@pytest.fixture
38+
def tool_spec():
39+
return {
40+
"description": "description",
41+
"name": "name",
42+
"inputSchema": {"json": {"key": "val"}},
43+
}
44+
45+
3746
@pytest.fixture
3847
def system_prompt():
3948
return "s1"
@@ -211,6 +220,30 @@ async def test_stream_request_with_reasoning(gemini_client, model, model_id):
211220
gemini_client.aio.models.generate_content_stream.assert_called_with(**exp_request)
212221

213222

223+
@pytest.mark.asyncio
224+
async def test_stream_request_with_tool_spec(gemini_client, model, model_id, tool_spec):
225+
await anext(model.stream([], [tool_spec]))
226+
227+
exp_request = {
228+
"config": {
229+
"tools": [
230+
{
231+
"function_declarations": [
232+
{
233+
"description": "description",
234+
"name": "name",
235+
"parameters_json_schema": {"key": "val"},
236+
},
237+
],
238+
},
239+
],
240+
},
241+
"contents": [],
242+
"model": model_id,
243+
}
244+
gemini_client.aio.models.generate_content_stream.assert_called_with(**exp_request)
245+
246+
214247
@pytest.mark.asyncio
215248
async def test_stream_request_with_tool_use(gemini_client, model, model_id):
216249
messages = [

0 commit comments

Comments
 (0)