From df2bfe2d9d9c979145e28fb80418908d0a029dd1 Mon Sep 17 00:00:00 2001 From: Zdravko Bozakov Date: Thu, 1 Feb 2024 15:43:57 +0100 Subject: [PATCH] add option to pass API basepath --- README.md | 1 + src/openai-wrapper.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 586f41e..c1ce3e8 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ or when [running the docker image](#using-the-ready-made-docker-image) or when c | MATTERMOST_URL | yes | `https://mattermost.server` | The URL to the server. This is used for connecting the bot to the Mattermost API | | MATTERMOST_TOKEN | yes | `abababacdcdcd` | The authentication token from the logged in mattermost bot | | OPENAI_API_KEY | yes | `sk-234234234234234234` | The OpenAI API key to authenticate with OpenAI | +| OPENAI_API_BASE | no | `http://example.com:8080/v1` | The address of an OpenAI compatible API. Overrides the default base path (`https://api.openai.com`) | | OPENAI_MODEL_NAME | no | `gpt-3.5-turbo` | The OpenAI language model to use, defaults to `gpt-3.5-turbo` | | OPENAI_MAX_TOKENS | no | `2000` | The maximum number of tokens to pass to the OpenAI API, defaults to 2000 | | OPENAI_TEMPERATURE | no | `0.2` | The sampling temperature to use, between 0 and 2, defaults to 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. | diff --git a/src/openai-wrapper.ts b/src/openai-wrapper.ts index e40e916..f2d47cb 100644 --- a/src/openai-wrapper.ts +++ b/src/openai-wrapper.ts @@ -11,9 +11,10 @@ import {PluginBase} from "./plugins/PluginBase"; import {AiResponse, MessageData} from "./types"; const apiKey = process.env['OPENAI_API_KEY']; -log.trace({apiKey}) +const basePath = process.env['OPENAI_API_BASE']; +log.trace({apiKey, basePath}) -const configuration = new Configuration({ apiKey }) +const configuration = new Configuration({ apiKey, basePath }) const openai = new OpenAIApi(configuration)