Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Agent/ai/llm/_anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def create_chat_completion(
top_p: float = 1.0,
tools: Optional[List[Dict]] = None,
tool_choice: Optional[Union[str, Dict]] = None,
thinking: Optional[bool] = False,
thinking_budget_tokens: Optional[int] = 2048,
**kwargs
):
try:
Expand All @@ -59,13 +61,21 @@ def create_chat_completion(
"max_tokens": max_tokens,
**kwargs,
}
if thinking:
api_params["thinking"] = {
"type": "enabled",
"budget_tokens": thinking_budget_tokens
}
if temperature != 1.0:
api_params["temperature"] = temperature
elif top_p != 1.0:
api_params["top_p"] = top_p
else:
api_params["temperature"] = temperature

if api_params.get("thinking"):
api_params["temperature"] = 1

if system_message:
api_params["system"] = system_message

Expand Down
Loading