enable thinking in anthropic CUA (#2240)
This commit is contained in:
@@ -1416,6 +1416,8 @@ class ForgeAgent:
|
|||||||
"display_width_px": settings.BROWSER_WIDTH,
|
"display_width_px": settings.BROWSER_WIDTH,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
thinking = {"type": "enabled", "budget_tokens": 1024}
|
||||||
|
betas = ["computer-use-2025-01-24"]
|
||||||
if not llm_caller.message_history:
|
if not llm_caller.message_history:
|
||||||
llm_response = await llm_caller.call(
|
llm_response = await llm_caller.call(
|
||||||
prompt=task.navigation_goal,
|
prompt=task.navigation_goal,
|
||||||
@@ -1423,7 +1425,8 @@ class ForgeAgent:
|
|||||||
use_message_history=True,
|
use_message_history=True,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
raw_response=True,
|
raw_response=True,
|
||||||
betas=["computer-use-2025-01-24"],
|
betas=betas,
|
||||||
|
thinking=thinking,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
llm_response = await llm_caller.call(
|
llm_response = await llm_caller.call(
|
||||||
@@ -1431,7 +1434,8 @@ class ForgeAgent:
|
|||||||
use_message_history=True,
|
use_message_history=True,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
raw_response=True,
|
raw_response=True,
|
||||||
betas=["computer-use-2025-01-24"],
|
betas=betas,
|
||||||
|
thinking=thinking,
|
||||||
)
|
)
|
||||||
assistant_content = llm_response["content"]
|
assistant_content = llm_response["content"]
|
||||||
llm_caller.message_history.append({"role": "assistant", "content": assistant_content})
|
llm_caller.message_history.append({"role": "assistant", "content": assistant_content})
|
||||||
|
|||||||
@@ -693,6 +693,7 @@ class LLMCaller:
|
|||||||
max_tokens = active_parameters.get("max_completion_tokens") or active_parameters.get("max_tokens") or 4096
|
max_tokens = active_parameters.get("max_completion_tokens") or active_parameters.get("max_tokens") or 4096
|
||||||
model_name = self.llm_config.model_name.replace("bedrock/", "").replace("anthropic/", "")
|
model_name = self.llm_config.model_name.replace("bedrock/", "").replace("anthropic/", "")
|
||||||
betas = active_parameters.get("betas", NOT_GIVEN)
|
betas = active_parameters.get("betas", NOT_GIVEN)
|
||||||
|
thinking = active_parameters.get("thinking", NOT_GIVEN)
|
||||||
LOG.info("Anthropic request", betas=betas, tools=tools, timeout=timeout)
|
LOG.info("Anthropic request", betas=betas, tools=tools, timeout=timeout)
|
||||||
response = await app.ANTHROPIC_CLIENT.beta.messages.create(
|
response = await app.ANTHROPIC_CLIENT.beta.messages.create(
|
||||||
max_tokens=max_tokens,
|
max_tokens=max_tokens,
|
||||||
@@ -701,6 +702,7 @@ class LLMCaller:
|
|||||||
tools=tools or NOT_GIVEN,
|
tools=tools or NOT_GIVEN,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
betas=betas,
|
betas=betas,
|
||||||
|
thinking=thinking,
|
||||||
)
|
)
|
||||||
LOG.info("Anthropic response", response=response, betas=betas, tools=tools, timeout=timeout)
|
LOG.info("Anthropic response", response=response, betas=betas, tools=tools, timeout=timeout)
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user