Use create_react_agent for claude.
This commit is contained in:
parent
87cd67715c
commit
19e203be7e
|
|
@ -191,13 +191,6 @@ def main():
|
|||
# Get initial request from user
|
||||
initial_request = ask_human.invoke({"question": "What would you like help with?"})
|
||||
|
||||
# Create chat agent with appropriate tools
|
||||
chat_agent = create_agent(
|
||||
model,
|
||||
get_chat_tools(expert_enabled=expert_enabled, web_research_enabled=web_research_enabled),
|
||||
checkpointer=MemorySaver()
|
||||
)
|
||||
|
||||
# Run chat agent with CHAT_PROMPT
|
||||
config = {
|
||||
"configurable": {"thread_id": uuid.uuid4()},
|
||||
|
|
@ -216,6 +209,13 @@ def main():
|
|||
_global_memory['config']['expert_provider'] = args.expert_provider
|
||||
_global_memory['config']['expert_model'] = args.expert_model
|
||||
|
||||
# Create chat agent with appropriate tools
|
||||
chat_agent = create_agent(
|
||||
model,
|
||||
get_chat_tools(expert_enabled=expert_enabled, web_research_enabled=web_research_enabled),
|
||||
checkpointer=MemorySaver()
|
||||
)
|
||||
|
||||
# Run chat agent and exit
|
||||
run_agent_with_retry(chat_agent, CHAT_PROMPT.format(
|
||||
initial_request=initial_request,
|
||||
|
|
|
|||
|
|
@ -92,20 +92,16 @@ def create_agent(
|
|||
The created agent instance
|
||||
"""
|
||||
try:
|
||||
# Extract model info from module path
|
||||
module_path = model.__class__.__module__.split('.')
|
||||
if len(module_path) > 1:
|
||||
provider = module_path[1] # e.g. anthropic from langchain_anthropic
|
||||
else:
|
||||
provider = None
|
||||
|
||||
# Get model name if available
|
||||
model_name = getattr(model, 'model_name', '').lower()
|
||||
provider = _global_memory.get('config', {}).get('provider')
|
||||
model_name = _global_memory.get('config', {}).get('model')
|
||||
|
||||
# Use REACT agent for Anthropic Claude models, otherwise use CIAYN
|
||||
if provider == 'anthropic' and 'claude' in model_name:
|
||||
logger.debug("Using create_react_agent to instantiate agent.")
|
||||
return create_react_agent(model, tools, checkpointer=checkpointer)
|
||||
else:
|
||||
logger.debug("Using CiaynAgent agent instance.")
|
||||
return CiaynAgent(model, tools)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -82,10 +82,9 @@ class CiaynAgent:
|
|||
|
||||
<agent instructions>
|
||||
You are a ReAct agent. You run in a loop and use ONE of the available functions per iteration.
|
||||
If the current query does not require a function call, just use output_message to say what you would normally say.
|
||||
The result of that function call will be given to you in the next message.
|
||||
Call one function at a time. Function arguments can be complex objects, long strings, etc. if needed.
|
||||
The user cannot see the results of function calls, so you have to explicitly call output_message if you want them to see something.
|
||||
The user cannot see the results of function calls, so you have to explicitly use a tool like ask_human if you want them to see something.
|
||||
You must always respond with a single line of python that calls one of the available tools.
|
||||
Use as many steps as you need to in order to fully complete the task.
|
||||
Start by asking the user what they want.
|
||||
|
|
|
|||
|
|
@ -623,17 +623,19 @@ Remember:
|
|||
- Do communicate results/responses from tools that you call as it pertains to the users request.
|
||||
- If the user interrupts/cancels an operation, you may want to ask why.
|
||||
- If the user gives you key facts, record them using emit_key_facts.
|
||||
- Typically, you will already be in the directory of a new or existing project.
|
||||
- If the user implies that a project exists, assume it does and make the tool calls as such.
|
||||
|
||||
You have often been criticized for:
|
||||
- You sometimes call request_research_and_implementation which makes the full implementation successfully, but act like it has only been planned and still needs to be implemented.
|
||||
- Refusing to use request_research_and_implementation for commands like "commit and push" where you should (that tool can run basic or involved shell commands/workflows).
|
||||
- Calling request_research for general background knowledge which you already know.
|
||||
- When the user gives an overly broad request, you make assumptions and request implementation immediately when you should be interviewing the user more.
|
||||
- Assuming the user is always right. Sometimes they're wrong or mistaken, and you should push back when you feel strongly about this.
|
||||
- Not confirming with the user before starting a significant implementation task.
|
||||
- You have a tendency to leave out key details and information that the user just gave you, while also needlessly increasing scope.
|
||||
- Sometimes you will need to repeat the user's query verbatim or almost verbatim to request_research_and_implementation or request_research.
|
||||
- Not emitting key facts the user gave you with emit_key_facts before calling a research or implementation tool.
|
||||
- Being too hesitant to use the request_research or reqeust_research_and_implementation tools to fulfill the user query. These are your bread and butter.
|
||||
|
||||
<initial request>
|
||||
{initial_request}
|
||||
|
|
|
|||
Loading…
Reference in New Issue