mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-08 12:13:36 +00:00
fix(provider): extend StepFun reasoning fallback to all code paths
- Add reasoning_content fallback from reasoning in _parse dict branch - Add content fallback from msg.reasoning in _parse SDK object branch - Add reasoning_content fallback in _parse SDK object branch - Add reasoning fallback in _parse_chunks dict branch - Add reasoning fallback in _parse_chunks SDK object branch This ensures StepFun Plan API works correctly in both streaming and non-streaming modes, for both dict and SDK object response formats.
This commit is contained in:
parent
9e7c07ac89
commit
12ff8b22d6
@ -459,6 +459,8 @@ class OpenAICompatProvider(LLMProvider):
|
||||
if not content and msg0.get("reasoning"):
|
||||
content = self._extract_text_content(msg0.get("reasoning"))
|
||||
reasoning_content = msg0.get("reasoning_content")
|
||||
if not reasoning_content and msg0.get("reasoning"):
|
||||
reasoning_content = self._extract_text_content(msg0.get("reasoning"))
|
||||
for ch in choices:
|
||||
ch_map = self._maybe_mapping(ch) or {}
|
||||
m = self._maybe_mapping(ch_map.get("message")) or {}
|
||||
@ -514,6 +516,8 @@ class OpenAICompatProvider(LLMProvider):
|
||||
finish_reason = ch.finish_reason
|
||||
if not content and m.content:
|
||||
content = m.content
|
||||
if not content and getattr(m, "reasoning", None):
|
||||
content = m.reasoning
|
||||
|
||||
tool_calls = []
|
||||
for tc in raw_tool_calls:
|
||||
@ -530,12 +534,16 @@ class OpenAICompatProvider(LLMProvider):
|
||||
function_provider_specific_fields=fn_prov,
|
||||
))
|
||||
|
||||
reasoning_content = getattr(msg, "reasoning_content", None) or None
|
||||
if not reasoning_content and getattr(msg, "reasoning", None):
|
||||
reasoning_content = msg.reasoning
|
||||
|
||||
return LLMResponse(
|
||||
content=content,
|
||||
tool_calls=tool_calls,
|
||||
finish_reason=finish_reason or "stop",
|
||||
usage=self._extract_usage(response),
|
||||
reasoning_content=getattr(msg, "reasoning_content", None) or None,
|
||||
reasoning_content=reasoning_content,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ -596,6 +604,8 @@ class OpenAICompatProvider(LLMProvider):
|
||||
if text:
|
||||
content_parts.append(text)
|
||||
text = cls._extract_text_content(delta.get("reasoning_content"))
|
||||
if not text:
|
||||
text = cls._extract_text_content(delta.get("reasoning"))
|
||||
if text:
|
||||
reasoning_parts.append(text)
|
||||
for idx, tc in enumerate(delta.get("tool_calls") or []):
|
||||
@ -614,6 +624,8 @@ class OpenAICompatProvider(LLMProvider):
|
||||
content_parts.append(delta.content)
|
||||
if delta:
|
||||
reasoning = getattr(delta, "reasoning_content", None)
|
||||
if not reasoning:
|
||||
reasoning = getattr(delta, "reasoning", None)
|
||||
if reasoning:
|
||||
reasoning_parts.append(reasoning)
|
||||
for tc in (delta.tool_calls or []) if delta else []:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user