Add Version to AzureOpenAI (#3023)

This commit is contained in:
Timothy Carambat 2025-01-24 13:41:37 -08:00 committed by GitHub
parent 48dcb22b25
commit 2ca22abc9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,9 +16,13 @@ class AzureOpenAiLLM {
if (!process.env.AZURE_OPENAI_KEY)
throw new Error("No Azure API key was set.");
this.apiVersion = "2024-12-01-preview";
this.openai = new OpenAIClient(
process.env.AZURE_OPENAI_ENDPOINT,
new AzureKeyCredential(process.env.AZURE_OPENAI_KEY)
new AzureKeyCredential(process.env.AZURE_OPENAI_KEY),
{
apiVersion: this.apiVersion,
}
);
this.model = modelPreference ?? process.env.OPEN_MODEL_PREF;
this.limits = {
@ -29,6 +33,13 @@ class AzureOpenAiLLM {
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;
this.#log(
`Initialized. Model "${this.model}" @ ${this.promptWindowLimit()} tokens. API-Version: ${this.apiVersion}`
);
}
#log(text, ...args) {
console.log(`\x1b[32m[AzureOpenAi]\x1b[0m ${text}`, ...args);
}
#appendContext(contextTexts = []) {