Skip to content

Commit

Permalink
fix: Error in RootListenersTracer.on_chain_end callback: ValueError()
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu007 committed Aug 13, 2024
1 parent 38fdcc3 commit 4e0b704
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/codeinterpreterapi/agents/structured_chat/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def create_structured_chat_agent(
| create_complement_input(prompt)
| prompt
| llm_with_stop
| output_parser
)
agent = assign_runnable_history(agent, runnable_config)
agent = agent | output_parser
return agent


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def load_structured_chat_agent_executor(
Load an agent executor(general purpose).
"""
prompt = create_structured_chat_agent_prompt(ci_params.is_ja)
if agent_def.agent_role is not None:
if agent_def and agent_def.agent_role is not None:
prompt = prompt.partial(agent_role=agent_def.agent_role)
input_variables = prompt.input_variables
if ci_params.verbose_prompt:
Expand All @@ -31,10 +31,12 @@ def load_structured_chat_agent_executor(
runnable_config=ci_params.runnable_config,
# stop_sequence=["Observation:", "最終回答", "Final Answer"],
)
agent_def.agent = agent
if agent_def:
agent_def.agent = agent

agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=ci_params.tools, verbose=ci_params.verbose)
agent_def.agent_executor = agent_executor
if agent_def:
agent_def.agent_executor = agent_executor
return agent_executor


Expand Down
2 changes: 1 addition & 1 deletion src/codeinterpreterapi/agents/tool_calling/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def magic_function(input: int) -> int:
| create_complement_input(prompt)
| prompt
| llm_with_tools
| output_parser
)
agent = assign_runnable_history(agent, runnable_config)
agent = agent | output_parser
return agent


Expand Down
8 changes: 5 additions & 3 deletions src/codeinterpreterapi/agents/tool_calling/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def load_tool_calling_agent_executor(
Load an agent executor(general purpose).
"""
prompt = create_tool_calling_agent_prompt(ci_params.is_ja)
if agent_def.message_prompt_template is not None:
if agent_def and agent_def.message_prompt_template is not None:
prompt = prompt.partial(agent_role=agent_def.agent_role)
if ci_params.verbose_prompt:
input_variables = prompt.input_variables
Expand All @@ -30,10 +30,12 @@ def load_tool_calling_agent_executor(
prompt=prompt,
runnable_config=ci_params.runnable_config,
)
agent_def.agent = agent
if agent_def:
agent_def.agent = agent

agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=ci_params.tools, verbose=ci_params.verbose)
agent_def.agent_executor = agent_executor
if agent_def:
agent_def.agent_executor = agent_executor

return agent_executor

Expand Down

0 comments on commit 4e0b704

Please sign in to comment.