Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-Web into chatgpt-main
  • Loading branch information
Kosette committed Apr 12, 2024
2 parents de2870d + af3ebac commit b367943
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
25 changes: 18 additions & 7 deletions app/api/webdav/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function handle(
}

const endpointPath = params.path.join("/");
const targetPath = `${endpoint}/${endpointPath}`;
const targetPath = `${endpoint}${endpointPath}`;

// only allow MKCOL, GET, PUT
if (req.method !== "MKCOL" && req.method !== "GET" && req.method !== "PUT") {
Expand Down Expand Up @@ -96,7 +96,7 @@ async function handle(
);
}

const targetUrl = `${endpoint}/${endpointPath}`;
const targetUrl = targetPath;

const method = req.method;
const shouldNotHaveBody = ["get", "head"].includes(
Expand All @@ -114,12 +114,23 @@ async function handle(
duplex: "half",
};

const fetchResult = await fetch(targetUrl, fetchOptions);
let fetchResult;

console.log("[Any Proxy]", targetUrl, {
status: fetchResult.status,
statusText: fetchResult.statusText,
});
try {
fetchResult = await fetch(targetUrl, fetchOptions);
} finally {
console.log(
"[Any Proxy]",
targetUrl,
{
method: req.method,
},
{
status: fetchResult?.status,
statusText: fetchResult?.statusText,
},
);
}

return fetchResult;
}
Expand Down
19 changes: 19 additions & 0 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";

export const KnowledgeCutOffDate: Record<string, string> = {
default: "2021-09",
"gpt-4-turbo": "2023-12",
"gpt-4-turbo-preview": "2023-12",
"gpt-4-1106-preview": "2023-04",
"gpt-4-0125-preview": "2023-12",
Expand Down Expand Up @@ -191,6 +192,24 @@ export const DEFAULT_MODELS = [
providerType: "openai",
},
},
{
name: "gpt-4-turbo",
available: true,
provider: {
id: "openai",
providerName: "OpenAI",
providerType: "openai",
},
},
{
name: "gpt-4-turbo-2024-04-09",
available: true,
provider: {
id: "openai",
providerName: "OpenAI",
providerType: "openai",
},
},
{
name: "gpt-4-turbo-preview",
available: true,
Expand Down
1 change: 1 addition & 0 deletions app/store/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const useSyncStore = createPersistStore(
setLocalAppState(localState);
} catch (e) {
console.log("[Sync] failed to get remote state", e);
throw e;
}

await client.set(config.username, JSON.stringify(localState));
Expand Down
4 changes: 2 additions & 2 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ export function getMessageImages(message: RequestMessage): string[] {
}

export function isVisionModel(model: string) {
// Note: This is a better way using the TypeScript feature instead of `&&` or `||` (ts v5.5.0-dev.20240314 I've been using)
const visionKeywords = ["vision", "claude-3"];
const isGpt4Turbo = model.includes("gpt-4-turbo") && !model.includes("preview");

return visionKeywords.some((keyword) => model.includes(keyword));
return visionKeywords.some((keyword) => model.includes(keyword)) || isGpt4Turbo;
}
8 changes: 4 additions & 4 deletions app/utils/cloud/webdav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export function createWebDavClient(store: SyncStore) {
};
},
path(path: string, proxyUrl: string = "") {
if (!path.endsWith("/")) {
path += "/";
}
// if (!path.endsWith("/")) {
// path += "/";
// }
if (path.startsWith("/")) {
path = path.slice(1);
}
Expand All @@ -76,7 +76,7 @@ export function createWebDavClient(store: SyncStore) {

let url;
if (proxyUrl.length > 0 || proxyUrl === "/") {
let u = new URL(proxyUrl + "/api/webdav/" + path);
let u = new URL(proxyUrl + "api/webdav/" + path);
// add query params
u.searchParams.append("endpoint", config.endpoint);
url = u.toString();
Expand Down

0 comments on commit b367943

Please sign in to comment.