langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
32.23k stars 3.96k forks source link

How to use Sequential Chains in LangFlow #1308

Closed surendransuri closed 3 months ago

surendransuri commented 9 months ago

How to use Sequential Chains in LangFlow

dosubot[bot] commented 9 months ago

πŸ€–

Hello @surendransuri!

I'm Dosu, a friendly bot here to assist you while we wait for a human maintainer to chip in. I'm here to help you squash bugs, answer your questions, and even guide you to contribute to the project if you're interested. Let's make your LangFlow experience as smooth as possible together! πŸš€

In LangFlow, Sequential Chains are used to create a sequence of operations that can be executed in a specific order. Here's how you can use them:

  1. SeriesCharacterChain: This chain allows you to have a conversation with a character from a series. You can initialize it by providing the character and series names. Here's an example:
chain = SeriesCharacterChain(character="Sherlock Holmes", series="Sherlock")
  1. MidJourneyPromptChain: This chain generates new MidJourney prompts. You can initialize it without any parameters:
chain = MidJourneyPromptChain()
  1. TimeTravelGuideChain: This chain acts as a time travel guide. You can initialize it without any parameters:
chain = TimeTravelGuideChain()
  1. CombineDocsChain: This chain combines documents. You need to provide a language model and a chain type to initialize it:
chain = CombineDocsChain.initialize(llm=your_language_model, chain_type="your_chain_type")

After initializing a chain, you can use its run method to execute it:

result = chain.run(your_input)

Please replace your_input, your_language_model, and your_chain_type with your actual values.

To initialize and use the Sequential Chains in LangFlow, you need to follow the syntax and parameters as shown above. Here's how you can do it:

  1. Import the required chain from the langflow.interface.chains.custom module. For example, if you want to use the SeriesCharacterChain, you would do:
from langflow.interface.chains.custom import SeriesCharacterChain
  1. Initialize the chain by providing the required parameters. For SeriesCharacterChain, you need to provide character, series, and optionally template and ai_prefix_value. Here's an example:
chain = SeriesCharacterChain(character="Sherlock Holmes", series="Sherlock")
  1. To use the chain, you can call the run method on the chain instance. The run method takes a variable number of arguments and keyword arguments, depending on the specific chain.
result = chain.run(input="What is your name?")

Please note that the exact parameters and their types may vary depending on the specific chain you are using. Always refer to the chain's class definition for the most accurate information.

For more details, you can refer to the source code in the langflow repository.

I hope this helps! If you have any more questions, feel free to ask.

Best, Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

victorpicaud commented 9 months ago

Chain Sequential COMBINATOR.json here is a custom component that does that but it needs a bit of imporvement (orders params)

dosubot[bot] commented 6 months ago

Hi, @surendransuri, I'm helping the langflow team manage their backlog and am marking this issue as stale.

It looks like the issue you opened regarding using Sequential Chains in LangFlow has been resolved with detailed instructions provided by me on how to use Sequential Chains, along with examples and references to the source code. Additionally, there were some helpful responses from @victorpicaud who shared a custom component for Sequential Chains but noted that it needs some improvement in ordering parameters.

Could you please confirm if this issue is still relevant to the latest version of the langflow repository? If it is, please let the langflow team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

rashid-globallogic commented 3 months ago

let suppose I have four component chatInput-->Prompts--->AzureOpenAI--->Chatoutput. I have import all component individually in Json file. In vs code i have load like this run_flow_from_json(flow="simple_new.json", input_value=query.question). how can I perform chaining on it