Replies: 2 comments
-
Hey @Arjun17m! I'm Dosu, your friendly neighborhood bot here to lend a hand with bugs, answer questions, or help you contribute while we wait for a human maintainer to chime in. I'm diving into your issue now and will get back to you with a detailed answer shortly! |
Beta Was this translation helpful? Give feedback.
-
Hi @Arjun17m , The problem you're facing here is related to declaring an agent executor with an agent executor inside (which leads to a double definition of
This code should be enough : agent = create_csv_agent(ChatOpenAI() ,"app/test.csv" , verbose = True )
result = agent({'input' : "How many survivors ? "} ) However, if you still want to bind additional tools, you can pass them using the agent = create_csv_agent(ChatOpenAI() ,"app/test.csv" , verbose = True, extra_tools = tools) Let me know if that solves your problem |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to create a csv agent on which i can run some python pandas code but while executing I am getting below error
TypeError Traceback (most recent call last)
Cell In[45], line 4
----> 4 result = agent_executor({'input' : query} )
5 #agent(query)
File /lib/python3.9/site-packages/langchain_core/_api/deprecation.py:148, in deprecated..deprecate..warning_emitting_wrapper(*args, **kwargs)
146 warned = True
147 emit_warning()
--> 148 return wrapped(*args, **kwargs)
File /lib/python3.9/site-packages/langchain/chains/base.py:378, in Chain.call(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info)
346 """Execute the chain.
347
348 Args:
(...)
369
Chain.output_keys
.370 """
371 config = {
372 "callbacks": callbacks,
373 "tags": tags,
374 "metadata": metadata,
375 "run_name": run_name,
376 }
--> 378 return self.invoke(
379 inputs,
380 cast(RunnableConfig, {k: v for k, v in config.items() if v is not None}),
381 return_only_outputs=return_only_outputs,
382 include_run_info=include_run_info,
383 )
File /lib/python3.9/site-packages/langchain/chains/base.py:163, in Chain.invoke(self, input, config, **kwargs)
161 except BaseException as e:
162 run_manager.on_chain_error(e)
--> 163 raise e
164 run_manager.on_chain_end(outputs)
166 if include_run_info:
File /lib/python3.9/site-packages/langchain/chains/base.py:153, in Chain.invoke(self, input, config, **kwargs)
150 try:
151 self._validate_inputs(inputs)
152 outputs = (
--> 153 self._call(inputs, run_manager=run_manager)
154 if new_arg_supported
155 else self._call(inputs)
156 )
158 final_outputs: Dict[str, Any] = self.prep_outputs(
159 inputs, outputs, return_only_outputs
160 )
161 except BaseException as e:
File /lib/python3.9/site-packages/langchain/agents/agent.py:1432, in AgentExecutor._call(self, inputs, run_manager)
1430 # We now enter the agent loop (until it returns something).
1431 while self._should_continue(iterations, time_elapsed):
-> 1432 next_step_output = self._take_next_step(
1433 name_to_tool_map,
1434 color_mapping,
1435 inputs,
1436 intermediate_steps,
1437 run_manager=run_manager,
1438 )
1439 if isinstance(next_step_output, AgentFinish):
1440 return self._return(
1441 next_step_output, intermediate_steps, run_manager=run_manager
1442 )
File /lib/python3.9/site-packages/langchain/agents/agent.py:1138, in AgentExecutor._take_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager)
1129 def _take_next_step(
1130 self,
1131 name_to_tool_map: Dict[str, BaseTool],
(...)
1135 run_manager: Optional[CallbackManagerForChainRun] = None,
1136 ) -> Union[AgentFinish, List[Tuple[AgentAction, str]]]:
1137 return self._consume_next_step(
-> 1138 [
1139 a
1140 for a in self._iter_next_step(
1141 name_to_tool_map,
1142 color_mapping,
1143 inputs,
1144 intermediate_steps,
1145 run_manager,
1146 )
1147 ]
1148 )
File /lib/python3.9/site-packages/langchain/agents/agent.py:1138, in (.0)
1129 def _take_next_step(
1130 self,
1131 name_to_tool_map: Dict[str, BaseTool],
(...)
1135 run_manager: Optional[CallbackManagerForChainRun] = None,
1136 ) -> Union[AgentFinish, List[Tuple[AgentAction, str]]]:
1137 return self._consume_next_step(
-> 1138 [
1139 a
1140 for a in self._iter_next_step(
1141 name_to_tool_map,
1142 color_mapping,
1143 inputs,
1144 intermediate_steps,
1145 run_manager,
1146 )
1147 ]
1148 )
File /lib/python3.9/site-packages/langchain/agents/agent.py:1166, in AgentExecutor._iter_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager)
1163 intermediate_steps = self._prepare_intermediate_steps(intermediate_steps)
1165 # Call the LLM to see what to do.
-> 1166 output = self.agent.plan(
1167 intermediate_steps,
1168 callbacks=run_manager.get_child() if run_manager else None,
1169 **inputs,
1170 )
1171 except OutputParserException as e:
1172 if isinstance(self.handle_parsing_errors, bool):
File /lib/python3.9/site-packages/langchain/agents/agent.py:397, in RunnableAgent.plan(self, intermediate_steps, callbacks, **kwargs)
389 final_output: Any = None
390 if self.stream_runnable:
391 # Use streaming to make sure that the underlying LLM is invoked in a
392 # streaming
(...)
395 # Because the response from the plan is not a generator, we need to
396 # accumulate the output into final output and return that.
--> 397 for chunk in self.runnable.stream(inputs, config={"callbacks": callbacks}):
398 if final_output is None:
399 final_output = chunk
File /lib/python3.9/site-packages/langchain/agents/agent.py:1571, in AgentExecutor.stream(self, input, config, **kwargs)
1560 config = ensure_config(config)
1561 iterator = AgentExecutorIterator(
1562 self,
1563 input,
(...)
1569 **kwargs,
1570 )
-> 1571 for step in iterator:
1572 yield step
File /lib/python3.9/site-packages/langchain/agents/agent_iterator.py:174, in AgentExecutorIterator.iter(self)
168 while self.agent_executor._should_continue(
169 self.iterations, self.time_elapsed
170 ):
171 # take the next step: this plans next action, executes it,
172 # yielding action and observation as they are generated
173 next_step_seq: NextStepOutput = []
--> 174 for chunk in self.agent_executor._iter_next_step(
175 self.name_to_tool_map,
176 self.color_mapping,
177 self.inputs,
178 self.intermediate_steps,
179 run_manager,
180 ):
181 next_step_seq.append(chunk)
182 # if we're yielding actions, yield them as they come
183 # do not yield AgentFinish, which will be handled below
File /lib/python3.9/site-packages/langchain/agents/agent.py:1166, in AgentExecutor._iter_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager)
1163 intermediate_steps = self._prepare_intermediate_steps(intermediate_steps)
1165 # Call the LLM to see what to do.
-> 1166 output = self.agent.plan(
1167 intermediate_steps,
1168 callbacks=run_manager.get_child() if run_manager else None,
1169 **inputs,
1170 )
1171 except OutputParserException as e:
1172 if isinstance(self.handle_parsing_errors, bool):
TypeError: plan() got multiple values for argument 'intermediate_steps'
System Info
langchain==0.1.17
langchain-community==0.0.36
langchain-core==0.1.48
langchain-experimental==0.0.57
langchain-text-splitters==0.0.1
langsmith==0.1.52
prompt-toolkit==3.0.43
pydantic==2.7.1
pydantic-core==2.18.2
Beta Was this translation helpful? Give feedback.
All reactions