- {props.showToast && (
+ {props.showToast && context.length > 0 && (
Date: Fri, 13 Sep 2024 12:56:28 +0800
Subject: [PATCH 10/16] fix: remove the visual model judgment method that
checks if the model name contains 'preview' from the openai api to prevent
models like o1-preview from being classified as visual models
---
app/client/platforms/openai.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts
index 4d6f28845..31e2b0235 100644
--- a/app/client/platforms/openai.ts
+++ b/app/client/platforms/openai.ts
@@ -197,7 +197,7 @@ export class ChatGPTApi implements LLMApi {
};
// add max_tokens to vision model
- if (visionModel && modelConfig.model.includes("preview")) {
+ if (visionModel) {
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
}
}
From 71df415b140fec2b2754fd4cf99a38a6f38dacc2 Mon Sep 17 00:00:00 2001
From: skymkmk
Date: Fri, 13 Sep 2024 13:18:07 +0800
Subject: [PATCH 11/16] feat: add o1 model
---
app/client/platforms/openai.ts | 15 +++++++++------
app/constant.ts | 4 ++++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts
index 4d6f28845..da3153c62 100644
--- a/app/client/platforms/openai.ts
+++ b/app/client/platforms/openai.ts
@@ -160,6 +160,7 @@ export class ChatGPTApi implements LLMApi {
let requestPayload: RequestPayload | DalleRequestPayload;
const isDalle3 = _isDalle3(options.config.model);
+ const isO1 = options.config.model.startsWith("o1");
if (isDalle3) {
const prompt = getMessageTextContent(
options.messages.slice(-1)?.pop() as any,
@@ -181,17 +182,19 @@ export class ChatGPTApi implements LLMApi {
const content = visionModel
? await preProcessImageContent(v.content)
: getMessageTextContent(v);
- messages.push({ role: v.role, content });
+ if(!(isO1 && v.role === "system"))
+ messages.push({ role: v.role, content });
}
+ // O1 not support image, tools (plugin in ChatGPTNextWeb) and system, stream, logprobs, temperature, top_p, n, presence_penalty, frequency_penalty yet.
requestPayload = {
messages,
- stream: options.config.stream,
+ stream: !isO1 ? options.config.stream : false,
model: modelConfig.model,
- temperature: modelConfig.temperature,
- presence_penalty: modelConfig.presence_penalty,
- frequency_penalty: modelConfig.frequency_penalty,
- top_p: modelConfig.top_p,
+ temperature: !isO1 ? modelConfig.temperature : 1,
+ presence_penalty: !isO1 ? modelConfig.presence_penalty : 0,
+ frequency_penalty: !isO1 ? modelConfig.frequency_penalty : 0,
+ top_p: !isO1 ? modelConfig.top_p : 1,
// max_tokens: Math.max(modelConfig.max_tokens, 1024),
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
};
diff --git a/app/constant.ts b/app/constant.ts
index eb82d3c66..3d33a047e 100644
--- a/app/constant.ts
+++ b/app/constant.ts
@@ -250,6 +250,8 @@ export const KnowledgeCutOffDate: Record = {
"gpt-4o-mini": "2023-10",
"gpt-4o-mini-2024-07-18": "2023-10",
"gpt-4-vision-preview": "2023-04",
+ "o1-mini": "2023-10",
+ "o1-preview": "2023-10",
// After improvements,
// it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
"gemini-pro": "2023-12",
@@ -276,6 +278,8 @@ const openaiModels = [
"gpt-4-turbo-2024-04-09",
"gpt-4-1106-preview",
"dall-e-3",
+ "o1-mini",
+ "o1-preview"
];
const googleModels = [
From d0dce654bffead1971600a5feb313d9079800254 Mon Sep 17 00:00:00 2001
From: skymkmk
Date: Fri, 13 Sep 2024 14:18:18 +0800
Subject: [PATCH 12/16] fix: shouldstream is not depend on iso1
---
app/client/platforms/openai.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts
index da3153c62..bff34fdf8 100644
--- a/app/client/platforms/openai.ts
+++ b/app/client/platforms/openai.ts
@@ -207,7 +207,7 @@ export class ChatGPTApi implements LLMApi {
console.log("[Request] openai payload: ", requestPayload);
- const shouldStream = !isDalle3 && !!options.config.stream;
+ const shouldStream = !isDalle3 && !!options.config.stream && !isO1;
const controller = new AbortController();
options.onController?.(controller);
From 03fa580a558374c80485b6b36f9b1aad810f2df4 Mon Sep 17 00:00:00 2001
From: skymkmk
Date: Fri, 13 Sep 2024 16:25:04 +0800
Subject: [PATCH 13/16] fix: give o1 some time to think twice
---
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 bff34fdf8..492278a9b 100644
--- a/app/client/platforms/openai.ts
+++ b/app/client/platforms/openai.ts
@@ -182,7 +182,7 @@ export class ChatGPTApi implements LLMApi {
const content = visionModel
? await preProcessImageContent(v.content)
: getMessageTextContent(v);
- if(!(isO1 && v.role === "system"))
+ if (!(isO1 && v.role === "system"))
messages.push({ role: v.role, content });
}
@@ -316,7 +316,7 @@ export class ChatGPTApi implements LLMApi {
// make a fetch request
const requestTimeoutId = setTimeout(
() => controller.abort(),
- isDalle3 ? REQUEST_TIMEOUT_MS * 2 : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow.
+ isDalle3 || isO1 ? REQUEST_TIMEOUT_MS * 2 : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow.
);
const res = await fetch(chatPath, chatPayload);
From 3dabe47c7810983dc6e070f7571027e5dc5b6ebe Mon Sep 17 00:00:00 2001
From: lloydzhou
Date: Fri, 13 Sep 2024 16:27:02 +0800
Subject: [PATCH 14/16] fixed: html codeblock include 2 newline
---
app/components/artifacts.tsx | 2 +-
app/components/markdown.tsx | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/app/components/artifacts.tsx b/app/components/artifacts.tsx
index ac0d713b3..d725ee659 100644
--- a/app/components/artifacts.tsx
+++ b/app/components/artifacts.tsx
@@ -80,7 +80,7 @@ export const HTMLPreview = forwardRef(
}, [props.autoHeight, props.height, iframeHeight]);
const srcDoc = useMemo(() => {
- const script = ``;
+ const script = ``;
if (props.code.includes("")) {
props.code.replace("", "" + script);
}
diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx
index dc11c572d..b57fd7490 100644
--- a/app/components/markdown.tsx
+++ b/app/components/markdown.tsx
@@ -237,9 +237,26 @@ function escapeBrackets(text: string) {
);
}
+function tryWrapHtmlCode(text: string) {
+ // try add wrap html code (fixed: html codeblock include 2 newline)
+ return text
+ .replace(
+ /([`]*?)(\w*?)([\n\r]*?)()/g,
+ (match, quoteStart, lang, newLine, doctype) => {
+ return !quoteStart ? "\n```html\n" + doctype : match;
+ },
+ )
+ .replace(
+ /(<\/body>)([\r\n\s]*?)(<\/html>)([\n\r]*?)([`]*?)([\n\r]*?)/g,
+ (match, bodyEnd, space, htmlEnd, newLine, quoteEnd) => {
+ return !quoteEnd ? bodyEnd + space + htmlEnd + "\n```\n" : match;
+ },
+ );
+}
+
function _MarkDownContent(props: { content: string }) {
const escapedContent = useMemo(() => {
- return escapeBrackets(escapeDollarNumber(props.content));
+ return tryWrapHtmlCode(escapeBrackets(escapeDollarNumber(props.content)));
}, [props.content]);
return (
From db39fbc41917d50a014dcf82ae35846f3f3ec12e Mon Sep 17 00:00:00 2001
From: DDMeaqua
Date: Fri, 13 Sep 2024 16:56:06 +0800
Subject: [PATCH 15/16] =?UTF-8?q?chore:=20=E6=89=8B=E6=9C=BA=E7=AB=AF?=
=?UTF-8?q?=E9=9A=90=E8=97=8F=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=B1=95=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/components/chat.tsx | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index a6fd25d0a..e193f72ff 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -504,6 +504,8 @@ export function ChatActions(props: {
const currentStyle =
chatStore.currentSession().mask.modelConfig?.style ?? "vivid";
+ const isMobileScreen = useMobileScreen();
+
useEffect(() => {
const show = isVisionModel(currentModel);
setShowUploadImage(show);
@@ -758,11 +760,13 @@ export function ChatActions(props: {
/>
)}
- props.setShowShortcutKeyModal(true)}
- text={Locale.Chat.ShortcutKey.Title}
- icon={}
- />
+ {!isMobileScreen && (
+ props.setShowShortcutKeyModal(true)}
+ text={Locale.Chat.ShortcutKey.Title}
+ icon={}
+ />
+ )}
);
}
From df62736ff63ffa8abbda9b1be07bed65e8b167c4 Mon Sep 17 00:00:00 2001
From: lloydzhou
Date: Fri, 13 Sep 2024 17:36:32 +0800
Subject: [PATCH 16/16] update version
---
src-tauri/tauri.conf.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 78835d24d..2a19c9332 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -9,7 +9,7 @@
},
"package": {
"productName": "NextChat",
- "version": "2.15.1"
+ "version": "2.15.2"
},
"tauri": {
"allowlist": {