add new env for model, add warning about new version

This commit is contained in:
Max Kammler 2023-03-03 12:56:52 +01:00
parent 2d7d482fca
commit af954b7632
3 changed files with 12 additions and 3 deletions

View File

@ -4,8 +4,9 @@ OPENAI_API_KEY=
# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
CHATGPT_CONTEXT=thread
# (Optional) Explicitly set the ChatGPT model to be used by the API.
#CHATGPT_API_MODEL=gpt-3.5-turbo
# Set the ChatGPT model to be used by the API. 'gpt-3.5-turbo' is the official ChatGPT-model from OpenAI
# Note that the models are not free and will charge your OpenAI account depending on the usage of tokens
CHATGPT_API_MODEL=gpt-3.5-turbo
# (Optional) Explicitly set the prefix sent to model at the beginning of a conversation
#CHATGPT_PROMPT_PREFIX=Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.
# (Optional) Set to true if ChatGPT should ignore any messages which are not text

View File

@ -64,7 +64,7 @@ export const {
OPENAI_API_KEY: { schema: z.string().default(""), description: "Set to the API key from https://platform.openai.com/account/api-keys"},
CHATGPT_TIMEOUT: { schema: z.number().default(2 * 60 * 1000), description: "Set number of milliseconds to wait for ChatGPT responses" },
CHATGPT_CONTEXT: { schema: z.enum(["thread", "room", "both"]).default("thread"), description: "Set the ChatGPT conversation context to 'thread', 'room' or 'both'" },
CHATGPT_API_MODEL: { schema: z.string().default("gpt-3.5-turbo"), description: "The model for the ChatGPT-API to use. Keep in mind that these models will charge your OpenAI account depending on their pricing." },
CHATGPT_API_MODEL: { schema: z.string().default(""), description: "The model for the ChatGPT-API to use. Keep in mind that these models will charge your OpenAI account depending on their pricing." },
CHATGPT_PROMPT_PREFIX: { schema: z.string().default('Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.'), description: "Instructions to feed to ChatGPT on startup"},
CHATGPT_IGNORE_MEDIA: { schema: z.boolean().default(false), description: "Wether or not the bot should react to non-text messages"},
});

View File

@ -45,6 +45,13 @@ async function main() {
if (!MATRIX_THREADS && CHATGPT_CONTEXT !== "room") throw Error("You must set CHATGPT_CONTEXT to 'room' if you set MATRIX_THREADS to false")
const client: MatrixClient = new MatrixClient(MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, storage, cryptoStore);
if (!CHATGPT_API_MODEL) {
LogService.warn("index", "This bot now uses the official API from ChatGPT. In order to migrate add the CHATGPT_API_MODEL variable to your .env");
LogService.warn("index", "The official ChatGPT-model which should be used is 'gpt-3.5-turbo'. See the .env.example for details")
LogService.warn("index", "Please note that the usage of the models charge your OpenAI account and are not free to use");
return;
}
const clientOptions = { // (Optional) Parameters as described in https://platform.openai.com/docs/api-reference/completions
modelOptions: {
model: CHATGPT_API_MODEL, // The model is set to gpt-3.5-turbo by default
@ -52,6 +59,7 @@ async function main() {
promptPrefix: wrapPrompt(CHATGPT_PROMPT_PREFIX),
debug: false,
};
const chatgpt = new ChatGPTClient(OPENAI_API_KEY, clientOptions, cacheOptions);
// Automatically join rooms the bot is invited to