mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-12 04:53:44 +08:00
feat: Add service provider OpenRouter
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
XAI_BASE_URL,
|
||||
CHATGLM_BASE_URL,
|
||||
SILICONFLOW_BASE_URL,
|
||||
OPENROUTER_BASE_URL,
|
||||
} from "../constant";
|
||||
import { getHeaders } from "../client/api";
|
||||
import { getClientConfig } from "../config/client";
|
||||
@@ -59,6 +60,8 @@ const DEFAULT_SILICONFLOW_URL = isApp
|
||||
? SILICONFLOW_BASE_URL
|
||||
: ApiPath.SiliconFlow;
|
||||
|
||||
const DEFAULT_OPENROUTER_URL = isApp ? OPENROUTER_BASE_URL : ApiPath.OpenRouter;
|
||||
|
||||
const DEFAULT_ACCESS_STATE = {
|
||||
accessCode: "",
|
||||
useCustomConfig: false,
|
||||
@@ -132,6 +135,10 @@ const DEFAULT_ACCESS_STATE = {
|
||||
siliconflowUrl: DEFAULT_SILICONFLOW_URL,
|
||||
siliconflowApiKey: "",
|
||||
|
||||
// openrouter
|
||||
openrouterUrl: DEFAULT_OPENROUTER_URL,
|
||||
openrouterApiKey: "",
|
||||
|
||||
// server config
|
||||
needCode: true,
|
||||
hideUserApiKey: false,
|
||||
@@ -219,6 +226,10 @@ export const useAccessStore = createPersistStore(
|
||||
return ensure(get(), ["siliconflowApiKey"]);
|
||||
},
|
||||
|
||||
isValidOpenRouter() {
|
||||
return ensure(get(), ["openrouterApiKey"]);
|
||||
},
|
||||
|
||||
isAuthorized() {
|
||||
this.fetch();
|
||||
|
||||
@@ -238,6 +249,7 @@ export const useAccessStore = createPersistStore(
|
||||
this.isValidXAI() ||
|
||||
this.isValidChatGLM() ||
|
||||
this.isValidSiliconFlow() ||
|
||||
this.isValidOpenRouter() ||
|
||||
!this.enabledAccessControl() ||
|
||||
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
|
||||
);
|
||||
|
Reference in New Issue
Block a user