Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/api/302ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function handle(
return NextResponse.json({ body: "OK" }, { status: 200 });
}

const authResult = auth(req, ModelProvider["302.AI"]);
const authResult = auth(req, ModelProvider.AI302);
if (authResult.error) {
return NextResponse.json(authResult, {
status: 401,
Expand All @@ -42,7 +42,7 @@ async function request(req: NextRequest) {
const controller = new AbortController();

// alibaba use base url or just remove the path
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath["302.AI"], "");
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.AI302, "");

let baseUrl = serverConfig.ai302Url || AI302_BASE_URL;

Expand Down Expand Up @@ -91,7 +91,7 @@ async function request(req: NextRequest) {
isModelNotavailableInServer(
serverConfig.customModels,
jsonBody?.model as string,
ServiceProvider["302.AI"] as string,
ServiceProvider.AI302 as string,
)
) {
return NextResponse.json(
Expand Down
2 changes: 1 addition & 1 deletion app/api/[provider]/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function handle(
return siliconflowHandler(req, { params });
case ApiPath.OpenAI:
return openaiHandler(req, { params });
case ApiPath["302.AI"]:
case ApiPath.AI302:
return ai302Handler(req, { params });
default:
return proxyHandler(req, { params });
Expand Down
3 changes: 3 additions & 0 deletions app/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export function auth(req: NextRequest, modelProvider: ModelProvider) {
case ModelProvider.SiliconFlow:
systemApiKey = serverConfig.siliconFlowApiKey;
break;
case ModelProvider.AI302:
systemApiKey = serverConfig.ai302ApiKey;
break;
case ModelProvider.GPT:
default:
if (req.nextUrl.pathname.includes("azure/deployments")) {
Expand Down
8 changes: 4 additions & 4 deletions app/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class ClientApi {
case ModelProvider.SiliconFlow:
this.llm = new SiliconflowApi();
break;
case ModelProvider["302.AI"]:
case ModelProvider.AI302:
this.llm = new Ai302Api();
break;
default:
Expand Down Expand Up @@ -269,7 +269,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
const isChatGLM = modelConfig.providerName === ServiceProvider.ChatGLM;
const isSiliconFlow =
modelConfig.providerName === ServiceProvider.SiliconFlow;
const isAI302 = modelConfig.providerName === ServiceProvider["302.AI"];
const isAI302 = modelConfig.providerName === ServiceProvider.AI302;
const isEnabledAccessControl = accessStore.enabledAccessControl();
const apiKey = isGoogle
? accessStore.googleApiKey
Expand Down Expand Up @@ -391,8 +391,8 @@ export function getClientApi(provider: ServiceProvider): ClientApi {
return new ClientApi(ModelProvider.ChatGLM);
case ServiceProvider.SiliconFlow:
return new ClientApi(ModelProvider.SiliconFlow);
case ServiceProvider["302.AI"]:
return new ClientApi(ModelProvider["302.AI"]);
case ServiceProvider.AI302:
return new ClientApi(ModelProvider.AI302);
default:
return new ClientApi(ModelProvider.GPT);
}
Expand Down
14 changes: 3 additions & 11 deletions app/client/platforms/ai302.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"use client";

import {
ApiPath,
AI302_BASE_URL,
DEFAULT_MODELS,
AI302,
} from "@/app/constant";
import { ApiPath, AI302_BASE_URL, DEFAULT_MODELS, AI302 } from "@/app/constant";
import {
useAccessStore,
useAppConfig,
Expand Down Expand Up @@ -54,17 +49,14 @@ export class Ai302Api implements LLMApi {

if (baseUrl.length === 0) {
const isApp = !!getClientConfig()?.isApp;
const apiPath = ApiPath["302.AI"];
const apiPath = ApiPath.AI302;
baseUrl = isApp ? AI302_BASE_URL : apiPath;
}

if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
if (
!baseUrl.startsWith("http") &&
!baseUrl.startsWith(ApiPath["302.AI"])
) {
if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.AI302)) {
baseUrl = "https://" + baseUrl;
}

Expand Down
70 changes: 35 additions & 35 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1459,44 +1459,44 @@ export function Settings() {
</>
);

const ai302ConfigComponent = accessStore.provider === ServiceProvider["302.AI"] && (
const ai302ConfigComponent = accessStore.provider ===
ServiceProvider.AI302 && (
<>
<ListItem
title={Locale.Settings.Access.AI302.Endpoint.Title}
subTitle={
Locale.Settings.Access.AI302.Endpoint.SubTitle +
AI302.ExampleEndpoint
title={Locale.Settings.Access.AI302.Endpoint.Title}
subTitle={
Locale.Settings.Access.AI302.Endpoint.SubTitle + AI302.ExampleEndpoint
}
>
<input
aria-label={Locale.Settings.Access.AI302.Endpoint.Title}
type="text"
value={accessStore.ai302Url}
placeholder={AI302.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.ai302Url = e.currentTarget.value),
)
}
>
<input
aria-label={Locale.Settings.Access.AI302.Endpoint.Title}
type="text"
value={accessStore.ai302Url}
placeholder={AI302.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) => (access.ai302Url = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.AI302.ApiKey.Title}
subTitle={Locale.Settings.Access.AI302.ApiKey.SubTitle}
>
<PasswordInput
aria-label={Locale.Settings.Access.AI302.ApiKey.Title}
value={accessStore.ai302ApiKey}
type="text"
placeholder={Locale.Settings.Access.AI302.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.ai302ApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.AI302.ApiKey.Title}
subTitle={Locale.Settings.Access.AI302.ApiKey.SubTitle}
>
<PasswordInput
aria-label={Locale.Settings.Access.AI302.ApiKey.Title}
value={accessStore.ai302ApiKey}
type="text"
placeholder={Locale.Settings.Access.AI302.ApiKey.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.ai302ApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
);

return (
Expand Down
10 changes: 5 additions & 5 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export enum ApiPath {
ChatGLM = "/api/chatglm",
DeepSeek = "/api/deepseek",
SiliconFlow = "/api/siliconflow",
"302.AI" = "/api/302ai",
AI302 = "/api/302ai",
}

export enum SlotID {
Expand Down Expand Up @@ -133,7 +133,7 @@ export enum ServiceProvider {
ChatGLM = "ChatGLM",
DeepSeek = "DeepSeek",
SiliconFlow = "SiliconFlow",
"302.AI" = "302.AI",
AI302 = "302.AI",
}

// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
Expand All @@ -160,7 +160,7 @@ export enum ModelProvider {
ChatGLM = "ChatGLM",
DeepSeek = "DeepSeek",
SiliconFlow = "SiliconFlow",
"302.AI" = "302.AI",
AI302 = "302.AI",
}

export const Stability = {
Expand Down Expand Up @@ -493,7 +493,7 @@ export const VISION_MODEL_REGEXES = [
/o3/,
/o4-mini/,
/grok-4/i,
/gpt-5/
/gpt-5/,
];

export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
Expand Down Expand Up @@ -561,7 +561,7 @@ const googleModels = [
"gemini-2.0-pro-exp",
"gemini-2.0-pro-exp-02-05",
"gemini-2.5-pro-preview-06-05",
"gemini-2.5-pro"
"gemini-2.5-pro",
];

const anthropicModels = [
Expand Down
2 changes: 1 addition & 1 deletion app/store/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const DEFAULT_SILICONFLOW_URL = isApp
? SILICONFLOW_BASE_URL
: ApiPath.SiliconFlow;

const DEFAULT_AI302_URL = isApp ? AI302_BASE_URL : ApiPath["302.AI"];
const DEFAULT_AI302_URL = isApp ? AI302_BASE_URL : ApiPath.AI302;

const DEFAULT_ACCESS_STATE = {
accessCode: "",
Expand Down