返回提交历史
Modified
etc/unittest/test_reasoning_standardization.py
+0
-1
Modified
g4f/client/__init__.py
+6
-6
XFEstudio/gpt4free
Address review comments: remove hardcoded path and rename reasoning_content to reasoning
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
69ee861a
代码差异
2 个文件
+6
-7
@@ -6,7 +6,6 @@ Create a comprehensive test for reasoning field standardization
6
6
import sys
7
7
import unittest
8
8
import json
9
sys.path.append('/home/runner/work/gpt4free/gpt4free')
10
9
11
10
from g4f.providers.response import Reasoning
12
11
from g4f.client.stubs import ChatCompletionDelta, ChatCompletionChunk
@@ -67,7 +67,7 @@ def iter_response(
67
67
stop: Optional[list[str]] = None
68
68
) -> ChatCompletionResponseType:
69
69
content = ""
70
reasoning_content = []
70
reasoning = []
71
71
finish_reason = None
72
72
tool_calls = None
73
73
usage = None
@@ -97,7 +97,7 @@ def iter_response(
97
97
provider = chunk
98
98
continue
99
99
elif isinstance(chunk, Reasoning):
100
reasoning_content.append(chunk)
100
reasoning.append(chunk)
101
101
elif isinstance(chunk, HiddenResponse):
102
102
continue
103
103
elif isinstance(chunk, Exception):
@@ -145,7 +145,7 @@ def iter_response(
145
145
content, finish_reason, completion_id, int(time.time()), usage=usage,
146
146
**filter_none(tool_calls=[ToolCallModel.model_construct(**tool_call) for tool_call in tool_calls]) if tool_calls is not None else {},
147
147
conversation=None if conversation is None else conversation.get_dict(),
148
reasoning=reasoning_content if reasoning_content else None
148
reasoning=reasoning if reasoning else None
149
149
)
150
150
if provider is not None:
151
151
chat_completion.provider = provider.name
@@ -172,7 +172,7 @@ async def async_iter_response(
172
172
stop: Optional[list[str]] = None
173
173
) -> AsyncChatCompletionResponseType:
174
174
content = ""
175
reasoning_content = []
175
reasoning = []
176
176
finish_reason = None
177
177
completion_id = ''.join(random.choices(string.ascii_letters + string.digits, k=28))
178
178
idx = 0
@@ -200,7 +200,7 @@ async def async_iter_response(
200
200
provider = chunk
201
201
continue
202
202
elif isinstance(chunk, Reasoning) and not stream:
203
reasoning_content.append(chunk)
203
reasoning.append(chunk)
204
204
elif isinstance(chunk, HiddenResponse):
205
205
continue
206
206
elif isinstance(chunk, Exception):
@@ -250,7 +250,7 @@ async def async_iter_response(
250
250
tool_calls=[ToolCallModel.model_construct(**tool_call) for tool_call in tool_calls]
251
251
) if tool_calls is not None else {},
252
252
conversation=conversation,
253
reasoning=reasoning_content if reasoning_content else None
253
reasoning=reasoning if reasoning else None
254
254
)
255
255
if provider is not None:
256
256
chat_completion.provider = provider.name