mortium91 / langchain-assistant

Interact with LLM's (GPT-3, GPT-3.5, GPT-4) via messenger apps like Telegram, Whatsapp and Facebook Messenger
https://abracadata.io
MIT License
155 stars 33 forks source link

LangChain Assistant

"Build your own ChatGPT on Telegram, WhatsApp and Facebook Messenger!"

LangChain Assistant is a versatile chatbot that leverages state-of-the-art Language Models (currently GPT-3, GPT-3.5-Turbo and GPT-4) to interact with users via Telegram, WhatsApp and Facebook Messenger. The primary goal is to keep AI development open, fun, and accessible. LangChain Assistant can handle text messages, voice messages, put stuff in your calendar and even generate images using OpenAI's DALL-E.

Features

Roadmap

Get Images from DALL-E

To generate images using OpenAI's DALL-E, include the text '/image' in your chat message. The default image size is "256x256" and can be modified in the config.py file.

Deployment

Try for Free

To deploy LangChain Assistant for free on Replit:

Prerequisites

Installation

  1. Clone the repository and navigate to the project directory.

  2. Install the required Python packages:

pip install -r requirements.txt

  1. Create a .env file in the project directory and add the following variables:
    TELEGRAM_BOT_TOKEN=
    OPENAI_API_KEY=
    TEMPERATURE_VALUE=
    ACCOUNT_SID= #Twilio
    AUTH_TOKEN= #Twilio
    TWILIO_WHATSAPP_NUMBER = #Twilio sandbox / business number
    FACEBOOK_PAGE_ID = #

Setup Telegram

  1. Run the FastAPI server:
    uvicorn main:app --reload --port 8000

(when running locally on Windows)

  1. Expose the local server using NGROK:

    ngrok http 8000
  2. Set up the webhook for your Telegram bot:

https://api.telegram.org/bot{YOUR_TOKEN}/setWebhook?url={YOUR_WEBHOOK_ENDPOINT}

Setup WhatsApp

  1. Activate the Twilio Sandbox for WhatsApp and obtain the Account SID and Auth Token.

  2. Add the Twilio WhatsApp phone number to your contacts and send a message to join the sandbox.

  3. Update the webhook URL in the Twilio Sandbox settings with your FastAPI server URL.

Setup Facebook Messenger

For more details, follow the Twilio tutorial: Send and Receive Media Messages with WhatsApp in Python

Facebook Messenger

How to set Google Calendar Event