Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore fix #4525

Merged
merged 2 commits into from
Apr 16, 2024
Merged
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: 5 additions & 1 deletion app/client/platforms/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ export class ClaudeApi implements LLMApi {
path(path: string): string {
const accessStore = useAccessStore.getState();

let baseUrl: string = accessStore.anthropicUrl;
let baseUrl: string = "";

if (accessStore.useCustomConfig) {
baseUrl = accessStore.anthropicUrl;
}

// if endpoint is empty, use default endpoint
if (baseUrl.trim().length === 0) {
Expand Down
8 changes: 7 additions & 1 deletion app/client/platforms/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ export class GeminiProApi implements LLMApi {
};

const accessStore = useAccessStore.getState();
let baseUrl = accessStore.googleUrl;

let baseUrl = "";

if (accessStore.useCustomConfig) {
baseUrl = accessStore.googleUrl;
}

const isApp = !!getClientConfig()?.isApp;

let shouldStream = !!options.config.stream;
Expand Down
26 changes: 15 additions & 11 deletions app/client/platforms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,23 @@ export class ChatGPTApi implements LLMApi {
path(path: string): string {
const accessStore = useAccessStore.getState();

const isAzure = accessStore.provider === ServiceProvider.Azure;
let baseUrl = "";

if (isAzure && !accessStore.isValidAzure()) {
throw Error(
"incomplete azure config, please check it in your settings page",
);
}
if (accessStore.useCustomConfig) {
const isAzure = accessStore.provider === ServiceProvider.Azure;

let baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
if (isAzure && !accessStore.isValidAzure()) {
throw Error(
"incomplete azure config, please check it in your settings page",
);
}

if (isAzure) {
path = makeAzurePath(path, accessStore.azureApiVersion);
}

baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
}

if (baseUrl.length === 0) {
const isApp = !!getClientConfig()?.isApp;
Expand All @@ -84,10 +92,6 @@ export class ChatGPTApi implements LLMApi {
baseUrl = "https://" + baseUrl;
}

if (isAzure) {
path = makeAzurePath(path, accessStore.azureApiVersion);
}

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

return [baseUrl, path].join("/");
Expand Down
18 changes: 9 additions & 9 deletions app/utils/cloud/webdav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ export function createWebDavClient(store: SyncStore) {
};
},
path(path: string, proxyUrl: string = "") {
// if (!path.endsWith("/")) {
// path += "/";
// }
if (path.startsWith("/")) {
path = path.slice(1);
}

if (proxyUrl.length > 0 && !proxyUrl.endsWith("/")) {
proxyUrl += "/";
if (proxyUrl.endsWith("/")) {
proxyUrl = proxyUrl.slice(0, -1);
}

let url;
if (proxyUrl.length > 0 || proxyUrl === "/") {
let u = new URL(proxyUrl + "api/webdav/" + path);
const pathPrefix = "/api/webdav/";

try {
let u = new URL(proxyUrl + pathPrefix + path);
// add query params
u.searchParams.append("endpoint", config.endpoint);
url = u.toString();
} else {
url = "/api/upstash/" + path + "?endpoint=" + config.endpoint;
} catch (e) {
url = pathPrefix + path + "?endpoint=" + config.endpoint;
}

return url;
},
};
Expand Down
Loading