DEV Community

Cover image for Langchain Chat Assistant using Chainlit App
Yash Jivani
Yash Jivani

Posted on

4

Langchain Chat Assistant using Chainlit App

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay