Giter VIP home page Giter VIP logo

langchain-chatbot's Introduction

Chatbot with Langchain, LangSmith.

Requirement

  • Python version >= 3.9. Because langchainhub package require it

Description

  • This is a chatbot implementation with Langchain framework.
    • Base LLM: Vertex AI or OpenAI API
    • Memory: MongoDB
    • UI:
      • Gradio
      • Langchain UI: Chat Langchain
        • Use it to leverages LangChain's streaming support.
    • Prompt versioning and tracing: LangSmith
  • User can custom bot's personality by setting bot information like gender, age, ...
  • Demo UI: Demo UI

PII for chatbot

  • Data anonymization with Microsoft Presidio
  • To protect personally identifiable information (PII), we add PresidioAnonymizer to my bot to replace PIIs before pass to LLM api. View code in Anonymizer
  • Steps when using it:
    • User message after anonymize:

      anonymized message

    • Anonymized prompt before input to LLM:

      anonymized_prompt

    • De-anonymized response to user after LLM call:

      de-anonymized_output.png

How to use

  • You need Google Cloud credentials to call Vertex API or OPENAI API KEY to call OpenAI API
  • You need create MongoDB database and collection to use as Langchain memory

Setup tracing with Langsmith

  • Langsmith docs: LangSmith
  • Configure environment to connect to LangSmith.
    export LANGCHAIN_TRACING_V2=true
    export LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
    export LANGCHAIN_API_KEY="<your-api-key>"
    export LANGCHAIN_PROJECT="chatbot-with-langchain"
    

Running

  1. Download the models for the languages to use in anonymizer. PII support.
    1. python -m spacy download en_core_web_md
  2. RUN backend
    1. Clone repo: git clone https://github.com/btrcm00/chatbot-with-langchain.git
    2. Add google-cloud-platform credential file to secure/vertexai.json
    3. cd chatbot
    4. Install required packages: pip install -r requirements.txt
    5. Create MongoDB database and config environment variables to connect Mongo.
    6. Run: python app.py
  3. RUN frontend
    1. cd chatbot_frontend
    2. Install packages: npm i
    3. Start frontend: npm start dev

langchain-chatbot's People

Contributors

spartan-minhbui avatar spartan-hieunguyen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.