langflow-ai / langflow

⛓️ Langflow is a visual framework for building multi-agent and RAG applications. It's open-source, Python-powered, fully customizable, model and vector store agnostic.

Home Page:http://www.langflow.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested chats

gamercoder153 opened this issue · comments

Can I create a nested chat between agents? For example, the first agent generates some output, the second agent analyzes it, and prompts the first agent to refine the output based on the second agent's analysis. This process iterates until a high-quality desired output is generated.

Yes, you can create a nested chat between agents where the first agent generates some output, the second agent analyzes it, and then prompts the first agent to refine the output based on the second agent's analysis, iterating until a high-quality desired output is generated.

The XMLAgentComponent class allows for the configuration and execution of LangChain agents using a simplified interface. You can set up and run an agent with a given prompt, tools, and message history, and adapt this setup to create a nested chat between agents.

Here is a simplified example of how you might set up such a nested chat:

async def nested_chat(agent1_name, agent2_name, input_value, llm, tools, iterations=3):
    agent_component = XMLAgentComponent()
    
    for _ in range(iterations):
        # Run the first agent
        result1 = await agent_component.build(
            input_value=input_value,
            llm=llm,
            tools=tools
        )
        
        # Run the second agent with the output of the first agent
        result2 = await agent_component.build(
            input_value=result1,
            llm=llm,
            tools=tools
        )
        
        # Use the output of the second agent to refine the input for the first agent
        input_value = result2
    
    return input_value

# Example usage
final_output = await nested_chat(
    agent1_name="Agent1",
    agent2_name="Agent2",
    input_value="Initial input",
    llm=your_llm_instance,
    tools=your_tools_list
)
print(final_output)

In this example, nested_chat runs the first agent with the initial input, then runs the second agent with the output of the first agent, and iterates this process for a specified number of iterations. The final output is the refined result after the specified iterations [1][2].

To continue talking to Dosu, mention @dosu.

Hi @gamercoder153 ,

Do you need any assistance with this case? If not, please let us know if this issue can be closed.

@carlosrcoelho Hey, can you help me? The bot responded, but I need assistance with creating something similar in Langflow UI.

Hey @gamercoder153

We just launched the integration with Crew AI, so you might get an experience similar to what you're suggesting.

@carlosrcoelho Great I will check it out now!
I tried installing langflow on debian 12 (which is running on my Windows machine through wsl2) but it doesn't install and ends up with BSOD. Can u help me with this

Hey @gamercoder153
Try these steps:

Pip install Langflow

  • Set up an environment: python3 -m venv installation-test
  • Activate your env: source installation-test/bin/activate
  • Run this: python3 -m pip install langflow
  • Then start Langflow: langflow run