mirror of
https://github.com/matrixgpt/matrix-chatgpt-bot.git
synced 2024-09-30 13:05:50 +00:00
add new env for model, add warning about new version
This commit is contained in:
parent
2d7d482fca
commit
af954b7632
@ -4,8 +4,9 @@ OPENAI_API_KEY=
|
|||||||
|
|
||||||
# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
|
# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
|
||||||
CHATGPT_CONTEXT=thread
|
CHATGPT_CONTEXT=thread
|
||||||
# (Optional) Explicitly set the ChatGPT model to be used by the API.
|
# Set the ChatGPT model to be used by the API. 'gpt-3.5-turbo' is the official ChatGPT-model from OpenAI
|
||||||
#CHATGPT_API_MODEL=gpt-3.5-turbo
|
# 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
|
# (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.
|
#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
|
# (Optional) Set to true if ChatGPT should ignore any messages which are not text
|
||||||
|
@ -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"},
|
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_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_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_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"},
|
CHATGPT_IGNORE_MEDIA: { schema: z.boolean().default(false), description: "Wether or not the bot should react to non-text messages"},
|
||||||
});
|
});
|
||||||
|
@ -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")
|
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);
|
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
|
const clientOptions = { // (Optional) Parameters as described in https://platform.openai.com/docs/api-reference/completions
|
||||||
modelOptions: {
|
modelOptions: {
|
||||||
model: CHATGPT_API_MODEL, // The model is set to gpt-3.5-turbo by default
|
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),
|
promptPrefix: wrapPrompt(CHATGPT_PROMPT_PREFIX),
|
||||||
debug: false,
|
debug: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chatgpt = new ChatGPTClient(OPENAI_API_KEY, clientOptions, cacheOptions);
|
const chatgpt = new ChatGPTClient(OPENAI_API_KEY, clientOptions, cacheOptions);
|
||||||
|
|
||||||
// Automatically join rooms the bot is invited to
|
// Automatically join rooms the bot is invited to
|
||||||
|
Loading…
Reference in New Issue
Block a user