修改: app/api/[provider]/[...path]/route.ts

修改:     app/api/auth.ts
	新文件:   app/api/bedrock.ts
	新文件:   app/api/bedrock/models.ts
	新文件:   app/api/bedrock/utils.ts
	修改:     app/client/api.ts
	新文件:   app/client/platforms/bedrock.ts
	修改:     app/components/settings.tsx
	修改:     app/config/server.ts
	修改:     app/constant.ts
	修改:     app/locales/cn.ts
	修改:     app/locales/en.ts
	修改:     app/store/access.ts
	修改:     app/utils.ts
	修改:     package.json
This commit is contained in:
glay
2024-10-29 22:20:26 +08:00
parent 613d67eada
commit ff356f0c8c
15 changed files with 1261 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ import {
StoreKey,
ApiPath,
OPENAI_BASE_URL,
BEDROCK_BASE_URL,
ANTHROPIC_BASE_URL,
GEMINI_BASE_URL,
BAIDU_BASE_URL,
@@ -26,6 +27,7 @@ let fetchState = 0; // 0 not fetch, 1 fetching, 2 done
const isApp = getClientConfig()?.buildMode === "export";
const DEFAULT_OPENAI_URL = isApp ? OPENAI_BASE_URL : ApiPath.OpenAI;
const DEFAULT_BEDROCK_URL = isApp ? BEDROCK_BASE_URL : ApiPath.Bedrock;
const DEFAULT_GOOGLE_URL = isApp ? GEMINI_BASE_URL : ApiPath.Google;
@@ -57,6 +59,16 @@ const DEFAULT_ACCESS_STATE = {
openaiUrl: DEFAULT_OPENAI_URL,
openaiApiKey: "",
// bedrock
bedrockUrl: DEFAULT_BEDROCK_URL,
bedrockApiKey: "",
awsRegion: "",
awsAccessKeyId: "",
awsSecretAccessKey: "",
awsSessionToken: "",
awsCognitoUser: false,
awsInferenceProfile: "", // Added inference profile field
// azure
azureUrl: "",
azureApiKey: "",
@@ -141,6 +153,14 @@ export const useAccessStore = createPersistStore(
return ensure(get(), ["openaiApiKey"]);
},
isValidBedrock() {
return ensure(get(), [
"awsAccessKeyId",
"awsSecretAccessKey",
"awsRegion",
]);
},
isValidAzure() {
return ensure(get(), ["azureUrl", "azureApiKey", "azureApiVersion"]);
},
@@ -186,6 +206,7 @@ export const useAccessStore = createPersistStore(
// has token or has code or disabled access control
return (
this.isValidOpenAI() ||
this.isValidBedrock() ||
this.isValidAzure() ||
this.isValidGoogle() ||
this.isValidAnthropic() ||