From f6ff32f339c974866a529f2612739cb141daa0ce Mon Sep 17 00:00:00 2001 From: Binh Le Date: Sun, 7 May 2023 14:54:09 +0700 Subject: [PATCH 1/8] Add Vietnamese translation --- app/locales/cn.ts | 1 + app/locales/de.ts | 1 + app/locales/en.ts | 1 + app/locales/es.ts | 1 + app/locales/index.ts | 3 + app/locales/it.ts | 1 + app/locales/jp.ts | 1 + app/locales/tr.ts | 1 + app/locales/tw.ts | 1 + app/locales/vi.ts | 241 +++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 252 insertions(+) create mode 100644 app/locales/vi.ts diff --git a/app/locales/cn.ts b/app/locales/cn.ts index f973dfb..8bec7c4 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -78,6 +78,7 @@ const cn = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "头像", diff --git a/app/locales/de.ts b/app/locales/de.ts index 048e575..5620272 100644 --- a/app/locales/de.ts +++ b/app/locales/de.ts @@ -81,6 +81,7 @@ const de: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "Avatar", diff --git a/app/locales/en.ts b/app/locales/en.ts index e424d9b..cb97c51 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -80,6 +80,7 @@ const en: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "Avatar", diff --git a/app/locales/es.ts b/app/locales/es.ts index 46d18a5..df28075 100644 --- a/app/locales/es.ts +++ b/app/locales/es.ts @@ -80,6 +80,7 @@ const es: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "Avatar", diff --git a/app/locales/index.ts b/app/locales/index.ts index 40f0a1a..dee6f79 100644 --- a/app/locales/index.ts +++ b/app/locales/index.ts @@ -6,6 +6,7 @@ import IT from "./it"; import TR from "./tr"; import JP from "./jp"; import DE from "./de"; +import VI from "./vi"; export type { LocaleType } from "./cn"; @@ -18,6 +19,7 @@ export const AllLangs = [ "tr", "jp", "de", + "vi", ] as const; export type Lang = (typeof AllLangs)[number]; @@ -79,4 +81,5 @@ export default { tr: TR, jp: JP, de: DE, + vi: VI, }[getLang()] as typeof CN; diff --git a/app/locales/it.ts b/app/locales/it.ts index ee9a2c2..abf655f 100644 --- a/app/locales/it.ts +++ b/app/locales/it.ts @@ -80,6 +80,7 @@ const it: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "Avatar", diff --git a/app/locales/jp.ts b/app/locales/jp.ts index fb693cf..de03f9f 100644 --- a/app/locales/jp.ts +++ b/app/locales/jp.ts @@ -80,6 +80,7 @@ const jp: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "アバター", diff --git a/app/locales/tr.ts b/app/locales/tr.ts index 5eb4fe3..6793beb 100644 --- a/app/locales/tr.ts +++ b/app/locales/tr.ts @@ -80,6 +80,7 @@ const tr: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "Avatar", diff --git a/app/locales/tw.ts b/app/locales/tw.ts index de964fc..c541e97 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -78,6 +78,7 @@ const tw: LocaleType = { tr: "Türkçe", jp: "日本語", de: "Deutsch", + vi: "Vietnamese", }, }, Avatar: "大頭貼", diff --git a/app/locales/vi.ts b/app/locales/vi.ts new file mode 100644 index 0000000..66d4a4d --- /dev/null +++ b/app/locales/vi.ts @@ -0,0 +1,241 @@ +import { SubmitKey } from "../store/config"; +import type { LocaleType } from "./index"; + +const vi: LocaleType = { + WIP: "Coming Soon...", + Error: { + Unauthorized: + "Truy cập chưa xác thực, vui lòng nhập mã truy cập trong trang cài đặt.", + }, + ChatItem: { + ChatItemCount: (count: number) => `${count} tin nhắn`, + }, + Chat: { + SubTitle: (count: number) => `${count} tin nhắn với ChatGPT`, + Actions: { + ChatList: "Xem danh sách chat", + CompressedHistory: "Nén tin nhắn trong quá khứ", + Export: "Xuất tất cả tin nhắn dưới dạng Markdown", + Copy: "Sao chép", + Stop: "Dừng", + Retry: "Thử lại", + Delete: "Xóa", + }, + Rename: "Đổi tên", + Typing: "Đang nhập…", + Input: (submitKey: string) => { + var inputHints = `${submitKey} để gửi`; + if (submitKey === String(SubmitKey.Enter)) { + inputHints += ", Shift + Enter để xuống dòng"; + } + return inputHints + ", / để tìm kiếm mẫu gợi ý"; + }, + Send: "Gửi", + Config: { + Reset: "Khôi phục cài đặt gốc", + SaveAs: "Lưu dưới dạng Mẫu", + }, + }, + Export: { + Title: "Tất cả tin nhắn", + Copy: "Sao chép tất cả", + Download: "Tải xuống", + MessageFromYou: "Tin nhắn của bạn", + MessageFromChatGPT: "Tin nhắn từ ChatGPT", + }, + Memory: { + Title: "Lịch sử tin nhắn", + EmptyContent: "Chưa có tin nhắn", + Send: "Gửi tin nhắn trong quá khứ", + Copy: "Sao chép tin nhắn trong quá khứ", + Reset: "Đặt lại phiên", + ResetConfirm: + "Đặt lại sẽ xóa toàn bộ lịch sử trò chuyện hiện tại và bộ nhớ. Bạn có chắc chắn muốn đặt lại không?", + }, + Home: { + NewChat: "Cuộc trò chuyện mới", + DeleteChat: "Xác nhận xóa các cuộc trò chuyện đã chọn?", + DeleteToast: "Đã xóa cuộc trò chuyện", + Revert: "Khôi phục", + }, + Settings: { + Title: "Cài đặt", + SubTitle: "Tất cả cài đặt", + Actions: { + ClearAll: "Xóa toàn bộ dữ liệu", + ResetAll: "Khôi phục cài đặt gốc", + Close: "Đóng", + ConfirmResetAll: "Bạn chắc chắn muốn thiết lập lại tất cả cài đặt?", + ConfirmClearAll: "Bạn chắc chắn muốn thiết lập lại tất cả dữ liệu?", + }, + Lang: { + Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` + All: "Tất cả ngôn ngữ", + Options: { + cn: "简体中文", + en: "English", + tw: "繁體中文", + es: "Español", + it: "Italiano", + tr: "Türkçe", + jp: "日本語", + de: "Deutsch", + vi: "Vietnamese", + }, + }, + Avatar: "Ảnh đại diện", + FontSize: { + Title: "Font chữ", + SubTitle: "Thay đổi font chữ của nội dung trò chuyện", + }, + Update: { + Version: (x: string) => `Phiên bản: ${x}`, + IsLatest: "Phiên bản mới nhất", + CheckUpdate: "Kiểm tra bản cập nhật", + IsChecking: "Kiểm tra bản cập nhật...", + FoundUpdate: (x: string) => `Phát hiện phiên bản mới: ${x}`, + GoToUpdate: "Cập nhật", + }, + SendKey: "Phím gửi", + Theme: "Theme", + TightBorder: "Chế độ không viền", + SendPreviewBubble: { + Title: "Gửi bong bóng xem trước", + SubTitle: "Xem trước nội dung markdown bằng bong bóng", + }, + Mask: { + Title: "Mask Splash Screen", + SubTitle: "Chớp màn hình khi bắt đầu cuộc trò chuyện mới", + }, + Prompt: { + Disable: { + Title: "Vô hiệu hóa chức năng tự động hoàn thành", + SubTitle: "Nhập / để kích hoạt chức năng tự động hoàn thành", + }, + List: "Danh sách mẫu gợi ý", + ListCount: (builtin: number, custom: number) => + `${builtin} có sẵn, ${custom} do người dùng xác định`, + Edit: "Chỉnh sửa", + Modal: { + Title: "Danh sách mẫu gợi ý", + Add: "Thêm", + Search: "Tìm kiếm mẫu", + }, + EditModal: { + Title: "Chỉnh sửa mẫu", + }, + }, + HistoryCount: { + Title: "Số lượng tin nhắn đính kèm", + SubTitle: "Số lượng tin nhắn trong quá khứ được gửi kèm theo mỗi yêu cầu", + }, + CompressThreshold: { + Title: "Ngưỡng nén lịch sử tin nhắn", + SubTitle: "Thực hiện nén nếu số lượng tin nhắn chưa nén vượt quá ngưỡng", + }, + Token: { + Title: "API Key", + SubTitle: "Sử dụng khóa của bạn để bỏ qua giới hạn mã truy cập", + Placeholder: "OpenAI API Key", + }, + Usage: { + Title: "Hạn mức tài khoản", + SubTitle(used: any, total: any) { + return `Đã sử dụng $${used} trong tháng này, hạn mức $${total}`; + }, + IsChecking: "Đang kiểm tra...", + Check: "Kiểm tra", + NoAccess: "Nhập API Key để kiểm tra hạn mức", + }, + AccessCode: { + Title: "Mã truy cập", + SubTitle: "Đã bật kiểm soát truy cập", + Placeholder: "Nhập mã truy cập", + }, + Model: "Mô hình", + Temperature: { + Title: "Tính ngẫu nhiên (temperature)", + SubTitle: "Giá trị càng lớn, câu trả lời càng ngẫu nhiên", + }, + MaxTokens: { + Title: "Giới hạn số lượng token (max_tokens)", + SubTitle: "Số lượng token tối đa được sử dụng trong mỗi lần tương tác", + }, + PresencePenlty: { + Title: "Chủ đề mới (presence_penalty)", + SubTitle: "Giá trị càng lớn tăng khả năng mở rộng sang các chủ đề mới", + }, + }, + Store: { + DefaultTopic: "Cuộc trò chuyện mới", + BotHello: "Xin chào! Mình có thể giúp gì cho bạn?", + Error: "Có lỗi xảy ra, vui lòng thử lại sau.", + Prompt: { + History: (content: string) => + "Tóm tắt ngắn gọn cuộc trò chuyện giữa người dùng và AI: " + content, + Topic: + "Sử dụng 4 đến 5 từ tóm tắt cuộc trò chuyện này mà không có phần mở đầu, dấu chấm câu, dấu ngoặc kép, dấu chấm, ký hiệu hoặc văn bản bổ sung nào. Loại bỏ các dấu ngoặc kép kèm theo.", + Summarize: + "Tóm tắt cuộc trò chuyện này một cách ngắn gọn trong 200 từ hoặc ít hơn để sử dụng làm gợi ý cho ngữ cảnh tiếp theo.", + }, + }, + Copy: { + Success: "Sao chép vào bộ nhớ tạm", + Failed: + "Sao chép không thành công, vui lòng cấp quyền truy cập vào bộ nhớ tạm", + }, + Context: { + Toast: (x: any) => `Sử dụng ${x} tin nhắn chứa ngữ cảnh`, + Edit: "Thiết lập ngữ cảnh và bộ nhớ", + Add: "Thêm tin nhắn", + }, + Plugin: { + Name: "Plugin", + }, + Mask: { + Name: "Mẫu", + Page: { + Title: "Mẫu trò chuyện", + SubTitle: (count: number) => `${count} mẫu`, + Search: "Tìm kiếm mẫu", + Create: "Tạo", + }, + Item: { + Info: (count: number) => `${count} tin nhắn`, + Chat: "Chat", + View: "Xem trước", + Edit: "Chỉnh sửa", + Delete: "Xóa", + DeleteConfirm: "Xác nhận xóa?", + }, + EditModal: { + Title: (readonly: boolean) => + `Chỉnh sửa mẫu ${readonly ? "(chỉ xem)" : ""}`, + Download: "Tải xuống", + Clone: "Tạo bản sao", + }, + Config: { + Avatar: "Ảnh đại diện bot", + Name: "Tên bot", + }, + }, + NewChat: { + Return: "Quay lại", + Skip: "Bỏ qua", + Title: "Chọn 1 biểu tượng", + SubTitle: "Bắt đầu trò chuyện ẩn sau lớp mặt nạ", + More: "Tìm thêm", + NotShow: "Không hiển thị lại", + ConfirmNoShow: "Xác nhận tắt? Bạn có thể bật lại trong phần cài đặt.", + }, + + UI: { + Confirm: "Xác nhận", + Cancel: "Hủy", + Close: "Đóng", + Create: "Tạo", + Edit: "Chỉnh sửa", + }, +}; + +export default vi; From 4a82a91f2d3370785cbeeae76c6b0ddded1f1147 Mon Sep 17 00:00:00 2001 From: "ShengYan, Zhang" Date: Mon, 8 May 2023 08:27:10 +0800 Subject: [PATCH 2/8] fix: styles on .user-prompt-buttons --- app/components/settings.module.scss | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/components/settings.module.scss b/app/components/settings.module.scss index f257a3c..863147b 100644 --- a/app/components/settings.module.scss +++ b/app/components/settings.module.scss @@ -60,13 +60,11 @@ .user-prompt-buttons { display: flex; align-items: center; + column-gap: 2px; .user-prompt-button { - height: 100%; - - &:not(:last-child) { - margin-right: 5px; - } + //height: 100%; + padding: 7px; } } } From 9bcfe6461db9fd8aa7e1dc40b3817629b212e72b Mon Sep 17 00:00:00 2001 From: "ShengYan, Zhang" Date: Mon, 8 May 2023 08:48:47 +0800 Subject: [PATCH 3/8] chore: remove an unused css name --- app/components/settings.module.scss | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/components/settings.module.scss b/app/components/settings.module.scss index 863147b..1eac17c 100644 --- a/app/components/settings.module.scss +++ b/app/components/settings.module.scss @@ -69,7 +69,4 @@ } } } - - .user-prompt-actions { - } } From c394b214231508c25843fa37534ced3b9232a2b8 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Mon, 8 May 2023 22:18:19 +0800 Subject: [PATCH 4/8] fix: #1294 fallback while mermaid render fails --- app/components/markdown.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 9e71bb0..cbe730c 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -12,15 +12,21 @@ import mermaid from "mermaid"; import LoadingIcon from "../icons/three-dots.svg"; import React from "react"; -export function Mermaid(props: { code: string }) { +export function Mermaid(props: { code: string; onError: () => void }) { const ref = useRef(null); useEffect(() => { if (props.code && ref.current) { - mermaid.run({ - nodes: [ref.current], - }); + mermaid + .run({ + nodes: [ref.current], + }) + .catch((e) => { + props.onError(); + console.error("[Mermaid] ", e.message); + }); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [props.code]); function viewSvgInNewWindow() { @@ -38,7 +44,7 @@ export function Mermaid(props: { code: string }) { return (
viewSvgInNewWindow()} > @@ -60,7 +66,7 @@ export function PreCode(props: { children: any }) { }, [props.children]); if (mermaidCode) { - return ; + return setMermaidCode("")} />; } return ( From 1f2ef1cdb714500b500c1ff207d580c73fe53ba3 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Mon, 8 May 2023 22:21:06 +0800 Subject: [PATCH 5/8] fix: #1307 empty messages --- app/components/markdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index cbe730c..fb37fdc 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -153,7 +153,7 @@ export function Markdown( } }; - checkInView(); + setTimeout(() => checkInView(), 1); return (
Date: Mon, 8 May 2023 22:49:51 +0800 Subject: [PATCH 6/8] feat: #1303 improve long text input ux and mobile modal --- app/components/mask.tsx | 95 +++++++++++++++++++------------ app/components/model-config.tsx | 1 - app/components/ui-lib.module.scss | 22 +++---- app/store/chat.ts | 2 +- app/styles/globals.scss | 4 ++ 5 files changed, 76 insertions(+), 48 deletions(-) diff --git a/app/components/mask.tsx b/app/components/mask.tsx index 106418e..964a3cc 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -106,6 +106,59 @@ export function MaskConfig(props: { ); } +function ContextPromptItem(props: { + prompt: Message; + update: (prompt: Message) => void; + remove: () => void; +}) { + const [focusingInput, setFocusingInput] = useState(false); + + return ( +
+ {!focusingInput && ( + + )} + setFocusingInput(true)} + onBlur={() => setFocusingInput(false)} + onInput={(e) => + props.update({ + ...props.prompt, + content: e.currentTarget.value as any, + }) + } + /> + {!focusingInput && ( + } + className={chatStyle["context-delete-button"]} + onClick={() => props.remove()} + bordered + /> + )} +
+ ); +} + export function ContextPrompts(props: { context: Message[]; updateContext: (updater: (context: Message[]) => void) => void; @@ -128,42 +181,12 @@ export function ContextPrompts(props: { <>
{context.map((c, i) => ( -
- - - updateContextPrompt(i, { - ...c, - content: e.currentTarget.value as any, - }) - } - /> - } - className={chatStyle["context-delete-button"]} - onClick={() => removeContextPrompt(i)} - bordered - /> -
+ updateContextPrompt(i, prompt)} + remove={() => removeContextPrompt(i)} + /> ))}
diff --git a/app/components/model-config.tsx b/app/components/model-config.tsx index 32c2f5c..fe9319e 100644 --- a/app/components/model-config.tsx +++ b/app/components/model-config.tsx @@ -1,4 +1,3 @@ -import styles from "./settings.module.scss"; import { ALL_MODELS, ModalConfigValidator, ModelConfig } from "../store"; import Locale from "../locales"; diff --git a/app/components/ui-lib.module.scss b/app/components/ui-lib.module.scss index 465fc0d..ce512da 100644 --- a/app/components/ui-lib.module.scss +++ b/app/components/ui-lib.module.scss @@ -124,6 +124,18 @@ } } +@media screen and (max-width: 600px) { + .modal-container { + width: 100vw; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + + .modal-content { + max-height: 50vh; + } + } +} + .show { opacity: 1; transition: all ease 0.3s; @@ -191,13 +203,3 @@ resize: none; min-width: 50px; } - -@media only screen and (max-width: 600px) { - .modal-container { - width: 90vw; - - .modal-content { - max-height: 50vh; - } - } -} diff --git a/app/store/chat.ts b/app/store/chat.ts index 5abd812..0d66580 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -33,7 +33,7 @@ export function createMessage(override: Partial): Message { }; } -export const ROLES: Message["role"][] = ["system", "user", "assistant"]; +export const ROLES: Message["role"][] = ["user", "system", "assistant"]; export interface ChatStat { tokenCount: number; diff --git a/app/styles/globals.scss b/app/styles/globals.scss index f849516..1ae908b 100644 --- a/app/styles/globals.scss +++ b/app/styles/globals.scss @@ -248,6 +248,10 @@ div.math { display: flex; align-items: center; justify-content: center; + + @media screen and (max-width: 600px) { + align-items: flex-end; + } } .link { From 222301307fd13ec2ed9828cc0dc4f8b2e309c0d6 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Tue, 9 May 2023 00:39:00 +0800 Subject: [PATCH 7/8] feat: close #1301 support message actions --- app/command.ts | 28 ++++++++++++++++++++++++++++ app/components/chat.tsx | 23 ++++++++++++----------- app/components/home.tsx | 1 + app/components/mask.tsx | 4 ++-- app/components/new-chat.tsx | 14 +++++++++++++- app/locales/cn.ts | 4 ++-- app/store/chat.ts | 6 +++--- app/store/config.ts | 2 +- next.config.mjs | 7 ++++++- 9 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 app/command.ts diff --git a/app/command.ts b/app/command.ts new file mode 100644 index 0000000..40bad92 --- /dev/null +++ b/app/command.ts @@ -0,0 +1,28 @@ +import { useSearchParams } from "react-router-dom"; + +type Command = (param: string) => void; +interface Commands { + fill?: Command; + submit?: Command; + mask?: Command; +} + +export function useCommand(commands: Commands = {}) { + const [searchParams, setSearchParams] = useSearchParams(); + + if (commands === undefined) return; + + let shouldUpdate = false; + searchParams.forEach((param, name) => { + const commandName = name as keyof Commands; + if (typeof commands[commandName] === "function") { + commands[commandName]!(param); + searchParams.delete(name); + shouldUpdate = true; + } + }); + + if (shouldUpdate) { + setSearchParams(searchParams); + } +} diff --git a/app/components/chat.tsx b/app/components/chat.tsx index ca51a06..8786877 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -26,12 +26,10 @@ import { SubmitKey, useChatStore, BOT_HELLO, - ROLES, createMessage, useAccessStore, Theme, useAppConfig, - ModelConfig, DEFAULT_TOPIC, } from "../store"; @@ -58,11 +56,8 @@ import { useLocation, useNavigate } from "react-router-dom"; import { Path } from "../constant"; import { Avatar } from "./emoji"; import { MaskAvatar, MaskConfig } from "./mask"; -import { - DEFAULT_MASK_AVATAR, - DEFAULT_MASK_ID, - useMaskStore, -} from "../store/mask"; +import { useMaskStore } from "../store/mask"; +import { useCommand } from "../command"; const Markdown = dynamic(async () => (await import("./markdown")).Markdown, { loading: () => , @@ -478,8 +473,7 @@ export function Chat() { } }; - // submit user input - const onUserSubmit = () => { + const doSubmit = (userInput: string) => { if (userInput.trim() === "") return; setIsLoading(true); chatStore.onUserInput(userInput).then(() => setIsLoading(false)); @@ -504,7 +498,7 @@ export function Chat() { return; } if (shouldSubmit(e)) { - onUserSubmit(); + doSubmit(userInput); e.preventDefault(); } }; @@ -618,6 +612,13 @@ export function Chat() { const isChat = location.pathname === Path.Chat; const autoFocus = !isMobileScreen || isChat; // only focus in chat page + useCommand({ + fill: setUserInput, + submit: (text) => { + doSubmit(text); + }, + }); + return (
@@ -816,7 +817,7 @@ export function Chat() { text={Locale.Chat.Send} className={styles["chat-input-send"]} type="primary" - onClick={onUserSubmit} + onClick={() => doSubmit(userInput)} />
diff --git a/app/components/home.tsx b/app/components/home.tsx index a83a779..4c3d0a6 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -23,6 +23,7 @@ import { } from "react-router-dom"; import { SideBar } from "./sidebar"; import { useAppConfig } from "../store/config"; +import { useMaskStore } from "../store/mask"; export function Loading(props: { noLogo?: boolean }) { return ( diff --git a/app/components/mask.tsx b/app/components/mask.tsx index 964a3cc..9794c97 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -20,7 +20,7 @@ import Locale, { AllLangs, Lang } from "../locales"; import { useNavigate } from "react-router-dom"; import chatStyle from "./chat.module.scss"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { downloadAs, readFromFile } from "../utils"; import { Updater } from "../api/openai/typing"; import { ModelConfigList } from "./model-config"; @@ -197,7 +197,7 @@ export function ContextPrompts(props: { className={chatStyle["context-prompt-button"]} onClick={() => addContextPrompt({ - role: "system", + role: "user", content: "", date: "", }) diff --git a/app/components/new-chat.tsx b/app/components/new-chat.tsx index 42612e0..81858fb 100644 --- a/app/components/new-chat.tsx +++ b/app/components/new-chat.tsx @@ -13,6 +13,7 @@ import { Mask, useMaskStore } from "../store/mask"; import Locale from "../locales"; import { useAppConfig, useChatStore } from "../store"; import { MaskAvatar } from "./mask"; +import { useCommand } from "../command"; function getIntersectionArea(aRect: DOMRect, bRect: DOMRect) { const xmin = Math.max(aRect.x, bRect.x); @@ -108,9 +109,20 @@ export function NewChat() { const startChat = (mask?: Mask) => { chatStore.newSession(mask); - navigate(Path.Chat); + setTimeout(() => navigate(Path.Chat), 1); }; + useCommand({ + mask: (id) => { + try { + const mask = maskStore.get(parseInt(id)); + startChat(mask ?? undefined); + } catch { + console.error("[New Chat] failed to create chat from mask id=", id); + } + }, + }); + return (
diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 8bec7c4..112b3b5 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -4,7 +4,7 @@ const cn = { WIP: "该功能仍在开发中……", Error: { Unauthorized: - "现在是未授权状态,请点击左下角[设置](/#/settings)按钮输入访问密码。", + "访问密码不正确或为空,请前往[设置](/#/settings)页输入正确的访问密码,或者填入你自己的 OpenAI API Key。", }, ChatItem: { ChatItemCount: (count: number) => `${count} 条对话`, @@ -149,7 +149,7 @@ const cn = { }, AccessCode: { Title: "访问密码", - SubTitle: "已开启加密访问", + SubTitle: "管理员已开启加密访问", Placeholder: "请输入访问密码", }, Model: "模型 (model)", diff --git a/app/store/chat.ts b/app/store/chat.ts index 0d66580..c938d78 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -7,11 +7,11 @@ import { requestChatStream, requestWithPrompt, } from "../requests"; -import { isMobileScreen, trimTopic } from "../utils"; +import { trimTopic } from "../utils"; import Locale from "../locales"; import { showToast } from "../components/ui-lib"; -import { DEFAULT_CONFIG, ModelConfig, ModelType, useAppConfig } from "./config"; +import { ModelType } from "./config"; import { createEmptyMask, Mask } from "./mask"; import { StoreKey } from "../constant"; @@ -33,7 +33,7 @@ export function createMessage(override: Partial): Message { }; } -export const ROLES: Message["role"][] = ["user", "system", "assistant"]; +export const ROLES: Message["role"][] = ["system", "user", "assistant"]; export interface ChatStat { tokenCount: number; diff --git a/app/store/config.ts b/app/store/config.ts index da77c7b..926c296 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -31,7 +31,7 @@ export const DEFAULT_CONFIG = { modelConfig: { model: "gpt-3.5-turbo" as ModelType, - temperature: 1, + temperature: 0.5, max_tokens: 2000, presence_penalty: 0, sendMemory: true, diff --git a/next.config.mjs b/next.config.mjs index 3f7c2fb..c62f884 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -5,7 +5,12 @@ const nextConfig = { appDir: true, }, async rewrites() { - const ret = []; + const ret = [ + { + source: "/api/proxy/:path*", + destination: "https://api.openai.com/:path*", + }, + ]; const apiUrl = process.env.API_URL; if (apiUrl) { From a1418fe33c0bd664f5cc88cb4df130026b0e7218 Mon Sep 17 00:00:00 2001 From: Crazyang Date: Tue, 9 May 2023 01:03:51 +0800 Subject: [PATCH 8/8] Update sync.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 因为 Vercel 频繁更新会失败,遂建议改为一天同步一次。 --- .github/workflows/sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 15d3240..a4c14c8 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -5,7 +5,7 @@ permissions: on: schedule: - - cron: "0 * * * *" # every hour + - cron: "0 0 * * *" # every day workflow_dispatch: jobs: