mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-24 13:07:53 +08:00
Address review comments: remove hardcoded path and rename reasoning_content to reasoning
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,6 @@ Create a comprehensive test for reasoning field standardization
|
||||
import sys
|
||||
import unittest
|
||||
import json
|
||||
sys.path.append('/home/runner/work/gpt4free/gpt4free')
|
||||
|
||||
from g4f.providers.response import Reasoning
|
||||
from g4f.client.stubs import ChatCompletionDelta, ChatCompletionChunk
|
||||
|
||||
@@ -67,7 +67,7 @@ def iter_response(
|
||||
stop: Optional[list[str]] = None
|
||||
) -> ChatCompletionResponseType:
|
||||
content = ""
|
||||
reasoning_content = []
|
||||
reasoning = []
|
||||
finish_reason = None
|
||||
tool_calls = None
|
||||
usage = None
|
||||
@@ -97,7 +97,7 @@ def iter_response(
|
||||
provider = chunk
|
||||
continue
|
||||
elif isinstance(chunk, Reasoning):
|
||||
reasoning_content.append(chunk)
|
||||
reasoning.append(chunk)
|
||||
elif isinstance(chunk, HiddenResponse):
|
||||
continue
|
||||
elif isinstance(chunk, Exception):
|
||||
@@ -145,7 +145,7 @@ def iter_response(
|
||||
content, finish_reason, completion_id, int(time.time()), usage=usage,
|
||||
**filter_none(tool_calls=[ToolCallModel.model_construct(**tool_call) for tool_call in tool_calls]) if tool_calls is not None else {},
|
||||
conversation=None if conversation is None else conversation.get_dict(),
|
||||
reasoning=reasoning_content if reasoning_content else None
|
||||
reasoning=reasoning if reasoning else None
|
||||
)
|
||||
if provider is not None:
|
||||
chat_completion.provider = provider.name
|
||||
@@ -172,7 +172,7 @@ async def async_iter_response(
|
||||
stop: Optional[list[str]] = None
|
||||
) -> AsyncChatCompletionResponseType:
|
||||
content = ""
|
||||
reasoning_content = []
|
||||
reasoning = []
|
||||
finish_reason = None
|
||||
completion_id = ''.join(random.choices(string.ascii_letters + string.digits, k=28))
|
||||
idx = 0
|
||||
@@ -200,7 +200,7 @@ async def async_iter_response(
|
||||
provider = chunk
|
||||
continue
|
||||
elif isinstance(chunk, Reasoning) and not stream:
|
||||
reasoning_content.append(chunk)
|
||||
reasoning.append(chunk)
|
||||
elif isinstance(chunk, HiddenResponse):
|
||||
continue
|
||||
elif isinstance(chunk, Exception):
|
||||
@@ -250,7 +250,7 @@ async def async_iter_response(
|
||||
tool_calls=[ToolCallModel.model_construct(**tool_call) for tool_call in tool_calls]
|
||||
) if tool_calls is not None else {},
|
||||
conversation=conversation,
|
||||
reasoning=reasoning_content if reasoning_content else None
|
||||
reasoning=reasoning if reasoning else None
|
||||
)
|
||||
if provider is not None:
|
||||
chat_completion.provider = provider.name
|
||||
|
||||
Reference in New Issue
Block a user