Chat GTP Telegram


Update: 4/5/20204

Un año después, es posible que una instancia de ChatGPT ya no sea tan atractiva como parecía antes. En este momento, optaría por Mistral o Llama 7B, alojados localmente o en algún servicio en la nube como AWS, Google Cloud, entre otros.


He creado un bot para utilizar ChatGPT en Telegram, y lo he alojado en AWS.

-> Repositorio

ChatGPT Telegram Bot with AWS Lambda

ChatGPT on Telegram by utilizing the services of AWS Lambda, S3, and API Gateway.

Features

  • API support
  • Memory

Initial Setup

  1. Create an OpenAI account and get an API Key.
  2. Create an AWS account.
  3. Setup your Telegram bot. You can follow this instructions to get your token.
  4. Create your Lambda service, choose Python 3.9
  5. Create a env and install requirements.txt
  6. put all content of lib/site-packages in a zip file with lambda_funtion.py
  7. Create a S3 bucket
  8. Create a Create a REST API and deploy
  9. Connect Telegram to your API Gateway
    $ curl --data "url=<INVOKE_URL>" "https://api.telegram.org/bot<ACCESS_TOKEN>/setWebhook"
    
    • Replace <ACCESS_TOKEN> with your Telegram HTTP API access token obtained in the first step
    • Replace <INVOKE_URL> with your endpoint You should get back a response similar to this:
    $ {"ok":true,"result":true,"description":"Webhook was set"}
    
  10. setup the environment variables:
    • BUCKET_TOKEN: bucket name
    • OPENIA_KEY: OpenAI key
    • PERSINALITY: the system message for the AI
    • TELEGRAM_TOKEN: Telegram bot token
    • USER_ID: your telegram user ID
  11. upload the zip file to your Lambda service

I skipped a thousand steps, you have to give permissions to lambda to be able to write files and some other things that I missed :sweat:. soon I will add what is missing

refs