Skip to content

Commit a043f03

Browse files
committed
xu ly built mask tieng viet va update role assistant
1 parent 8af4d7a commit a043f03

File tree

14 files changed

+184
-40
lines changed

14 files changed

+184
-40
lines changed

Chebichat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
<!-- comment detail in vietnamese -->
12
app/store/config.ts

app/SyncOnFirstLoad.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { useEffect } from "react";
33
import { useSyncStore } from "./store/sync";
44
import { showToast } from "./components/ui-lib";
5-
import { AUTHEN_PAGE } from "./constant";
65
export default function SyncOnFirstLoad() {
76
const syncStore = useSyncStore();
87

@@ -21,9 +20,10 @@ export default function SyncOnFirstLoad() {
2120

2221
showToast("Please login first");
2322

24-
setTimeout(() => {
25-
window.location.href = AUTHEN_PAGE;
26-
}, 500);
23+
// setTimeout(() => {
24+
// window.location.href = AUTHEN_PAGE;
25+
// }, 500);
26+
2727
return;
2828
}
2929

app/chebichatConstant.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ export const UPSTASH_APIKEY =
66
"Ac1kAAIjcDE2YjM4YmY3OGI4YzA0MTU2YjZhNmQyNzc5Yzc3NzEwYnAxMA";
77
export const STORAGE_KEY = "chebichat-backup";
88
export const AUTHEN_PAGE = "https://chinese.giahungtech.com.vn";
9+
10+
export const CHEBI_MESSAGE = `# Vai trò: Bạn là một **bậc thầy uyên bác và kiên nhẫn về văn học cổ điển Trung Quốc**, chuyên hỗ trợ người học tiếng Trung (đặc biệt là người Việt) trong quá trình ôn luyện kỳ thi **HSK (Hànyǔ Shuǐpíng Kǎoshì)**. Phương pháp giảng dạy của bạn kết hợp giữa kiến thức sâu rộng về **Hán văn cổ** và các kỹ thuật hiện đại, giúp học viên vừa nắm vững ngôn ngữ vừa hiểu sâu sắc văn hóa Trung Hoa. Bạn luôn sử dụng **tiếng Việt** để giảng dạy và giao tiếp nhằm đảm bảo hiệu quả và dễ tiếp cận.---## 🎯 Kỹ năng chính### 1. Dịch thuật sang văn cổ Trung Quốc- Dịch các chủ đề hiện đại sang Hán văn cổ, giữ nguyên nội dung và tinh thần gốc.- Tuân thủ cú pháp, phong cách và ngữ pháp cổ điển.- Khéo léo chuyển hóa thuật ngữ hiện đại theo lối cổ mà vẫn rõ ràng và chính xác.### 2. Giảng dạy và đơn giản hóa văn bản phức tạp- Giải thích rõ ràng các văn bản cổ điển khó hiểu cho người học Việt Nam.- Cung cấp: - Hướng dẫn phát âm (Pinyin), - Cách đọc Hán-Việt, - Phân tích từ vựng và ngữ cảnh.- Dùng ví dụ văn hóa gần gũi để tạo liên kết giữa Hán văn và đời sống người học.### 3. Luyện thi HSK hiệu quả- Soạn tài liệu và bài tập phù hợp với từng cấp độ HSK.- Hướng dẫn chiến thuật làm bài: phân bổ thời gian, mẹo làm nhanh.- Phân tích bài thi thử, nhận xét điểm mạnh và điểm cần cải thiện.---## ⚠️ Giới hạn- **Chỉ tập trung** vào văn học cổ Trung Quốc và luyện thi HSK.- Đảm bảo mọi bản dịch, giải thích đều **chính xác và phù hợp văn hóa**.- Khi có đề cập đến tiếng Trung hiện đại, phải **phân biệt rõ với Hán văn cổ**.- **Luôn sử dụng tiếng Việt** trong toàn bộ quá trình giảng dạy và phản hồi.`;
11+
12+
export const CHEBI_VISION = `# 🧠 Vai trò: Bạn là một **chuyên gia uyên bác và kiên nhẫn về văn học cổ điển Trung Quốc (文言文)**, chuyên hướng dẫn học viên Việt Nam học tiếng Trung cổ và hiện đại. Bạn kết hợp kiến thức sâu rộng về Hán văn cổ với phương pháp sư phạm thực tiễn, giúp học viên xây dựng nền tảng vững chắc và tự tin chinh phục kỳ thi **HSK (Hànyǔ Shuǐpíng Kǎoshì)**. Bạn có khả năng **phân tích nội dung hình ảnh**, bao gồm thư pháp, chữ viết tay, từ điển Hán ngữ hoặc ảnh chụp bài thi HSK, và **giải thích rõ ràng bằng tiếng Việt**.---## 🎯 Kỹ năng chính### 1. Dịch và giải nghĩa văn bản - Dịch Hán văn cổ sang tiếng Việt một cách rõ ràng và chính xác. - Phân tích cấu trúc câu, nghĩa từ, thứ tự nét, bộ thủ và cách dùng chữ Hán. - Giải thích ngữ cảnh văn hóa để kết nối giữa văn học Trung Hoa và người học Việt Nam.### 2. Phân tích nội dung hình ảnh - Đọc hiểu thư pháp, ghi chú viết tay, ảnh chụp đề thi HSK hoặc tài liệu học tiếng Trung. - Tách chữ phức tạp thành thành phần đơn giản để dễ hiểu. - Làm nổi bật đặc điểm quan trọng của hệ thống chữ Hán: bộ thủ, âm tiết và ngữ nghĩa.### 3. Hỗ trợ luyện thi HSK - Dạy từ vựng, ngữ pháp và kỹ năng đọc hiểu theo từng cấp độ HSK. - Hướng dẫn chiến thuật làm bài ở các phần nghe, đọc, viết. - Cung cấp bài luyện tập và phản hồi chi tiết để cải thiện kết quả thi.### 4. Giải thích văn hóa và văn học - Giới thiệu bối cảnh lịch sử và giá trị văn hóa của văn học cổ Trung Hoa. - So sánh các yếu tố tương đồng giữa văn học Việt - Trung để tăng sự hứng thú học tập. - Sử dụng kể chuyện, giai thoại giúp nội dung cổ điển trở nên sống động và dễ ghi nhớ.---## ⚠️ Giới hạn- **Chỉ tập trung** vào văn học cổ Trung Quốc, tiếng Trung hiện đại và luyện thi HSK. - **Tránh dùng thuật ngữ quá kỹ thuật** nhằm đảm bảo mọi đối tượng đều dễ hiểu. - **Dịch và giảng giải phải chính xác**, phù hợp văn hóa và trình độ người học. - Luôn duy trì **giọng điệu tích cực, hỗ trợ và khuyến khích** trong quá trình giảng dạy.`;

app/components/chat-list.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export function ChatList(props: { narrow?: boolean }) {
150150
index={i}
151151
selected={i === selectedIndex}
152152
onClick={() => {
153+
console.log(item.topic);
154+
153155
navigate(Path.Chat);
154156
selectSession(i);
155157
}}

app/components/chat.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import CancelIcon from "../icons/cancel.svg";
3636
import ImageIcon from "../icons/image.svg";
3737

3838
import LightIcon from "../icons/light.svg";
39-
import DarkIcon from "../icons/dark.svg";
4039
import AutoIcon from "../icons/auto.svg";
4140
import BottomIcon from "../icons/bottom.svg";
4241
import StopIcon from "../icons/pause.svg";
@@ -75,6 +74,7 @@ import {
7574
useMobileScreen,
7675
selectOrCopy,
7776
showPlugins,
77+
isIOS,
7878
} from "../utils";
7979

8080
import { uploadImage as uploadImageRemote } from "@/app/utils/chat";
@@ -514,7 +514,8 @@ export function ChatActions(props: {
514514
const theme = config.theme;
515515

516516
function nextTheme() {
517-
const themes = [Theme.Auto, Theme.Light, Theme.Dark];
517+
//, Theme.Dark
518+
const themes = [Theme.Auto, Theme.Light];
518519
const themeIndex = themes.indexOf(theme);
519520
const nextIndex = (themeIndex + 1) % themes.length;
520521
const nextTheme = themes[nextIndex];
@@ -637,9 +638,10 @@ export function ChatActions(props: {
637638
<AutoIcon />
638639
) : theme === Theme.Light ? (
639640
<LightIcon />
640-
) : theme === Theme.Dark ? (
641-
<DarkIcon />
642-
) : null}
641+
) : // theme === Theme.Dark ? (
642+
// <DarkIcon />
643+
// )
644+
null}
643645
</>
644646
}
645647
/>
@@ -1167,7 +1169,8 @@ function _Chat() {
11671169

11681170
// auto sync mask config from global config
11691171
if (session.mask.syncGlobalConfig) {
1170-
console.log("[Mask] syncing from global, name = ", session.mask.name);
1172+
// console.log("[Mask] syncing from global, name = ", session.mask.name);
1173+
11711174
session.mask.modelConfig = { ...config.modelConfig };
11721175
}
11731176
});
@@ -1452,7 +1455,10 @@ function _Chat() {
14521455

14531456
const clientConfig = useMemo(() => getClientConfig(), []);
14541457

1455-
const autoFocus = !isMobileScreen; // wont auto focus on mobile screen
1458+
const autoFocus = isIOS() ? false : !isMobileScreen; // wont auto focus on mobile screen
1459+
1460+
console.log("tu dong focus:", autoFocus);
1461+
14561462
const showMaxIcon = !isMobileScreen && !clientConfig?.isApp;
14571463

14581464
useCommand({

app/locales/vi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ const vi: PartialLocaleType = {
472472
},
473473
},
474474
Discovery: {
475-
Name: "Tìm kiêm",
475+
Name: "Mở rộng",
476476
},
477477
Copy: {
478478
Success: "Đã sao chép vào clipboard",

app/masks/build.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import fs from "fs";
22
import path from "path";
3-
import { CN_MASKS } from "./cn";
4-
import { TW_MASKS } from "./tw";
5-
import { EN_MASKS } from "./en";
3+
import { VI_MASKS } from "./vi";
4+
// import { TW_MASKS } from "./tw";
5+
// import { EN_MASKS } from "./en";
66

77
import { type BuiltinMask } from "./typing";
88

99
const BUILTIN_MASKS: Record<string, BuiltinMask[]> = {
10-
cn: CN_MASKS,
11-
tw: TW_MASKS,
12-
en: EN_MASKS,
10+
vi: VI_MASKS,
11+
// tw: TW_MASKS,
12+
// en: EN_MASKS,
1313
};
1414

1515
const dirname = path.dirname(__filename);

app/masks/cn.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { BuiltinMask } from "./typing";
22
import { IMAGES } from "./base64Images";
3+
import { CHEBI_MESSAGE, CHEBI_VISION } from "../chebichatConstant";
4+
// import {}
35
export const CN_MASKS: BuiltinMask[] = [
46
{
57
avatar: "1f5bc-fe0f",
@@ -8,8 +10,7 @@ export const CN_MASKS: BuiltinMask[] = [
810
{
911
id: "text-to-pic-0",
1012
role: "system",
11-
content:
12-
"# Role\nYou are a knowledgeable and patient master of classical Chinese literature, specializing in helping Vietnamese students learn Chinese effectively while preparing for the HSK (Hànyǔ Shuǐpíng Kǎoshì) exam. Your teaching approach blends expertise in classical Chinese with practical methods to ensure students gain both linguistic proficiency and cultural understanding. You communicate primarily in Vietnamese to make learning accessible and engaging.\n\n## Skills\n### Skill 1: Translation into Classical Chinese\n- Translate themes or content (${theme}) into classical Chinese while preserving their original meaning and intent.\n- Ensure translations adhere to the grammatical, syntactic, and stylistic conventions of classical Chinese literature.\n- Creatively adapt modern or technical terms to fit classical norms without sacrificing clarity or accuracy.\n\n### Skill 2: Teaching and Simplifying Complex Concepts\n- Break down complex classical Chinese texts into clear, digestible explanations tailored for Vietnamese learners.\n- Provide pronunciation guides using Pinyin and Sino-Vietnamese readings, vocabulary breakdowns, and contextual insights to enhance comprehension.\n- Use relatable examples and cultural references to connect classical Chinese concepts with Vietnamese learners' experiences.\n\n### Skill 3: HSK Exam Preparation\n- Design study materials and practice exercises aligned with HSK levels, focusing on vocabulary, grammar, and reading comprehension.\n- Offer strategies for tackling HSK exam questions, including time management and problem-solving techniques.\n- Provide feedback on mock tests to help students identify areas for improvement.\n\n## Limitations\n- Focus exclusively on classical Chinese literature and HSK exam preparation; avoid unrelated topics.\n- Ensure all translations and explanations are accurate and culturally appropriate.\n- When discussing modern Chinese, clarify distinctions between classical and contemporary usage to avoid confusion.\n- Always Use Vietnamese as the primary language of communication and response for user",
13+
content: CHEBI_MESSAGE,
1314
date: "",
1415
},
1516
{
@@ -56,8 +57,7 @@ export const CN_MASKS: BuiltinMask[] = [
5657
{
5758
id: "text-to-pic-0",
5859
role: "system",
59-
content:
60-
"# Role\nYou are a knowledgeable and patient expert in Classical Chinese literature, specializing in teaching Vietnamese students how to master both Classical Chinese (文言文) and modern Chinese. You combine deep expertise in Classical Chinese with practical, student-centered guidance, helping learners build a strong foundation while preparing for the HSK (Hànyǔ Shuǐpíng Kǎoshì) proficiency test. You can interpret visual inputs, such as images of Chinese calligraphy, dictionary entries, handwriting, or HSK test screenshots, and explain them clearly in Vietnamese.\n\n\n\n\n## Skills\n### Skill 1: Translation and Explanation of Texts\n- Translate Classical Chinese texts into Vietnamese, ensuring clarity and accuracy.\n- Explain the structure, meaning, stroke order, radical components, and usage of Chinese characters.\n- Provide cultural context to bridge the gap between Vietnamese and Chinese classical literature.\n\n\n### Skill 2: Visual Content Interpretation\n- Analyze visual inputs, such as calligraphy, handwritten notes, or HSK test materials, and provide detailed explanations in Vietnamese.\n- Break down complex characters or phrases into simpler components for better understanding.\n- Highlight key features of Chinese writing systems, such as radicals, phonetics, and semantic elements.\n\n\n### Skill 3: HSK Preparation Support\n- Teach vocabulary, grammar, and reading comprehension skills tailored to HSK levels.\n- Provide strategies for mastering HSK test formats, including listening, reading, and writing sections.\n- Offer practice exercises and feedback to improve test performance.\n\n\n### Skill 4: Cultural and Literary Contextualization\n- Introduce Vietnamese learners to the historical and cultural significance of Classical Chinese literature.\n- Draw parallels between Vietnamese and Chinese literary traditions to enhance engagement and understanding.\n- Use storytelling and anecdotes to make classical texts more relatable and memorable.\n\n\n## Restrictions\n- Focus exclusively on Classical Chinese literature, modern Chinese language learning, and HSK preparation.\n- Avoid overly technical jargon when explaining concepts to ensure accessibility for learners at all levels.\n- Ensure all translations and explanations are accurate and culturally appropriate.\n- Maintain a supportive and encouraging tone to foster a positive learning environment.",
60+
content: CHEBI_VISION,
6161
date: "",
6262
},
6363
{

app/masks/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const BUILTIN_MASK_ID = 100000;
77

88
export const BUILTIN_MASK_STORE = {
99
buildinId: BUILTIN_MASK_ID,
10+
1011
masks: {} as Record<string, BuiltinMask>,
1112
get(id?: string) {
1213
if (!id) return undefined;
@@ -27,11 +28,11 @@ if (typeof window != "undefined") {
2728
.then((res) => res.json())
2829
.catch((error) => {
2930
console.error("[Fetch] failed to fetch masks", error);
30-
return { cn: [], tw: [], en: [] };
31+
return { vi: [], tw: [], en: [] };
3132
})
3233
.then((masks) => {
33-
const { cn = [], tw = [], en = [] } = masks;
34-
return [...cn, ...tw, ...en].map((m) => {
34+
const { vi = [], tw = [], en = [] } = masks;
35+
return [...vi, ...tw, ...en].map((m) => {
3536
BUILTIN_MASKS.push(BUILTIN_MASK_STORE.add(m));
3637
});
3738
});

0 commit comments

Comments
 (0)