Skip to content

Commit

Permalink
fix get headers for bytedance
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Jul 9, 2024
1 parent 82be426 commit bb349a0
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions app/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,27 @@ export function getHeaders() {
const isGoogle = modelConfig.providerName == ServiceProvider.Google;
const isAzure = modelConfig.providerName === ServiceProvider.Azure;
const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic;
const isBaidu = modelConfig.providerName == ServiceProvider.Baidu;
const isByteDance = modelConfig.providerName === ServiceProvider.ByteDance;
const isEnabledAccessControl = accessStore.enabledAccessControl();
const apiKey = isGoogle
? accessStore.googleApiKey
: isAzure
? accessStore.azureApiKey
: isAnthropic
? accessStore.anthropicApiKey
: isByteDance
? accessStore.bytedanceApiKey
: accessStore.openaiApiKey;
return { isGoogle, isAzure, isAnthropic, apiKey, isEnabledAccessControl };
return {
isGoogle,
isAzure,
isAnthropic,
isBaidu,
isByteDance,
apiKey,
isEnabledAccessControl,
};
}

function getAuthHeader(): string {
Expand All @@ -203,10 +215,18 @@ export function getHeaders() {
function validString(x: string): boolean {
return x?.length > 0;
}
const { isGoogle, isAzure, isAnthropic, apiKey, isEnabledAccessControl } =
getConfig();
const {
isGoogle,
isAzure,
isAnthropic,
isBaidu,
apiKey,
isEnabledAccessControl,
} = getConfig();
// when using google api in app, not set auth header
if (isGoogle && clientConfig?.isApp) return headers;
// when using baidu api in app, not set auth header
if (isBaidu && clientConfig?.isApp) return headers;

const authHeader = getAuthHeader();

Expand Down

0 comments on commit bb349a0

Please sign in to comment.