mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-17 16:00:59 +00:00
fix:fix remove_think logic, and end<think> fix </think>
This commit is contained in:
@@ -299,12 +299,12 @@ class AnthropicMessages(requester.ProviderAPIRequester):
|
|||||||
async for chunk in await self.client.messages.create(**args):
|
async for chunk in await self.client.messages.create(**args):
|
||||||
# print(chunk)
|
# print(chunk)
|
||||||
if isinstance(chunk, anthropic.types.raw_content_block_start_event.RawContentBlockStartEvent): # 记录开始
|
if isinstance(chunk, anthropic.types.raw_content_block_start_event.RawContentBlockStartEvent): # 记录开始
|
||||||
if chunk.content_block.type == 'thinking' and not remove_think:
|
if not remove_think:
|
||||||
think_started = True
|
if chunk.content_block.type == 'thinking':
|
||||||
continue
|
think_started = True
|
||||||
elif chunk.content_block.type == 'text' and not remove_think:
|
elif chunk.content_block.type == 'text':
|
||||||
think_ended = True
|
think_ended = True
|
||||||
continue
|
continue
|
||||||
elif isinstance(chunk, anthropic.types.raw_content_block_delta_event.RawContentBlockDeltaEvent):
|
elif isinstance(chunk, anthropic.types.raw_content_block_delta_event.RawContentBlockDeltaEvent):
|
||||||
if chunk.delta.type == "thinking_delta":
|
if chunk.delta.type == "thinking_delta":
|
||||||
if think_started:
|
if think_started:
|
||||||
@@ -317,7 +317,7 @@ class AnthropicMessages(requester.ProviderAPIRequester):
|
|||||||
elif chunk.delta.type == "text_delta":
|
elif chunk.delta.type == "text_delta":
|
||||||
if think_ended:
|
if think_ended:
|
||||||
think_ended = False
|
think_ended = False
|
||||||
content = '\n<think>\n' + chunk.delta.text
|
content = '\n</think>\n' + chunk.delta.text
|
||||||
else:
|
else:
|
||||||
content = chunk.delta.text
|
content = chunk.delta.text
|
||||||
elif isinstance(chunk, anthropic.types.raw_content_block_stop_event.RawContentBlockStopEvent):
|
elif isinstance(chunk, anthropic.types.raw_content_block_stop_event.RawContentBlockStopEvent):
|
||||||
|
|||||||
Reference in New Issue
Block a user