This repository contains a Python-based FastAPI application that integrates OpenAI's ChatGPT with the LINE Messaging API.
The application uses the OpenAI API to generate responses to user messages sent via LINE. The integration is done using FastAPI and the LINE Messaging API.
To run this application, you will need:
- Python 3.6 or later
- An OpenAI account with API key
- LINE Messaging API Channel with a Channel Secret and Channel Access Token
- Clone this repository:
git clone https://github.com/your-repository.git
- Navigate to the project directory:
cd your-repository
- Install the required packages:
pip install -r requirements.txt
Create a .env
file in the project root directory with the following variables:
OPENAI_API_KEY=your_openai_api_key
ChannelSecret=your_line_channel_secret
ChannelAccessToken=your_line_channel_access_token
Replace your_openai_api_key
, your_line_channel_secret
, and your_line_channel_access_token
with your actual OpenAI API key, LINE Channel Secret, and LINE Channel Access Token respectively.
Run the FastAPI application:
uvicorn main:app --reload
The application will start on http://localhost:8000/
.
- POST
/callback
: Handles incoming requests from the LINE Messaging API.
You can choose Heroku or Render
- Input
Channel Secret
andChannel Access Token
. - Input OpenAI API Key in
OPENAI_API_KEY
. - Remember your heroku, ID
This project is licensed under the Apache License, Version 2.0. For more information, see the LICENSE file.