feat(openai): add Azure OpenAI support with configuration options

This commit is contained in:
Gianluigi Conti
2025-09-09 10:14:34 +02:00
parent b995a6b6c0
commit 098d67cd8c
4 changed files with 143 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import { DEFAULT_MAX_TOKENS, DEFAULT_MODEL } from "../constants/llm";
import { DEFAULT_MAX_TOKENS, DEFAULT_MODEL, DEFAULT_AZURE_API_VERSION } from "../constants/llm";
type OpenAIStore = {
baseURL: string | null;
@ -12,6 +12,10 @@ type OpenAIStore = {
setModel: (model: string | null) => void;
maxTokens: number | null;
setMaxTokens: (maxTokens: number | null) => void;
isAzure: boolean;
setIsAzure: (isAzure: boolean) => void;
azureApiVersion: string | null;
setAzureApiVersion: (apiVersion: string | null) => void;
};
export const useOpenAiStore = create<OpenAIStore>()(
@ -33,6 +37,14 @@ export const useOpenAiStore = create<OpenAIStore>()(
setMaxTokens: (maxTokens: number | null) => {
set({ maxTokens });
},
isAzure: false,
setIsAzure: (isAzure: boolean) => {
set({ isAzure });
},
azureApiVersion: DEFAULT_AZURE_API_VERSION,
setAzureApiVersion: (azureApiVersion: string | null) => {
set({ azureApiVersion });
},
}),
{ name: "openai" },
),