XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Address issue #2628 (#2630)

* Address issue #2628 Initialized 'chunk_text' with an empty string before using it. * Update Blackbox.py Refactor <think> parsing logic for improved handling of reasoning content Description: Updated the code to retain <think> and </think> tags when yielding reasoning content. Ensured cleaner splitting and handling of text around <think> and </think> tags. Preserved original content structure in full_response.

25917810
Sreejith BR <164229190+SreejiBR@users.noreply.github.com>
提交于

代码差异

1 个文件 +6 -6
Modified g4f/Provider/Blackbox.py +6 -6
@@ -310,12 +310,12 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
310 310 prompt = messages[-1]["content"]
311 311 yield ImageResponse(images=[image_url], alt=prompt)
312 312 else:
313 if "<think>" in text_to_yield and "</think>" in chunk_text :
314 chunk_text = text_to_yield.split('<think>', 1)
315 yield chunk_text[0]
316 chunk_text = text_to_yield.split('</think>', 1)
317 yield Reasoning(chunk_text[0])
318 yield chunk_text[1]
313 if "<think>" in text_to_yield and "</think>" in text_to_yield:
314 parts = text_to_yield.split('<think>', 1)
315 yield parts[0]
316 reasoning_parts = parts[1].split('</think>', 1)
317 yield Reasoning(f"<think>{reasoning_parts[0]}</think>")
318 yield reasoning_parts[1]
319 319 full_response = text_to_yield
320 320 elif "Generated by BLACKBOX.AI" in text_to_yield:
321 321 conversation.validated_value = await cls.fetch_validated(force_refresh=True)