8000 models - openai - argument none (#97) · B-00/sdk-python@61c3bf7 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 61c3bf7

Browse files
authored
models - openai - argument none (strands-agents#97)
1 parent 58dc3ab commit 61c3bf7

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/strands/models/openai.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Client(Protocol):
1818
"""Protocol defining the OpenAI-compatible interface for the underlying provider client."""
1919

2020
@property
21+
# pragma: no cover
2122
def chat(self) -> Any:
2223
"""Chat completions interface."""
2324
...

src/strands/types/models/openai.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def format_chunk(self, event: dict[str, Any]) -> StreamEvent:
206206

207207
case "content_delta":
208208
if event["data_type"] == "tool":
209-
return {"contentBlockDelta": {"delta": {"toolUse": {"input": event["data"].function.arguments}}}}
209+
return {
210+
"contentBlockDelta": {"delta": {"toolUse": {"input": event["data"].function.arguments or ""}}}
211+
}
210212

211213
return {"contentBlockDelta": {"delta": {"text": event["data"]}}}
212214

tests/strands/types/models/test_openai.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ def test_format_request(model, messages, tool_specs, system_prompt):
246246
@pytest.mark.parametrize(
247247
("event", "exp_chunk"),
248248
[
249-
# Case 1: Message start
249+
# Message start
250250
(
251251
{"chunk_type": "message_start"},
252252
{"messageStart": {"role": "assistant"}},
253253
),
254-
# Case 2: Content Start - Tool Use
254+
# Content Start - Tool Use
255255
(
256256
{
257257
"chunk_type": "content_start",
@@ -260,12 +260,12 @@ def test_format_request(model, messages, tool_specs, system_prompt):
260260
},
261261
{"contentBlockStart": {"start": {"toolUse": {"name": "calculator", "toolUseId": "c1"}}}},
262262
),
263-
# Case 3: Content Start - Text
263+
# Content Start - Text
264264
(
265265
{"chunk_type": "content_start", "data_type": "text"},
266266
{"contentBlockStart": {"start": {}}},
267267
),
268-
# Case 4: Content Delta - Tool Use
268+
# Content Delta - Tool Use
269269
(
270270
{
271271
"chunk_type": "content_delta",
@@ -274,32 +274,41 @@ def test_format_request(model, messages, tool_specs, system_prompt):
274274
},
275275
{"contentBlockDelta": {"delta": {"toolUse": {"input": '{"expression": "2+2"}'}}}},
276276
),
277-
# Case 5: Content Delta - Text
277+
# Content Delta - Tool Use - None
278+
(
279+
{
280+
"chunk_type": "content_delta",
281+
"data_type": "tool",
282+
"data": unittest.mock.Mock(function=unittest.mock.Mock(arguments=None)),
283+
},
284+
{"contentBlockDelta": {"delta": {"toolUse": {"input": ""}}}},
285+
),
286+
# Content Delta - Text
278287
(
279288
{"chunk_type": "content_delta", "data_type": "text", "data": "hello"},
280289
{"contentBlockDelta": {"delta": {"text": "hello"}}},
281290
),
282-
# Case 6: Content Stop
291+
# Content Stop
283292
(
284293
{"chunk_type": "content_stop"},
285294
{"contentBlockStop": {}},
286295
),
287-
# Case 7: Message Stop - Tool Use
296+
# Message Stop - Tool Use
288297
(
289298
{"chunk_type": "message_stop", "data": "tool_calls"},
290299
{"messageStop": {"stopReason": "tool_use"}},
291300
),
292-
# Case 8: Message Stop - Max Tokens
301+
# Message Stop - Max Tokens
293302
(
294303
{"chunk_type": "message_stop", "data": "length"},
295304
{"messageStop": {"stopReason": "max_tokens"}},
296305
),
297-
# Case 9: Message Stop - End Turn
306+
# Message Stop - End Turn
298307
(
299308
{"chunk_type": "message_stop", "data": "stop"},
300309
{"messageStop": {"stopReason": "end_turn"}},
301310
),
302-
# Case 10: Metadata
311+
# Metadata
303312
(
304313
{
305314
"chunk_type": "metadata",

0 commit comments

Comments
 (0)
0