mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-09 03:35:07 +08:00
support azure deployment name
This commit is contained in:
@@ -30,6 +30,7 @@ export interface RequestMessage {
|
||||
|
||||
export interface LLMConfig {
|
||||
model: string;
|
||||
providerName?: string;
|
||||
temperature?: number;
|
||||
top_p?: number;
|
||||
stream?: boolean;
|
||||
@@ -54,6 +55,7 @@ export interface LLMUsage {
|
||||
|
||||
export interface LLMModel {
|
||||
name: string;
|
||||
displayName?: string;
|
||||
available: boolean;
|
||||
provider: LLMModelProvider;
|
||||
}
|
||||
@@ -160,10 +162,14 @@ export function getHeaders() {
|
||||
Accept: "application/json",
|
||||
};
|
||||
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
|
||||
const isGoogle = modelConfig.model.startsWith("gemini");
|
||||
const isAzure = accessStore.provider === ServiceProvider.Azure;
|
||||
const isAnthropic = accessStore.provider === ServiceProvider.Anthropic;
|
||||
const authHeader = isAzure ? "api-key" : isAnthropic ? 'x-api-key' : "Authorization";
|
||||
const isGoogle = modelConfig.providerName == ServiceProvider.Azure;
|
||||
const isAzure = modelConfig.providerName === ServiceProvider.Azure;
|
||||
const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic;
|
||||
const authHeader = isAzure
|
||||
? "api-key"
|
||||
: isAnthropic
|
||||
? "x-api-key"
|
||||
: "Authorization";
|
||||
const apiKey = isGoogle
|
||||
? accessStore.googleApiKey
|
||||
: isAzure
|
||||
@@ -172,7 +178,8 @@ export function getHeaders() {
|
||||
? accessStore.anthropicApiKey
|
||||
: accessStore.openaiApiKey;
|
||||
const clientConfig = getClientConfig();
|
||||
const makeBearer = (s: string) => `${isAzure || isAnthropic ? "" : "Bearer "}${s.trim()}`;
|
||||
const makeBearer = (s: string) =>
|
||||
`${isAzure || isAnthropic ? "" : "Bearer "}${s.trim()}`;
|
||||
const validString = (x: string) => x && x.length > 0;
|
||||
|
||||
// when using google api in app, not set auth header
|
||||
@@ -185,7 +192,7 @@ export function getHeaders() {
|
||||
validString(accessStore.accessCode)
|
||||
) {
|
||||
// access_code must send with header named `Authorization`, will using in auth middleware.
|
||||
headers['Authorization'] = makeBearer(
|
||||
headers["Authorization"] = makeBearer(
|
||||
ACCESS_CODE_PREFIX + accessStore.accessCode,
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user