[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:
@@ -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 = """<|DSML|function_calls>
|
||||
<|DSML|invoke name="get_favorite_tourist_spot">
|
||||
{
|
||||
"city": "San Francisco"
|
||||
"city": "San Francisco",
|
||||
"another_city": "London",
|
||||
"topn": 10,
|
||||
"obj": {
|
||||
"name": "John",
|
||||
"age": 30
|
||||
}
|
||||
}
|
||||
</|DSML|invoke>
|
||||
</|DSML|function_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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user