mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 19:37:36 +08:00
perf(claude): simplify the thinking resp processing
This commit is contained in:
@@ -23,7 +23,5 @@ class LLMModelInfo(pydantic.BaseModel):
|
|||||||
|
|
||||||
vision_supported: typing.Optional[bool] = False
|
vision_supported: typing.Optional[bool] = False
|
||||||
|
|
||||||
thinking: typing.Optional[bool] = False
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
arbitrary_types_allowed = True
|
arbitrary_types_allowed = True
|
||||||
|
|||||||
@@ -50,9 +50,6 @@ class AnthropicMessages(requester.LLMAPIRequester):
|
|||||||
args = self.ap.provider_cfg.data['requester']['anthropic-messages']['args'].copy()
|
args = self.ap.provider_cfg.data['requester']['anthropic-messages']['args'].copy()
|
||||||
args["model"] = model.name if model.model_name is None else model.model_name
|
args["model"] = model.name if model.model_name is None else model.model_name
|
||||||
|
|
||||||
if model.thinking:
|
|
||||||
args["thinking"] = {"type": "enabled", "budget_tokens": 16000}
|
|
||||||
|
|
||||||
# 处理消息
|
# 处理消息
|
||||||
|
|
||||||
# system
|
# system
|
||||||
@@ -150,8 +147,8 @@ class AnthropicMessages(requester.LLMAPIRequester):
|
|||||||
|
|
||||||
for block in resp.content:
|
for block in resp.content:
|
||||||
if block.type == 'thinking':
|
if block.type == 'thinking':
|
||||||
args['content'] = '<think>' + block.thinking + '</think>'
|
args['content'] = '<think>' + block.thinking + '</think>\n' + args['content']
|
||||||
if block.type == 'text':
|
elif block.type == 'text':
|
||||||
args['content'] += block.text
|
args['content'] += block.text
|
||||||
elif block.type == 'tool_use':
|
elif block.type == 'tool_use':
|
||||||
assert type(block) is anthropic.types.tool_use_block.ToolUseBlock
|
assert type(block) is anthropic.types.tool_use_block.ToolUseBlock
|
||||||
|
|||||||
Reference in New Issue
Block a user