利用 OpenAI GPT-3 寫一個 Telegram 聊天機器人 (Cloudflare Tunnel & GCP AppEngine)

最近 ChatGPT 很紅,想說可以試著把 OpenAI 的 API 給接上 Telegram 的群組來玩玩看,順便記錄一下 GCP 的 AppEngine Deploy 方法! 程式碼我放在:https://github.com/stevenyu113228/OpenAI-GPT-3-Telegram-Chatbot 效果 OpenAI 先到 https://beta.openai.com/account/api-keys 申請一組 API Token 在 Playground 上面隨意玩一下,複製他的 Example 來微調 import os import openai openai.api_key = os.getenv("OPENAI_API_KEY") start_sequence = "\nA:" restart_sequence = "\n\nQ: " response = openai.Completion.create( model="text-davinci-003", prompt="Q: ", temperature=0, max_tokens=100, top_p=1, frequency_penalty=0, presence_penalty=0, stop=["\n"] ) Telegram API 接下來到 Telegram 的 BotFather 來新增 Bot ...

2022-12-04 · 2 分鐘 · steven

Using boto3 to control the AWS EC2

Install awscli and boto3 sudo apt install awscli pip3 install boto3 Add a new AWS user Go to https://console.aws.amazon.com/iam/home Add User, pick a username, and set the AWS credential type to Access key In the “Set permissions” section, select the “Attach existing policies directly” and check the AmazonEC2FullAccess And it will receive an Access Key ID and a Secret Access key Configure the aws-cli Run the command aws configure Input the AWS Access Key ID and AWS Secret Access key, other leave blanks. ...

2022-03-23 · 1 分鐘 · steven