Giter Site home page Giter Site logo

gpt-on-line's Introduction

GPT on LINE

System

Using Chalice and AWS CDK, we will build a REST API that will serve as a webhook for LINE bot. We use AWS API Gate way, Lambda, and Dynamo DB.

Credentials

Before you can deploy an application, be sure you have credentials configured. Create an AWS IAM user named "chalice"γ€€and attouch admin (or appropriate) role. You can follow these steps to configure aws credentials:

$ mkdir ~/.aws
$ cat >> ~/.aws/config
[chalice]
aws_access_key_id=YOUR_ACCESS_KEY_HERE
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
region=YOUR_REGION (such as us-west-2, us-west-1, etc)
output=json

Install

Install Python3.9 and Node.js in advance. Install AWS-CDK, chalice.

npm install -g aws-cdk
pip install "chalice[cdkv2]"

Clone this repository. We will call the root directory of this repository $ROOT_DIRECTORY。

git clone https://github.com/ground0state/GPT-on-LINE.git

Install libraries.

cd $ROOT_DIRECTORY
pip install -r requirements.txt

Environment variables

Create your OpenAI API Key. Please also set up payment methods for Billing. Create your new Messaging API channel.

Copy config file and edit to set your openAI API Key and LINE token.

cd runtime/.chalice
cp config_sample.json config.json
vi config.json

Deploy

Deploy with the following command.

cd infrastructure
cdk bootstrap --profile chalice
cdk deploy --profile chalice

If you are using a virtual environment and receive the following error, deactivate the virtual environment and re-activate it.

Traceback (most recent call last):
  File "/Users/masafumi/work/chatgpt_aws_line/infrastructure/app.py", line 3, in <module>
    from aws_cdk import core as cdk
ModuleNotFoundError: No module named 'aws_cdk'

After deployment is complete, the API Gateway URL will be displayed. Copy this and set it to the webhook URL of LINE Bot as https://YOUR_ADDRESS/callback.

Usage

Chat with bot from your line app. "EXIT" command is special command to reset chat histories. When you want to instruct, edit SYSTEM_PROMPTS in runtime/chalicelib/chatgpt_api.py.

Undeploy

Uneploy with the following command. Delete your LINE channel.

cdk destroy --profile chalice

Rederences

gpt-on-line's People

Contributors

ground0state avatar

Watchers

 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.