Skip to content

This project demonstrates how to build a simple no code retrieval augmented generation (RAG) chatbot using Langflow and Mistral AI on a Transfer Pricing based pdf.

Notifications You must be signed in to change notification settings

ghwallis/rag_langflow_mistralai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Low Code / No Code Langflow & Mistral AI Tax Document QA Chatbot

This project demonstrates how to build a question-and-answer chatbot using Langflow, with a document loaded from local memory. Instead of OpenAI, we used Mistral AI for the LLM model.

Langflow is a visual framework for building multi-agent and RAG applications. It is Open-source, Python-powered, fully customizable, LLM and vector store agnostic

Important Note : Detailed instructions on how to install and build on Langflow are contained on their github link here.

Prerequisites

  1. Langflow installed and running
   # Make sure you have >=Python 3.10 installed on your system.
   python -m pip install langflow -U

Then, run Langflow with:

    python -m langflow run

A successful install and run would show the access link as shown below, which will open in your default browser. I ran the installation through vscode, but feel free to leverage your favorite IDE.

Langflow1

  1. Mistral AI API key created

You will need to create a Mistral AI account to generate an API key. Please note that Mistral is only free for a limited time after you create an account. Access the console through the link here

MistralAPI

Creating the Document QA Project

From the Langflow dashboard, click New Project. Select Document QA from the template option. You also have an option to selected a blank canvas to include each of the components listed below.

This creates a basic chatbot flow with the following components:

  • Chat Input
  • Prompt
  • Mistral AI (replacing the OpenAI component)
  • Chat Output
  • Files

The Files component loads a file from your local machine into the Prompt component as {Document}. The Prompt component is instructed to answer questions based on the contents of {Document}. Including a file with the prompt gives the Mistral AI component context it may not otherwise have access to.

Langflow2

Setting Up the Mistral AI Component

  1. To create an environment variable for the Mistral AI component, in the Mistral AI API Key field, click the Globe button, and then click Add New Variable.
  2. In the Variable Name field, enter mistral_api_key.
  3. In the Value field, paste your Mistral AI API Key.
  4. Click Save Variable.

MistralAP2

Loading a Document

  1. In the Files component, click within the Path field.
  2. Select a local file, and then click Open.
  3. The file name appears in the field.

MistralAP3

Running the Document QA Flow

  1. Click the Run button. The Interaction Panel opens, where you can converse with your bot.
  2. Type a message and press Enter.

For this example, we loaded a document on US 482 Regulations regarding methods to determine taxable income in connection with a transfer of intangible property. We asked, "What is an intangible? can you give me some examples?" The bot responded with an accurate summary based on the contents of the document.

Langflow3

Langflow4

Sharing

Builders have a couple of options to share workflows:

  • Export workfow in json format. Once exported, worflow can be run
   results = run_flow_from_json("path/to/flow.json", input_value="What is an intangile?")
  • Other methods for further integrastion to other applications.

    Langflow5

Conclusion

This project showcases how to leverage Langflow and Mistral AI to create a functional Document QA chatbot that can provide context-aware answers based on the content of a loaded document, such as the US 482 Regulations on methods to determine taxable income in connection with a transfer of intangible property.

Feel free to reach out if you have any questions/suggestions or ideas for a project. Thanks for reading!

About

This project demonstrates how to build a simple no code retrieval augmented generation (RAG) chatbot using Langflow and Mistral AI on a Transfer Pricing based pdf.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published