Skip to content

Commit

Permalink
rm serverConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper committed Feb 14, 2025
1 parent 15effb0 commit 3c250ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/client/platforms/siliconflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
getTimeoutMSByModel,
} from "@/app/utils";
import { RequestPayload } from "./openai";
import { getServerSideConfig } from "@/app/config/server";
import { fetch } from "@/app/utils/stream";
import { Cookies } from "react-cookie";
export interface SiliconFlowListModelResponse {
Expand All @@ -46,7 +45,6 @@ export class SiliconflowApi implements LLMApi {

path(path: string): string {
const accessStore = useAccessStore.getState();
const serverConfig = getServerSideConfig();

let baseUrl = "";

Expand All @@ -60,11 +58,6 @@ export class SiliconflowApi implements LLMApi {
baseUrl = isApp ? SILICONFLOW_BASE_URL : apiPath;
}

// Don't proxy if vercel
if (serverConfig?.isVercel) {
baseUrl = SiliconFlow.ExampleEndpoint;
}

if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
Expand All @@ -75,6 +68,11 @@ export class SiliconflowApi implements LLMApi {
baseUrl = "https://" + baseUrl;
}

// If we are building on Vercel, directly access to SiliconFlow API for better performance
if (!!getClientConfig()?.isVercelBuild) {
baseUrl = SILICONFLOW_BASE_URL;
}

console.log("[Proxy Endpoint] ", baseUrl, path);

return [baseUrl, path].join("/");
Expand Down
1 change: 1 addition & 0 deletions app/config/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const getBuildConfig = () => {
buildMode,
isApp,
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
isVercelBuild: !!process.env.VERCEL,
};
};

Expand Down
1 change: 1 addition & 0 deletions app/store/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export const useAccessStore = createPersistStore(
.then((res: DangerConfig) => {
console.log("[Config] got config from server", res);
set(() => ({ ...res }));
set(() => ({ siliconflowUrl: SILICONFLOW_BASE_URL }));
const sfak = retrieveAPIKeyFromCookies();
if (sfak) {
set(() => ({ siliconflowApiKey: sfak }));
Expand Down

0 comments on commit 3c250ac

Please sign in to comment.