返回提交历史
Modified
g4f/Provider/needs_auth/Antigravity.py
+6
-3
Modified
g4f/Provider/needs_auth/GeminiCLI.py
+7
-2
XFEstudio/gpt4free
fix: update tool call indexing and yield logic in Antigravity and GeminiCLI providers
f418b6a7
代码差异
2 个文件
+13
-5
@@ -1252,6 +1252,8 @@ class AntigravityProvider:
1252
1252
raise RuntimeError(f"Antigravity API error {resp.status}: {await resp.text()}")
1253
1253
1254
1254
usage_metadata = {}
1255
openai_tool_calls = []
1256
tool_calls_index = 0
1255
1257
async for json_data in parse_sse_stream(resp.content):
1256
1258
# Process JSON data according to Gemini API structure
1257
1259
candidates = json_data.get("response", {}).get("candidates", [])
@@ -1291,11 +1293,10 @@ class AntigravityProvider:
1291
1293
1292
1294
if tool_calls:
1293
1295
# Convert Gemini tool calls to OpenAI format
1294
openai_tool_calls = []
1295
1296
for i, part in enumerate(tool_calls):
1296
1297
tc = part["functionCall"]
1297
1298
tool_call_obj = {
1298
"index": len(openai_tool_calls),
1299
"index": tool_calls_index,
1299
1300
"id": tc.get("id", f"call_{i}_{tc.get('name', 'unknown')}"),
1300
1301
"type": "function",
1301
1302
"function": {
@@ -1311,7 +1312,9 @@ class AntigravityProvider:
1311
1312
}
1312
1313
}
1313
1314
openai_tool_calls.append(tool_call_obj)
1314
yield ToolCalls(openai_tool_calls)
1315
tool_calls_index += 1
1316
if openai_tool_calls:
1317
yield ToolCalls(openai_tool_calls)
1315
1318
1316
1319
if usage_metadata:
1317
1320
yield Usage(**usage_metadata)
@@ -816,6 +816,9 @@ class GeminiCLIProvider():
816
816
error_body = await resp.text()
817
817
raise RuntimeError(f"Gemini API error {resp.status}: {error_body}")
818
818
819
usage_metadata = {}
820
openai_tool_calls = []
821
tool_calls_index = 0
819
822
async for json_data in parse_sse_stream(resp.content):
820
823
# Process JSON data according to Gemini API structure
821
824
candidates = json_data.get("response", {}).get("candidates", [])
@@ -861,7 +864,7 @@ class GeminiCLIProvider():
861
864
for i, part in enumerate(tool_calls):
862
865
tc = part["functionCall"]
863
866
tool_call_obj = {
864
"index": len(openai_tool_calls),
867
"index": i,
865
868
"id": tc.get("id", f"call_{i}_{tc.get('name', 'unknown')}"),
866
869
"type": "function",
867
870
"function": {
@@ -877,7 +880,9 @@ class GeminiCLIProvider():
877
880
}
878
881
}
879
882
openai_tool_calls.append(tool_call_obj)
880
yield ToolCalls(openai_tool_calls)
883
tool_calls_index += 1
884
if openai_tool_calls:
885
yield ToolCalls(openai_tool_calls)
881
886
if usage_metadata:
882
887
yield Usage(**usage_metadata)
883
888