Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a cookbook for ChatGPT Bot #961

Merged
merged 3 commits into from
Mar 29, 2023
Merged

Conversation

LokiWager
Copy link
Collaborator

Add a cookbook for ChatGPT Bot

Since the bot needs to receive Telegram message notifications and call third-party APIs, we must prepare the following in advance:

* Install the latest version of Easegress according to [this document](https://github.com/megaease/easegress#setting-up-easegress) and make sure that external applications can access the Easegress instance on at least one of ports 80, 88, 443, or 8443.
* Create a Telegram bot by following [this document](https://core.telegram.org/bots#3-how-do-i-create-a-bot), set its name (EaseTranslateBot is used in this article), write down its token, and [set up a Webhook](https://core.telegram.org/bots/api#setwebhook) that points to the Easegress instance installed in the previous step. Our bot will receive notifications of new messages through this Webhook.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bot is not for translation, so better use another name instead of EaseTranslateBot.


## 1. Prerequisites

Since the bot needs to receive Telegram message notifications and call third-party APIs, we must prepare the following in advance:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Since the bot needs to receive Telegram message notifications and call third-party APIs, we must prepare the following in advance:
Since the bot needs to receive Telegram message notifications and call ChatGPT APIs, we must prepare the following in advance:


Before reading this article, please read the [Multiple API Orchestration](./translation-bot.md) article to ensure understanding of Easegress API orchestration and Telegram robot.

In this article, we will introduce how to build a Telegram ChatGPT robot with Easegress. This robot can generate a response based on the user's input.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both bot and robot are used in this article, per telegram, we should only use bot.

@@ -0,0 +1,190 @@
# Build A Telegram ChatGPT Bot With Easegress

Before reading this article, please read the [Multiple API Orchestration](./translation-bot.md) article to ensure understanding of Easegress API orchestration and Telegram robot.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Before reading this article, please read the [Multiple API Orchestration](./translation-bot.md) article to ensure understanding of Easegress API orchestration and Telegram robot.
Before reading this article, please read the [Multiple API Orchestration](./translation-bot.md) article to ensure an understanding of Easegress API orchestration and Telegram robot.


## 3. Pipeline

First, let's check the overall flow that Pipeline orchestrates:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
First, let's check the overall flow that Pipeline orchestrates:
First, let's check the overall flow of the Pipeline:


### 4.1 Backend Proxies

We need to create two proxies to send requests to the ChatGPT API and Telegram API. The configuration of the two proxies is as follows:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We need to create two proxies to send requests to the ChatGPT API and Telegram API. The configuration of the two proxies is as follows:
We need to create two proxies to send requests to the ChatGPT API server and the Telegram API server. The configuration of the two proxies is as follows:


### 4.2 Check and Extract Text

The processing details is consistent with that in [Multiple API Orchestration](./translation-bot.md) and will not be described again.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The processing details is consistent with that in [Multiple API Orchestration](./translation-bot.md) and will not be described again.
The processing details are the same as that in [Multiple API Orchestration](./translation-bot.md).


### 4.3 Send Request to ChatGPT

Build a request to send to the ChatGPT API. See more details in [OpenAI API](https://platform.openai.com/docs/guides/chate). Make sure to replace the `{Your OpenAI API Key}` with your own API key.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Build a request to send to the ChatGPT API. See more details in [OpenAI API](https://platform.openai.com/docs/guides/chate). Make sure to replace the `{Your OpenAI API Key}` with your own API key.
Build a request to send to ChatGPT. See more details in [OpenAI API](https://platform.openai.com/docs/guides/chate). Make sure to replace the `{Your OpenAI API Key}` with your own API key.


### 4.3 Send Request to ChatGPT

Build a request to send to ChatGPT. See more details in [OpenAI API](https://platform.openai.com/docs/guides/chate). Make sure to replace the `{Your OpenAI API Key}` with your own API key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Build a request to send to ChatGPT. See more details in [OpenAI API](https://platform.openai.com/docs/guides/chate). Make sure to replace the `{Your OpenAI API Key}` with your own API key.
Build a request to send to ChatGPT. See more details in [OpenAI API](https://platform.openai.com/docs/guides/chat). Make sure to replace the `{Your OpenAI API Key}` with your own API key.

@LokiWager LokiWager added this pull request to the merge queue Mar 29, 2023
Merged via the queue into easegress-io:main with commit 2b11f7a Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants