Langchain Chat Assistant using Chainlit App

Yash Jivani - Aug 21 - - Dev Community

Hey there! If you're excited about building your own AI assistant using Langchain and Chainlit, you're in the right place. In this post, I'll walk you through the steps to set up a simple yet powerful AI assistant. Let’s dive in!

Demo

This is Video Demo recording.

Steps to Configure

Follow these steps to configure the app on your machine!

1. Clone Git Repo

git clone https://github.com/jivaniyash/langchain-chat-assistant.git
cd ./langchain-chat-assistant
Enter fullscreen mode Exit fullscreen mode

2. Create & Activate Virtual Env

sudo apt install python3.11-venv
python3 -m venv .venv
source ./.venv/bin/activate
python3 -m pip install --upgrade pip
Enter fullscreen mode Exit fullscreen mode

3. Install Packages

pip install chainlit langchain_openai langchain
Enter fullscreen mode Exit fullscreen mode

4. Run the script

chainlit run ./app/main_openai.py -w
Enter fullscreen mode Exit fullscreen mode

-w flag to enable auto-reloading

This will open a web browser automatically. If not, please copy this link - localhost:8000 into the web browser.


Customize

  • Now, you can customize your app to specific use cases by changing System Prompt from ./utils/systemPrompt.md.

  • Add New Functions to tailor your use-cases from ./utils/functions.py. Also, if you need to connect using local database, csv, or Excel or any other data files; add those files under ./assests/ directory. fetchFromLocalDB function explains how to configure adding new data sources.

Run Local LLM using OLLAMA APIs

If you want to run your assistant using local LLM running in OLLAMA, please follow these steps.

And there you have it! You can now build and run your own AI assistant using OpenAI or OLLAMA. Enjoy exploring the possibilities!

Please look at my GitHub Repo to get a glance over the files.

. . . .
Terabox Video Player