From 05ef5adfa72d2a519a07c36aca4e6c1a965da7d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:53:00 +0000 Subject: [PATCH 01/13] chore(deps-dev): bump @testing-library/jest-dom from 6.6.2 to 6.6.3 Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 6.6.2 to 6.6.3. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](https://github.com/testing-library/jest-dom/compare/v6.6.2...v6.6.3) --- updated-dependencies: - dependency-name: "@testing-library/jest-dom" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 235652c3928..f7b544bb2e5 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@tauri-apps/api": "^1.6.0", "@tauri-apps/cli": "1.5.11", "@testing-library/dom": "^10.4.0", - "@testing-library/jest-dom": "^6.6.2", + "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", "@types/jest": "^29.5.14", "@types/js-yaml": "4.0.9", diff --git a/yarn.lock b/yarn.lock index 4f92858f343..ff257a3ef6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2114,10 +2114,10 @@ lz-string "^1.5.0" pretty-format "^27.0.2" -"@testing-library/jest-dom@^6.6.2": - version "6.6.2" - resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.6.2.tgz#8186aa9a07263adef9cc5a59a4772db8c31f4a5b" - integrity sha512-P6GJD4yqc9jZLbe98j/EkyQDTPgqftohZF5FBkHY5BUERZmcf4HeO2k0XaefEg329ux2p21i1A1DmyQ1kKw2Jw== +"@testing-library/jest-dom@^6.6.3": + version "6.6.3" + resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz#26ba906cf928c0f8172e182c6fe214eb4f9f2bd2" + integrity sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA== dependencies: "@adobe/css-tools" "^4.4.0" aria-query "^5.0.0" From 1d14a991eedb17a492d6e840de71567c8a6884a7 Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Mon, 11 Nov 2024 20:30:59 +0800 Subject: [PATCH 02/13] fix: use current session id to trigger rerender --- app/components/chat.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index ed51d926f4e..5669cc9a314 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -2071,6 +2071,6 @@ function _Chat() { export function Chat() { const chatStore = useChatStore(); - const sessionIndex = chatStore.currentSessionIndex; - return <_Chat key={sessionIndex}>; + const session = chatStore.currentSession(); + return <_Chat key={session.id}>; } From 8d66fedb1f5093d6e29ac06a839316edb535512d Mon Sep 17 00:00:00 2001 From: LovelyGuYiMeng <76251800+LovelyGuYiMeng@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:28:11 +0800 Subject: [PATCH 03/13] Update visionKeywords --- app/utils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/utils.ts b/app/utils.ts index 2dd80b8a314..1c359ef9508 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -257,11 +257,11 @@ export function isVisionModel(model: string) { const excludeKeywords = ["claude-3-5-haiku-20241022"]; const visionKeywords = [ "vision", - "claude-3", - "gemini-1.5-pro", - "gemini-1.5-flash", "gpt-4o", - "gpt-4o-mini", + "claude-3", + "gemini-1.5", + "qwen-vl", + "qwen2-vl", ]; const isGpt4Turbo = model.includes("gpt-4-turbo") && !model.includes("preview"); From 9a86c42c95be5b2bb85f44c0bdeb7714dc526a49 Mon Sep 17 00:00:00 2001 From: opchips Date: Tue, 12 Nov 2024 16:33:55 +0800 Subject: [PATCH 04/13] update --- app/components/markdown.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 8ea73112380..f58b1642794 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -90,7 +90,11 @@ export function PreCode(props: { children: any }) { const refText = ref.current.querySelector("code")?.innerText; if (htmlDom) { setHtmlCode((htmlDom as HTMLElement).innerText); - } else if (refText?.startsWith(" Date: Wed, 13 Nov 2024 14:24:44 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix:=20[#5308]=20gemini=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=80=BB=E7=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/client/platforms/google.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 53ff00aeed0..d5aa93af196 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -51,8 +51,10 @@ export class GeminiProApi implements LLMApi { console.log("[Proxy Endpoint] ", baseUrl, path); let chatPath = [baseUrl, path].join("/"); + if (!chatPath.includes("gemini-pro")) { + chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse"; + } - chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse"; return chatPath; } extractMessage(res: any) { @@ -60,6 +62,7 @@ export class GeminiProApi implements LLMApi { return ( res?.candidates?.at(0)?.content?.parts.at(0)?.text || + res?.at(0)?.candidates?.at(0)?.content?.parts.at(0)?.text || res?.error?.message || "" ); @@ -167,6 +170,7 @@ export class GeminiProApi implements LLMApi { try { // https://github.com/google-gemini/cookbook/blob/main/quickstarts/rest/Streaming_REST.ipynb const chatPath = this.path(Google.ChatPath(modelConfig.model)); + console.log("[Chat Path] ", chatPath); const chatPayload = { method: "POST", From 0628ddfc6f36479650d50281e3fa0ba1a847f777 Mon Sep 17 00:00:00 2001 From: DDMeaqua Date: Wed, 13 Nov 2024 14:27:41 +0800 Subject: [PATCH 06/13] chore: update --- app/client/platforms/google.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index d5aa93af196..30f35359e89 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -170,7 +170,6 @@ export class GeminiProApi implements LLMApi { try { // https://github.com/google-gemini/cookbook/blob/main/quickstarts/rest/Streaming_REST.ipynb const chatPath = this.path(Google.ChatPath(modelConfig.model)); - console.log("[Chat Path] ", chatPath); const chatPayload = { method: "POST", From b41c012d27d5495bec12f6aa6f9537ebb6873083 Mon Sep 17 00:00:00 2001 From: DDMeaqua Date: Wed, 13 Nov 2024 15:12:46 +0800 Subject: [PATCH 07/13] chore: shouldStream --- app/client/platforms/google.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 30f35359e89..a7bce4fc2d0 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -29,7 +29,7 @@ import { RequestPayload } from "./openai"; import { fetch } from "@/app/utils/stream"; export class GeminiProApi implements LLMApi { - path(path: string): string { + path(path: string, shouldStream = false): string { const accessStore = useAccessStore.getState(); let baseUrl = ""; @@ -51,7 +51,7 @@ export class GeminiProApi implements LLMApi { console.log("[Proxy Endpoint] ", baseUrl, path); let chatPath = [baseUrl, path].join("/"); - if (!chatPath.includes("gemini-pro")) { + if (shouldStream) { chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse"; } @@ -169,7 +169,10 @@ export class GeminiProApi implements LLMApi { options.onController?.(controller); try { // https://github.com/google-gemini/cookbook/blob/main/quickstarts/rest/Streaming_REST.ipynb - const chatPath = this.path(Google.ChatPath(modelConfig.model)); + const chatPath = this.path( + Google.ChatPath(modelConfig.model), + shouldStream, + ); const chatPayload = { method: "POST", From 19facc7c85a0e509b5d4ca1eaa98782f29477c9a Mon Sep 17 00:00:00 2001 From: Sherlock <1075773551@qq.com> Date: Thu, 14 Nov 2024 21:31:45 +0800 Subject: [PATCH 08/13] feat: support mort user-friendly scrolling --- app/components/chat.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 5669cc9a314..51fe74fe7be 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -960,9 +960,24 @@ function _Chat() { (scrollRef.current.scrollTop + scrollRef.current.clientHeight), ) <= 1 : false; + const isAttachWithTop = useMemo(() => { + const lastMessage = scrollRef.current?.lastElementChild as HTMLElement; + // if scrolllRef is not ready or no message, return false + if (!scrollRef?.current || !lastMessage) return false; + const topDistance = + lastMessage!.getBoundingClientRect().top - + scrollRef.current.getBoundingClientRect().top; + // leave some space for user question + return topDistance < 100; + }, [scrollRef?.current?.scrollHeight]); + + const isTyping = userInput !== ""; + + // if user is typing, should auto scroll to bottom + // if user is not typing, should auto scroll to bottom only if already at bottom const { setAutoScroll, scrollDomToBottom } = useScrollToBottom( scrollRef, - isScrolledToBottom, + (isScrolledToBottom || isAttachWithTop) && !isTyping, ); const [hitBottom, setHitBottom] = useState(true); const isMobileScreen = useMobileScreen(); From e56216549efe58c1b734f5094eb77bfaa6654c69 Mon Sep 17 00:00:00 2001 From: opchips Date: Fri, 15 Nov 2024 11:56:26 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20=E4=BB=A3=E7=A0=81=E5=9D=97?= =?UTF-8?q?=E5=B5=8C=E5=85=A5=E5=B0=8F=E4=BB=A3=E7=A0=81=E5=9D=97=E6=97=B6?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/markdown.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index f58b1642794..ba85f09701f 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -248,6 +248,10 @@ function escapeBrackets(text: string) { function tryWrapHtmlCode(text: string) { // try add wrap html code (fixed: html codeblock include 2 newline) + // ignore embed codeblock + if (text.includes("```")) { + return text; + } return text .replace( /([`]*?)(\w*?)([\n\r]*?)()/g, From 23350c842b1b102ebdbb17ccbb2b5cfa7b25b893 Mon Sep 17 00:00:00 2001 From: code-october <148516338+code-october@users.noreply.github.com> Date: Thu, 21 Nov 2024 03:45:07 +0000 Subject: [PATCH 10/13] fix o1 in disableGPT4 --- app/api/openai.ts | 2 +- app/components/emoji.tsx | 3 ++- app/config/server.ts | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/api/openai.ts b/app/api/openai.ts index bbba69e569c..2b5deca8be3 100644 --- a/app/api/openai.ts +++ b/app/api/openai.ts @@ -14,7 +14,7 @@ function getModels(remoteModelRes: OpenAIListModelResponse) { if (config.disableGPT4) { remoteModelRes.data = remoteModelRes.data.filter( (m) => - !(m.id.startsWith("gpt-4") || m.id.startsWith("chatgpt-4o")) || + !(m.id.startsWith("gpt-4") || m.id.startsWith("chatgpt-4o") || m.id.startsWith("o1")) || m.id.startsWith("gpt-4o-mini"), ); } diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 6db746c462c..d75cdda9268 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -37,7 +37,8 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) { return (
{props.model?.startsWith("gpt-4") || - props.model?.startsWith("chatgpt-4o") ? ( + props.model?.startsWith("chatgpt-4o") || + props.model?.startsWith("o1") ? ( ) : ( diff --git a/app/config/server.ts b/app/config/server.ts index 485f950da03..9d6b3c2b8da 100644 --- a/app/config/server.ts +++ b/app/config/server.ts @@ -129,14 +129,15 @@ export const getServerSideConfig = () => { if (customModels) customModels += ","; customModels += DEFAULT_MODELS.filter( (m) => - (m.name.startsWith("gpt-4") || m.name.startsWith("chatgpt-4o")) && + (m.name.startsWith("gpt-4") || m.name.startsWith("chatgpt-4o") || m.name.startsWith("o1")) && !m.name.startsWith("gpt-4o-mini"), ) .map((m) => "-" + m.name) .join(","); if ( (defaultModel.startsWith("gpt-4") || - defaultModel.startsWith("chatgpt-4o")) && + defaultModel.startsWith("chatgpt-4o") || + defaultModel.startsWith("o1")) && !defaultModel.startsWith("gpt-4o-mini") ) defaultModel = ""; From ef24d3e63360eea8868334f884d83f747cfd8f73 Mon Sep 17 00:00:00 2001 From: code-october <148516338+code-october@users.noreply.github.com> Date: Thu, 21 Nov 2024 03:46:10 +0000 Subject: [PATCH 11/13] use stream when request o1 --- app/client/platforms/openai.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 7c1588440b2..15cfb7ca602 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -224,7 +224,7 @@ export class ChatGPTApi implements LLMApi { // O1 not support image, tools (plugin in ChatGPTNextWeb) and system, stream, logprobs, temperature, top_p, n, presence_penalty, frequency_penalty yet. requestPayload = { messages, - stream: !isO1 ? options.config.stream : false, + stream: options.config.stream, model: modelConfig.model, temperature: !isO1 ? modelConfig.temperature : 1, presence_penalty: !isO1 ? modelConfig.presence_penalty : 0, @@ -247,7 +247,7 @@ export class ChatGPTApi implements LLMApi { console.log("[Request] openai payload: ", requestPayload); - const shouldStream = !isDalle3 && !!options.config.stream && !isO1; + const shouldStream = !isDalle3 && !!options.config.stream; const controller = new AbortController(); options.onController?.(controller); From b7acb890969fe5af9135bb49533fad610ac52e69 Mon Sep 17 00:00:00 2001 From: code-october <148516338+code-october@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:48:50 +0000 Subject: [PATCH 12/13] update new model for gpt-4o and gemini-exp --- app/constant.ts | 5 +++++ app/utils.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index f1a1996b8c5..25c8d98eae3 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -264,6 +264,7 @@ export const KnowledgeCutOffDate: Record = { "gpt-4o": "2023-10", "gpt-4o-2024-05-13": "2023-10", "gpt-4o-2024-08-06": "2023-10", + "gpt-4o-2024-11-20": "2023-10", "chatgpt-4o-latest": "2023-10", "gpt-4o-mini": "2023-10", "gpt-4o-mini-2024-07-18": "2023-10", @@ -303,6 +304,7 @@ const openaiModels = [ "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", + "gpt-4o-2024-11-20", "chatgpt-4o-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", @@ -318,6 +320,9 @@ const googleModels = [ "gemini-1.0-pro", "gemini-1.5-pro-latest", "gemini-1.5-flash-latest", + "gemini-exp-1114", + "gemini-exp-1121", + "learnlm-1.5-pro-experimental", "gemini-pro-vision", ]; diff --git a/app/utils.ts b/app/utils.ts index 1c359ef9508..b62bc126da7 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -260,6 +260,8 @@ export function isVisionModel(model: string) { "gpt-4o", "claude-3", "gemini-1.5", + "gemini-exp", + "learnlm", "qwen-vl", "qwen2-vl", ]; From 759a09a76c8c6cd97cd4546da022f38f426618f2 Mon Sep 17 00:00:00 2001 From: frostime Date: Wed, 27 Nov 2024 13:11:18 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=F0=9F=8E=A8=20style(setting):=20Place=20?= =?UTF-8?q?custom-model's=20input=20a=20seperated=20row.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/settings.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index ddbda1b730a..a74ff17b1f5 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1771,9 +1771,11 @@ export function Settings() {