Closed alexoli97 closed 7 months ago
🤖
Hey there, @alexoli97! Long time no code 😄. How's everything on your end?
Thank you for providing the details of the error you're encountering. The TypeError: add_user_step_to_reasoning() got multiple values for argument 'generate_chat_message_fn'
error typically occurs when a function is called with multiple values for a specific argument. In this case, it seems like the add_user_step_to_reasoning
function is receiving multiple values for the generate_chat_message_fn
argument.
Based on the function definition you provided, add_user_step_to_reasoning
expects five arguments:
def add_user_step_to_reasoning(
generate_chat_message_fn: ChatMessageCallable,
step: TaskStep,
memory: BaseMemory,
current_reasoning: List[BaseReasoningStep],
verbose: bool = False,
) -> None:
The error message suggests that generate_chat_message_fn
is being provided more than once when the function is called. This could be happening in the _run_step
, _arun_step
, _run_step_stream
, or _arun_step_stream
methods of the MultimodalReActAgentWorker
class, as these are the methods that call add_user_step_to_reasoning
.
To resolve this issue, you'll need to identify where add_user_step_to_reasoning
is being called with multiple values for generate_chat_message_fn
and correct it. If you're unable to find the source of the error, it would be helpful if you could provide the full stack trace or the code snippet where the function is being called.
As for the fix you've suggested, without seeing the actual code it's hard to say whether it would resolve the issue. However, based on the information you've provided, it seems like a reasonable approach. Please ensure that your modifications maintain the original functionality of the add_user_step_to_reasoning
function and the methods that call it.
For more information on how to debug this type of error, you might find this StackOverflow thread helpful. It explains the error in more detail and provides some general advice on how to fix it.
I hope this helps! If you have any further questions or need more assistance, please don't hesitate to ask.
I am having this issue as well @alexoli97 , could you point out specifically what you changed in the file to fix it? I cannot see any changes when comparing your comment to the current file.
just delete this i think
self._add_user_step_to_reasoning = partial( add_user_step_to_reasoning, generate_chat_message_fn=generate_openai_multi_modal_chat_message, )
@dosu-bot here is the function def add_user_step_to_reasoning( generate_chat_message_fn: ChatMessageCallable, step: TaskStep, memory: BaseMemory, current_reasoning: List[BaseReasoningStep], verbose: bool = False, ) -> None: """Add user step to reasoning.
Adds both text input and image input to reasoning.
"""
# raise error if step.input is None
if step.input is None:
raise ValueError("Step input is None.")
# TODO: support gemini as well. Currently just supports OpenAI
# TODO: currently assume that you can't generate images in the loop,
# so step_state contains the original image_docs from the task
# (it doesn't change)
image_docs = step.step_state["image_docs"]
image_kwargs = step.step_state.get("image_kwargs", {})
if "is_first" in step.step_state and step.step_state["is_first"]:
mm_message = generate_chat_message_fn(
prompt=step.input,
role=MessageRole.USER,
image_documents=image_docs,
**image_kwargs,
)
# add to new memory
memory.put(mm_message)
step.step_state["is_first"] = False
else:
# NOTE: this is where the user specifies an intermediate step in the middle
# TODO: don't support specifying image_docs here for now
reasoning_step = ObservationReasoningStep(observation=step.input)
current_reasoning.append(reasoning_step)
if verbose:
print(f"Added user message to memory: {step.input}")
Bug Description
in : response = execute_steps(agent, task)
error: TypeError Traceback (most recent call last) in <cell line: 2>() 1 # Run this and not the below if you just want to run everything at once. ----> 2 response = execute_steps(agent, task)
6 frames /usr/local/lib/python3.10/dist-packages/llama_index/core/agent/react_multimodal/step.py in _run_step(self, step, task) 388 # an intermediate step in the middle 389 if step.input is not None: --> 390 self._add_user_step_to_reasoning( 391 step, 392 task.extra_state["new_memory"],
TypeError: add_user_step_to_reasoning() got multiple values for argument 'generate_chat_message_fn'
Version
v0.10.12
Steps to Reproduce
follow this his guide: https://docs.llamaindex.ai/en/stable/examples/multi_modal/mm_agent.html
Relevant Logs/Tracbacks