Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurs when calling flowasTool using ToolCallAagent #3865

Closed
alex-ge123 opened this issue Sep 20, 2024 · 4 comments
Closed

An error occurs when calling flowasTool using ToolCallAagent #3865

alex-ge123 opened this issue Sep 20, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@alex-ge123
Copy link

Bug Description

微信图片_20240920151735
微信图片_20240920151803

Reproduction

An error occurs when calling flowasTool using ToolCallAagent

Expected behavior

An error occurs when calling flowasTool using ToolCallAagent

Who can help?

No response

Operating System

windows

Langflow Version

1.0.18

Python Version

3.11

Screenshot

No response

Flow File

No response

@alex-ge123 alex-ge123 added the bug Something isn't working label Sep 20, 2024
Copy link

dosubot bot commented Sep 20, 2024

I found a similar issue that might help you resolve the error. The issue titled Asyncio Thread error when running Flow as Tool with a Agent was closed by a pull request that refactored FlowTool to use run_until_complete for async flow execution.

Additionally, ensure that your user_prompt contains the 'input' key. The run_agent method in ToolCallingAgentComponent raises a ValueError if the 'input' key is missing from the user_prompt. Here is the relevant code snippet:

async def run_agent(self) -> Message:
    if "input" not in self.user_prompt:
        raise ValueError("Prompt must contain 'input' key.")
    messages = [
        ("system", self.system_prompt),
        ("placeholder", "{chat_history}"),
        ("human", self.user_prompt),
        ("placeholder", "{agent_scratchpad}"),
    ]
    prompt = ChatPromptTemplate.from_messages(messages)
    agent = create_tool_calling_agent(self.llm, self.tools, prompt)

    runnable = AgentExecutor.from_agent_and_tools(
        agent=cast(BaseSingleActionAgent, agent),
        tools=self.tools,
        verbose=True,
        handle_parsing_errors=self.handle_parsing_errors,
    )
    input_dict: dict[str, str | list[Dict[str, str]]] = {"input": self.input_value}
    if hasattr(self, "memory") and self.memory:
        input_dict["chat_history"] = self.convert_chat_history(self.memory)
    result = await runnable.ainvoke(input_dict)
    self.status = result

    if "output" not in result:
        raise ValueError("Output key not found in result. Tried 'output'.")

    result_string = result["output"]

    return Message(text=result_string)

Make sure your user_prompt string includes the 'input' key, like so:

user_prompt = "Please process the following input: {input}"

This should help resolve the error [1][2].

To continue talking to Dosu, mention @dosu.

@alex-ge123
Copy link
Author

I'm sure I added {input} to the ToolCallAgent component promnt

@Cristhianzl
Copy link
Collaborator

hi @alex-ge123,

can you please provide the JSON file with your flows (the main flow you want to run and the others you want to use as a Tool).

this way I can debug here to understand what can be causing the error for you.

thanks!

@carlosrcoelho
Copy link
Contributor

@alex-ge123
Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants