Add support for Azure OpenAI (#186)

Co-authored-by: 無名氏 <hello@edgerunners.eu.org>
This commit is contained in:
sg-qwt 2023-06-08 23:02:44 +08:00 committed by GitHub
parent cc8c64bf22
commit d0d6c5d0b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,8 @@
# ChatGPT Settings (required)
# Set the API Key from OpenAI
OPENAI_API_KEY=
# To use Azure OpenAI API, set `OPENAI_AZURE` to true and `CHATGPT_REVERSE_PROXY` to your completion endpoint
# OPENAI_AZURE=false
# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
CHATGPT_CONTEXT=thread

View File

@ -29,6 +29,7 @@ export const {
MATRIX_DEFAULT_PREFIX,
MATRIX_DEFAULT_PREFIX_REPLY,
/** ChatGPT Settings */
OPENAI_AZURE,
OPENAI_API_KEY,
CHATGPT_CONTEXT,
CHATGPT_TIMEOUT,
@ -63,6 +64,7 @@ export const {
MATRIX_DEFAULT_PREFIX: { schema: z.string().default(""), description: "Set to a string if you want the bot to respond only when messages start with this prefix. Trailing space matters. Empty for no prefix." },
MATRIX_DEFAULT_PREFIX_REPLY: { schema: z.boolean().default(false), description: "Set to false if you want the bot to answer to all messages in a thread/conversation" },
/** ChatGPT Settings */
OPENAI_AZURE: { schema: z.boolean().default(false), description: "Wether or not to use Azure OPENAI"},
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'" },

View File

@ -8,7 +8,7 @@ import {
import * as path from "path";
import {
DATA_PATH, KEYV_URL, OPENAI_API_KEY, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN,
DATA_PATH, KEYV_URL, OPENAI_AZURE, OPENAI_API_KEY, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN,
MATRIX_BOT_PASSWORD, MATRIX_BOT_USERNAME, MATRIX_ENCRYPTION, MATRIX_THREADS, CHATGPT_CONTEXT,
CHATGPT_API_MODEL, KEYV_BOT_STORAGE, KEYV_BACKEND, CHATGPT_PROMPT_PREFIX, MATRIX_WELCOME,
CHATGPT_REVERSE_PROXY, CHATGPT_TEMPERATURE
@ -64,6 +64,7 @@ async function main() {
},
promptPrefix: wrapPrompt(CHATGPT_PROMPT_PREFIX),
debug: false,
azure: OPENAI_AZURE,
reverseProxyUrl: CHATGPT_REVERSE_PROXY,
};