This project integrates Langflow with Chainlit to create a powerful and user-friendly chatbot interface. The integration allows you to design complex language models and workflows in Langflow and then expose them through a Chainlit-powered chat interface.
- Python 3.10 or higher
- Langflow server running (locally or remotely)
It's recommended to use a virtual environment to manage dependencies for this project. Here's how to set it up:
-
Open a terminal and navigate to your project directory.
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
- On Windows:
Once your virtual environment is activated, install the required dependencies:
pip install -r requirements.txt
- Copy the
.env.example
file in the project root to a new file named.env
:
cp .env.example .env
- Open the
.env
file and replace the placeholder values with your actual Langflow configuration:
# Langflow API URL (e.g., http://localhost:7860)
LF_BASE_API_URL=your_langflow_api_url
# Langflow API Key
LF_API_KEY=your_langflow_api_key
# Langflow Flow ID
LF_FLOW_ID=your_langflow_flow_id
Replace the following:
your_langflow_api_url
with the URL of your Langflow server (e.g., http://localhost:7860)your_langflow_api_key
with your actual Langflow API key (e.g., sk-oph-VQdeGJdxxTd_wouyleFJ0XSII1hFGHUSXuY340w)your_langflow_flow_id
with the ID of the specific flow you want to use (e.g, be21d65f-b2fa-4e43-a2e4-562f81235c1a)
To get your Langflow API Key:
- Open your Langflow application.
- Click on the user icon in the top right corner.
- Select "Settings" from the dropdown menu.
- In the Settings page, navigate to the "Langflow API" section.
- Here you can view your existing API keys or create a new one.
To find the Base URL and Flow ID:
- Open the specific flow you want to use in Langflow.
- Look at the URL in your browser's address bar.
- The URL will be in this format:
http://127.0.0.1:7860/flow/13f9c6fc-fda3-4ab2-9992-25b7b93ba24a/...
- The Base URL is the part before
/flow/
:http://127.0.0.1:7860
- The Flow ID is the UUID after
/flow/
:13f9c6fc-fda3-4ab2-9992-25b7b93ba24a
- The Base URL is the part before
Use the Langflow UI to design your language model workflow. This is where you'll create the logic for your chatbot.
Once your Langflow is set up and running, start the Chainlit app:
chainlit run app.py
Open your web browser and navigate to the URL provided by Chainlit (e.g., http://localhost:8000
). You can now interact with your Langflow-powered chatbot through the Chainlit interface.
- Ensure all environment variables are correctly set in the
.env
file. - If you encounter any issues with the Langflow connection, verify that Langflow is running and accessible at the URL specified in
LF_BASE_API_URL
. - Double-check that your
LF_API_KEY
is correct and has the necessary permissions. - Make sure you have the latest versions of
langflow
andchainlit
installed. - If you're experiencing dependency conflicts, ensure you're using the virtual environment and that it's properly activated.
Contributions to improve this integration are welcome. Please feel free to submit issues or pull requests.