[Tool Call] Stream DeepSeek-V3.2 function call parameters in JSON format. (#16091)

Co-authored-by: Huixxi <uestc.hugo@gmail.com>
This commit is contained in:
Muqi Li
2026-03-03 17:46:29 +08:00
committed by GitHub
parent 4c95953b77
commit 666caaf9ce
2 changed files with 31 additions and 22 deletions

View File

@@ -1391,9 +1391,11 @@ class TestDeepSeekV32Detector(unittest.TestCase):
tool_calls_by_index = {}
num_tool_call_chunks = 0
for chunk in chunks:
result = self.detector.parse_streaming_increment(chunk, self.tools)
for call in result.calls:
num_tool_call_chunks += 1
if call.tool_index is not None:
if call.tool_index not in tool_calls_by_index:
tool_calls_by_index[call.tool_index] = {
@@ -1408,6 +1410,8 @@ class TestDeepSeekV32Detector(unittest.TestCase):
"parameters"
] += call.parameters
self.assertGreater(num_tool_call_chunks, 8)
self.assertEqual(len(tool_calls_by_index), 1)
self.assertEqual(tool_calls_by_index[0]["name"], "get_favorite_tourist_spot")
params = json.loads(tool_calls_by_index[0]["parameters"])
@@ -1422,7 +1426,13 @@ class TestDeepSeekV32Detector(unittest.TestCase):
text = """<DSMLfunction_calls>
<DSMLinvoke name="get_favorite_tourist_spot">
{
"city": "San Francisco"
"city": "San Francisco",
"another_city": "London",
"topn": 10,
"obj": {
"name": "John",
"age": 30
}
}
</DSMLinvoke>
</DSMLfunction_calls>"""
@@ -1436,9 +1446,11 @@ class TestDeepSeekV32Detector(unittest.TestCase):
tool_calls_by_index = {}
num_tool_call_chunks = 0
for chunk in chunks:
result = self.detector.parse_streaming_increment(chunk, self.tools)
for call in result.calls:
num_tool_call_chunks += 1
if call.tool_index is not None:
if call.tool_index not in tool_calls_by_index:
tool_calls_by_index[call.tool_index] = {
@@ -1453,6 +1465,7 @@ class TestDeepSeekV32Detector(unittest.TestCase):
"parameters"
] += call.parameters
self.assertGreater(num_tool_call_chunks, 8)
self.assertEqual(len(tool_calls_by_index), 1)
self.assertEqual(tool_calls_by_index[0]["name"], "get_favorite_tourist_spot")