diff --git a/etc/unittest/test_reasoning_standardization.py b/etc/unittest/test_reasoning_standardization.py index 32f8d71f..5bbe4bfa 100644 --- a/etc/unittest/test_reasoning_standardization.py +++ b/etc/unittest/test_reasoning_standardization.py @@ -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 diff --git a/g4f/client/__init__.py b/g4f/client/__init__.py index b5c419ef..9fed1222 100644 --- a/g4f/client/__init__.py +++ b/g4f/client/__init__.py @@ -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