/LineGPT

A fastapi implementation of Linebot + GPT-3

Primary LanguagePythonMIT LicenseMIT

LineGPT

中文 | English

A linebot with assistance of ChatGPT.

Usage

The functions of LineGPT are defined by several commands. You can use help to list available commands.

@LineGPT help

help

ChatGPT

Let ChatGPT help you.

@LineGPT gpt help

gpt help

Weather (Currently only support weather in Taiwan)

Check the weather in your place.

@LineGPT weather help

weather help weather use

Settle

Need to know how much you should pay? Let LineGPT settle a groups' expense!

@LineGPT settle help

settle help

Developer's guide

Environment variable

Settings are listed in a .env file. Here offering a template '.env.template' for user to setup your personal setting for this bot.

Item Necessity Default value Note
LANGUAGE NO zh_TW Default is Traditional Chinese.
LINE_CHANNEL_SECRET YES "" Channel secret of LINE. You can check this link for more information
LINE_CHANNEL_ACCESS_TOKEN YES "" Channel access token of LINE. You can check this link for more information
SESSION_EXPIRE NO 600 To save the memory, you can not talk to ChatGPT after <SESSION_EXPIRE> time since last update.
WEATHER_TOKEN NO "" You can set your own token or simply use mine. If you want to use your own token. Please refer the official website to see how to get a token.

Note: After you fill in these variable, please rename the .env.template to .env.

Testing

  1. Start the server
uvicorn api.index:app --reload --loop asyncio

api page will be http://127.0.0.1:8000/docs

  1. Open ngrok
ngrok http 8000

ngrok

  1. Copy the https url to line bot webhook url. The result will be /webhook webhook

  2. Check verify button to see if the url works.

  3. You can send message to your bot.

Deploy

  1. Vercel Fork this project to your github to use vercel. You can import the .env file in Settings > Environment Variables.

  2. Container You can also deploy your bot by docker. Note that Linebot only take https url, so you may need to verify your domain first.

Issues, questions and PRs

Bug reports, issues, and PRs are always welcome. If you face any questions, welcome to discuss page to discuss.