mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 11:29:39 +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
|
||||
|
||||
thinking: typing.Optional[bool] = False
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
@@ -50,9 +50,6 @@ class AnthropicMessages(requester.LLMAPIRequester):
|
||||
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
|
||||
|
||||
if model.thinking:
|
||||
args["thinking"] = {"type": "enabled", "budget_tokens": 16000}
|
||||
|
||||
# 处理消息
|
||||
|
||||
# system
|
||||
@@ -150,8 +147,8 @@ class AnthropicMessages(requester.LLMAPIRequester):
|
||||
|
||||
for block in resp.content:
|
||||
if block.type == 'thinking':
|
||||
args['content'] = '<think>' + block.thinking + '</think>'
|
||||
if block.type == 'text':
|
||||
args['content'] = '<think>' + block.thinking + '</think>\n' + args['content']
|
||||
elif block.type == 'text':
|
||||
args['content'] += block.text
|
||||
elif block.type == 'tool_use':
|
||||
assert type(block) is anthropic.types.tool_use_block.ToolUseBlock
|
||||
|
||||
Reference in New Issue
Block a user