Skip to content
Closed

update #6477

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
57dc81d
feat:personal changes
EricYangXD Apr 5, 2023
88fcbf3
Update README.md
EricYangXD Apr 5, 2023
7f2d309
Update app.ts
EricYangXD Apr 5, 2023
c6877de
Merge branch 'Yidadaa:main' into main
EricYangXD Apr 5, 2023
8013bf9
Merge branch 'Yidadaa:main' into main
EricYangXD Apr 7, 2023
dc66753
feat: add copy function in user's chatbox & adjust styles
EricYangValtech Apr 7, 2023
7a5aca3
Merge branch 'Yidadaa:main' into main
EricYangXD Apr 8, 2023
12f12f6
Merge
EricYangValtech Apr 10, 2023
8ae214d
Merge branch 'Yidadaa-main'
EricYangValtech Apr 10, 2023
b517b0a
Merge branch 'main' of github.com:Yidadaa/ChatGPT-Next-Web into Yidad…
EricYangXD Apr 11, 2023
9b770ca
Merge branch 'Yidadaa-main' into main
EricYangXD Apr 11, 2023
72eaedf
Merge branch 'Yidadaa:main' into main
EricYangXD Apr 13, 2023
51fbce6
Merge branch 'Yidadaa:main' into main
EricYangXD Apr 14, 2023
bc5ef2d
Merge branch 'Yidadaa:main' into main
EricYangXD Apr 19, 2023
2fca318
merge
EricYangValtech May 8, 2023
dbc1522
Merge branch 'Yidadaa-main'
EricYangValtech May 8, 2023
1fbfe26
fix: the name DEFAULT_CONFIG is defined multiple times
EricYangValtech May 15, 2023
e2a43cd
Merge branch 'main' of github.com:Yidadaa/ChatGPT-Next-Web into Yidad…
EricYangValtech May 15, 2023
863de95
Merge branch 'Yidadaa-main'
EricYangValtech May 15, 2023
429c3a4
Merge branch 'main' of github.com:Yidadaa/ChatGPT-Next-Web into Yidad…
EricYangValtech May 23, 2023
fe4f0d0
Merge branch 'Yidadaa-main'
EricYangValtech May 23, 2023
d98945b
style: adjust .chat-body css
EricYangValtech May 23, 2023
0b8f86d
Merge branch 'Yidadaa:main' into main
EricYangXD May 26, 2023
f22395a
feat: use meta/command + enter as default to chat
EricYangValtech May 26, 2023
c6cb645
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user May 27, 2023
c230f52
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user May 30, 2023
38fd0bd
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 1, 2023
14152e6
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 2, 2023
eae129d
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 3, 2023
6ed3ca7
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 6, 2023
39c7c98
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 7, 2023
6c8d852
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 8, 2023
eaf9c07
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 9, 2023
4d2fa23
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 11, 2023
aa92396
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 13, 2023
126248b
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 14, 2023
44f811c
Merge branch 'Yidadaa:main' into main
EricYangXD Jun 14, 2023
dbaab45
feat: add title and revert changes
EricYangValtech Jun 14, 2023
b745a8a
Merge branch 'Yidadaa:main' into main
EricYangXD Jun 21, 2023
3cbea7a
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 23, 2023
555168f
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 24, 2023
58f00a9
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Jun 25, 2023
9914af2
Merge branch 'main' of github.com:Yidadaa/ChatGPT-Next-Web into Yidad…
EricYangValtech Jul 5, 2023
d5a827b
Merge branch 'Yidadaa-main'
EricYangValtech Jul 5, 2023
3de0ed3
bugfix
EricYangValtech Jul 5, 2023
10842b1
merge conflicts
EricYangValtech Aug 25, 2023
4994fed
Merge branch 'Yidadaa-main'
EricYangValtech Aug 25, 2023
cc75bdf
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Aug 27, 2023
7542b80
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Aug 28, 2023
258e65c
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Aug 29, 2023
1da6ca6
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Sep 5, 2023
994be31
Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
actions-user Sep 8, 2023
7384bd7
Merge branch 'main' into main
EricYangXD Jan 12, 2024
fa939d7
Update new-chat.tsx
EricYangXD Jan 12, 2024
68ad5a7
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next…
actions-user Jan 23, 2024
15ac78f
update
EricYangValtech May 14, 2024
3956a74
Merge branch 'ChatGPTNextWeb-main'
EricYangValtech May 14, 2024
d279556
Merge branch 'main' of github.com:ChatGPTNextWeb/ChatGPT-Next-Web int…
EricYangValtech Jun 19, 2024
400e976
Merge branch 'ChatGPTNextWeb-main'
EricYangValtech Jun 19, 2024
ccb9001
fix isMacOS
EricYangValtech Jun 20, 2024
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# attention please

This project is forked from [ChatGPT-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web), and changed somewhere as personal like, thanks to [Yidadaa](https://github.com/Yidadaa) and some other developers' hard working and finally I have my own ChatGPT assistant now. Also, I should thank [Vercel](https://vercel.com/), Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration. Thanks again.

<div align="center">
<img src="./docs/images/head-cover.png" alt="icon"/>

Expand Down
9 changes: 3 additions & 6 deletions app/api/anthropic/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,9 @@ async function request(req: NextRequest) {
console.log("[Proxy] ", path);
console.log("[Base Url]", baseUrl);

const timeoutId = setTimeout(
() => {
controller.abort();
},
10 * 60 * 1000,
);
const timeoutId = setTimeout(() => {
controller.abort();
}, 10 * 60 * 1000);

const fetchUrl = `${baseUrl}${path}`;

Expand Down
29 changes: 12 additions & 17 deletions app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ export async function requestOpenai(req: NextRequest) {
console.log("[Proxy] ", path);
console.log("[Base Url]", baseUrl);

const timeoutId = setTimeout(
() => {
controller.abort();
},
10 * 60 * 1000,
);
const timeoutId = setTimeout(() => {
controller.abort();
}, 10 * 60 * 1000);

if (serverConfig.isAzure) {
if (!serverConfig.azureApiVersion) {
Expand Down Expand Up @@ -112,24 +109,23 @@ export async function requestOpenai(req: NextRequest) {
try {
const res = await fetch(fetchUrl, fetchOptions);

// Extract the OpenAI-Organization header from the response
const openaiOrganizationHeader = res.headers.get("OpenAI-Organization");
// Extract the OpenAI-Organization header from the response
const openaiOrganizationHeader = res.headers.get("OpenAI-Organization");

// Check if serverConfig.openaiOrgId is defined and not an empty string
if (serverConfig.openaiOrgId && serverConfig.openaiOrgId.trim() !== "") {
// If openaiOrganizationHeader is present, log it; otherwise, log that the header is not present
console.log("[Org ID]", openaiOrganizationHeader);
} else {
console.log("[Org ID] is not set up.");
}
// Check if serverConfig.openaiOrgId is defined and not an empty string
if (serverConfig.openaiOrgId && serverConfig.openaiOrgId.trim() !== "") {
// If openaiOrganizationHeader is present, log it; otherwise, log that the header is not present
console.log("[Org ID]", openaiOrganizationHeader);
} else {
console.log("[Org ID] is not set up.");
}

// to prevent browser prompt for credentials
const newHeaders = new Headers(res.headers);
newHeaders.delete("www-authenticate");
// to disable nginx buffering
newHeaders.set("X-Accel-Buffering", "no");


// Conditionally delete the OpenAI-Organization header from the response if [Org ID] is undefined or empty (not setup in ENV)
// Also, this is to prevent the header from being sent to the client
if (!serverConfig.openaiOrgId || serverConfig.openaiOrgId.trim() === "") {
Expand All @@ -142,7 +138,6 @@ export async function requestOpenai(req: NextRequest) {
// The browser will try to decode the response with brotli and fail
newHeaders.delete("content-encoding");


return new Response(res.body, {
status: res.status,
statusText: res.statusText,
Expand Down
9 changes: 3 additions & 6 deletions app/api/google/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ async function handle(
console.log("[Proxy] ", path);
console.log("[Base Url]", baseUrl);

const timeoutId = setTimeout(
() => {
controller.abort();
},
10 * 60 * 1000,
);
const timeoutId = setTimeout(() => {
controller.abort();
}, 10 * 60 * 1000);

const authResult = auth(req, ModelProvider.GeminiPro);
if (authResult.error) {
Expand Down
4 changes: 2 additions & 2 deletions app/api/webdav/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async function handle(

// Validate the endpoint to prevent potential SSRF attacks
if (
!mergedAllowedWebDavEndpoints.some(
(allowedEndpoint) => endpoint?.startsWith(allowedEndpoint),
!mergedAllowedWebDavEndpoints.some((allowedEndpoint) =>
endpoint?.startsWith(allowedEndpoint),
)
) {
return NextResponse.json(
Expand Down
2 changes: 1 addition & 1 deletion app/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ClaudeApi } from "./platforms/anthropic";
export const ROLES = ["system", "user", "assistant"] as const;
export type MessageRole = (typeof ROLES)[number];

export const Models = ["gpt-3.5-turbo", "gpt-4"] as const;
export const Models = ["gpt-3.5-turbo"] as const;
export type ChatModel = ModelType;

export interface MultimodalContent {
Expand Down
91 changes: 46 additions & 45 deletions app/client/platforms/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export class GeminiProApi implements LLMApi {

if (!baseUrl) {
baseUrl = isApp
? DEFAULT_API_HOST + "/api/proxy/google/" + Google.ChatPath(modelConfig.model)
? DEFAULT_API_HOST +
"/api/proxy/google/" +
Google.ChatPath(modelConfig.model)
: this.path(Google.ChatPath(modelConfig.model));
}

Expand All @@ -139,7 +141,7 @@ export class GeminiProApi implements LLMApi {
() => controller.abort(),
REQUEST_TIMEOUT_MS,
);

if (shouldStream) {
let responseText = "";
let remainText = "";
Expand Down Expand Up @@ -182,59 +184,58 @@ export class GeminiProApi implements LLMApi {
const decoder = new TextDecoder();
let partialData = "";

return reader?.read().then(function processText({
done,
value,
}): Promise<any> {
if (done) {
if (response.status !== 200) {
try {
let data = JSON.parse(ensureProperEnding(partialData));
if (data && data[0].error) {
options.onError?.(new Error(data[0].error.message));
} else {
return reader
?.read()
.then(function processText({ done, value }): Promise<any> {
if (done) {
if (response.status !== 200) {
try {
let data = JSON.parse(ensureProperEnding(partialData));
if (data && data[0].error) {
options.onError?.(new Error(data[0].error.message));
} else {
options.onError?.(new Error("Request failed"));
}
} catch (_) {
options.onError?.(new Error("Request failed"));
}
} catch (_) {
options.onError?.(new Error("Request failed"));
}
}

console.log("Stream complete");
// options.onFinish(responseText + remainText);
finished = true;
return Promise.resolve();
}
console.log("Stream complete");
// options.onFinish(responseText + remainText);
finished = true;
return Promise.resolve();
}

partialData += decoder.decode(value, { stream: true });
partialData += decoder.decode(value, { stream: true });

try {
let data = JSON.parse(ensureProperEnding(partialData));
try {
let data = JSON.parse(ensureProperEnding(partialData));

const textArray = data.reduce(
(acc: string[], item: { candidates: any[] }) => {
const texts = item.candidates.map((candidate) =>
candidate.content.parts
.map((part: { text: any }) => part.text)
.join(""),
);
return acc.concat(texts);
},
[],
);
const textArray = data.reduce(
(acc: string[], item: { candidates: any[] }) => {
const texts = item.candidates.map((candidate) =>
candidate.content.parts
.map((part: { text: any }) => part.text)
.join(""),
);
return acc.concat(texts);
},
[],
);

if (textArray.length > existingTexts.length) {
const deltaArray = textArray.slice(existingTexts.length);
existingTexts = textArray;
remainText += deltaArray.join("");
if (textArray.length > existingTexts.length) {
const deltaArray = textArray.slice(existingTexts.length);
existingTexts = textArray;
remainText += deltaArray.join("");
}
} catch (error) {
// console.log("[Response Animation] error: ", error,partialData);
// skip error message when parsing json
}
} catch (error) {
// console.log("[Response Animation] error: ", error,partialData);
// skip error message when parsing json
}

return reader.read().then(processText);
});
return reader.read().then(processText);
});
})
.catch((error) => {
console.error("Error:", error);
Expand Down
7 changes: 7 additions & 0 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,13 @@ function _Chat() {
: message.date.toLocaleString()}
</div>
</div>
{!isUser && !message.preview && (
<div className={styles["chat-message-actions"]}>
<div className={styles["chat-message-action-date"]}>
{message.date.toLocaleString()}
</div>
</div>
)}
</div>
{shouldShowClearContextDivider && <ClearContextDivider />}
</Fragment>
Expand Down
Loading
Loading