Skip to content

Commit

Permalink
Perf: i18n change and captcha code. (#2625)
Browse files Browse the repository at this point in the history
* perf: send captcha check

* perf: back router

* perf: i18n init

* perf: ui

* i18n

* perf: ui duration
  • Loading branch information
c121914yu authored Sep 5, 2024
1 parent 478386c commit c614f8b
Show file tree
Hide file tree
Showing 43 changed files with 259 additions and 793 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"js",
"ts"
],
"i18n-ally.keystyle": "nested",
"i18n-ally.keystyle": "flat",
"i18n-ally.sortKeys": true,
"i18n-ally.keepFulfilled": false,
"i18n-ally.sourceLanguage": "zh", // 根据此语言文件翻译其他语言文件的变量和内容
Expand Down
61 changes: 32 additions & 29 deletions docSite/content/zh-cn/docs/development/upgrading/4810.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,35 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4810' \
7. 新增 - 应用调用迁移成单独节点,同时可以传递全局变量和用户的文件。
8. 新增 - 插件增加使用说明配置。
9. 新增 - 工作流导出导入,支持直接导出和导入 JSON 文件,便于交流。
10. 商业版新增 - 飞书机器人接入
11. 商业版新增 - 公众号接入接入
12. 商业版新增 - 自助开票申请
13. 商业版新增 - SSO 定制
14. 优化 - 工作流循环校验,避免 skip 循环空转。同时支持分支完全并发执行。
15. 优化 - SSE 响应优化。
16. 优化 - 无 SSL 证书情况下,优化复制。
17. 优化 - 单选框打开后自动滚动到选中的位置。
18. 优化 - 知识库集合禁用,目录禁用会递归修改其下所有 children 的禁用状态。
19. 优化 - 节点选择,避免切换 tab 时候,path 加载报错。
20. 优化 - 最新 React Markdown 组件,支持 Base64 图片。
21. 优化 - 知识库列表 UI。
22. 优化 - 知识库详情页 UI。
23. 优化 - 支持无网络配置情况下运行。
24. 优化 - 部分全局变量,增加数据类型约束。
25. 优化 - 查看工作流详情,切换 tab 时,自动滚动到顶部。
26. 修复 - 全局变量 key 可能重复。
27. 修复 - Prompt 模式调用工具,stream=false 模式下,会携带 0: 开头标记。
28. 修复 - 对话日志鉴权问题:仅为 APP 管理员的用户,无法查看对话日志详情。
29. 修复 - 选择 Milvus 部署时,无法导出知识库。
30. 修复 - 创建 APP 副本,无法复制系统配置。
31. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
32. 修复 - 内容提取的数据类型与输出数据类型未一致。
33. 修复 - 工作流运行时间统计错误。
34. 修复 - stream 模式下,工具调用有可能出现 undefined
35. 修复 - 全局变量在 API 中无法持久化。
36. 修复 - OpenAPI,detail=false模式下,不应该返回 tool 调用结果,仅返回文字。(可解决 cow 不适配问题)
37. 修复 - 知识库标签重复加载。
38. 修复 - Debug 模式下,循环调用边问题。
10. 新增 - HTTP模块支持超时配置、支持更多的 Body 类型,params 和 headers 支持新的变量选择模式。
11. 新增 - 发送验证码安全校验。
12. 商业版新增 - 飞书机器人接入
13. 商业版新增 - 公众号接入接入
14. 商业版新增 - 自助开票申请
15. 商业版新增 - SSO 定制
16. 优化 - 工作流循环校验,避免 skip 循环空转。同时支持分支完全并发执行。
17. 优化 - SSE 响应优化。
18. 优化 - 无 SSL 证书情况下,优化复制。
19. 优化 - 单选框打开后自动滚动到选中的位置。
20. 优化 - 知识库集合禁用,目录禁用会递归修改其下所有 children 的禁用状态。
21. 优化 - 节点选择,避免切换 tab 时候,path 加载报错。
22. 优化 - 最新 React Markdown 组件,支持 Base64 图片。
23. 优化 - 知识库列表 UI。
24. 优化 - 知识库详情页 UI。
25. 优化 - 支持无网络配置情况下运行。
26. 优化 - 部分全局变量,增加数据类型约束。
27. 优化 - 查看工作流详情,切换 tab 时,自动滚动到顶部。
28. 优化 - 对话框性能问题。
29. 修复 - 全局变量 key 可能重复。
30. 修复 - Prompt 模式调用工具,stream=false 模式下,会携带 0: 开头标记。
31. 修复 - 对话日志鉴权问题:仅为 APP 管理员的用户,无法查看对话日志详情。
32. 修复 - 选择 Milvus 部署时,无法导出知识库。
33. 修复 - 创建 APP 副本,无法复制系统配置。
34. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
35. 修复 - 内容提取的数据类型与输出数据类型未一致。
36. 修复 - 工作流运行时间统计错误。
37. 修复 - stream 模式下,工具调用有可能出现 undefined
38. 修复 - 全局变量在 API 中无法持久化。
39. 修复 - OpenAPI,detail=false模式下,不应该返回 tool 调用结果,仅返回文字。(可解决 cow 不适配问题)
40. 修复 - 知识库标签重复加载。
41. 修复 - Debug 模式下,循环调用边问题。
7 changes: 6 additions & 1 deletion packages/service/common/vectorStore/pg/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class PgVectorCtrl {
const { teamId, datasetId, collectionId, vector, retry = 3 } = props;

try {
const { rows } = await PgClient.insert(DatasetVectorTableName, {
const { rowCount, rows } = await PgClient.insert(DatasetVectorTableName, {
values: [
[
{ key: 'vector', value: `[${vector}]` },
Expand All @@ -58,6 +58,11 @@ export class PgVectorCtrl {
]
]
});

if (rowCount === 0) {
return Promise.reject('insertDatasetData: no insert');
}

return {
insertId: rows[0].id
};
Expand Down
45 changes: 45 additions & 0 deletions packages/web/hooks/useI18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Cookies, { CookieAttributes } from 'js-cookie';
import { useTranslation } from 'next-i18next';

const setCookie = (key: string, value: string, options?: CookieAttributes) => {
Cookies.set(key, value, options);
};
const getCookie = (key: string) => {
return Cookies.get(key);
};

const LANG_KEY = 'NEXT_LOCALE';

export const useI18nLng = () => {
const { i18n } = useTranslation();

const onChangeLng = (lng: string) => {
setCookie(LANG_KEY, lng, {
expires: 30,
sameSite: 'None',
secure: true
});
i18n?.changeLanguage(lng);
};

const setUserDefaultLng = () => {
if (!navigator || !localStorage) return;
if (getCookie(LANG_KEY)) return onChangeLng(getCookie(LANG_KEY) as string);

const languageMap = {
zh: 'zh',
'zh-CN': 'zh'
};

// @ts-ignore
const lang = languageMap[navigator.language] || 'en';

// currentLng not in userLang
return onChangeLng(lang);
};

return {
onChangeLng,
setUserDefaultLng
};
};
9 changes: 2 additions & 7 deletions packages/web/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"version_initial_copy": "Duplicate - Original State",
"version_name_tips": "Version name cannot be empty",
"version_past": "Previously Published",
"version_publish_tips": "This version will be saved to the team cloud, synchronized with the entire team, and update the app version on all release channels.",
"version_save_tips": "This version will be saved to the team cloud, synchronized with the entire team."
"version_publish_tips": "This version will be saved to the team cloud, synchronized with the entire team, and update the app version on all release channels."
},
"app_detail": "Application Details",
"chat_debug": "Chat Preview",
Expand Down Expand Up @@ -138,13 +137,11 @@
"Create plugin bot": "Create Plugin",
"Create simple bot": "Create Simple App",
"Create simple bot tip": "Create a simple AI app by filling out a form, suitable for beginners.",
"Create template tip": "Explore more features in the template market to help you understand and get started with various applications.",
"Create workflow bot": "Create Workflow",
"Create workflow tip": "Build complex multi-turn dialogue AI applications through low-code methods, recommended for advanced users.",
"Http plugin": "HTTP Plugin",
"Plugin": "Plugin",
"Simple bot": "Simple App",
"Template": "Create via Template",
"Workflow bot": "Workflow"
},
"upload_file_max_amount": "Maximum File Quantity",
Expand All @@ -169,8 +166,6 @@
"workflow": {
"Input guide": "Input Guide",
"file_url": "Document Link",
"option1": "Option 1",
"option2": "Option 2",
"read_files": "Document Parsing",
"read_files_result": "Document Parsing Result",
"read_files_result_desc": "Original document text, consisting of file names and document content, separated by hyphens between multiple files.",
Expand All @@ -187,4 +182,4 @@
"user_select": "User Selection",
"user_select_tip": "This module can configure multiple options for selection during the dialogue. Different options can lead to different workflow branches."
}
}
}
4 changes: 1 addition & 3 deletions packages/web/i18n/en/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
"items": "Items",
"module_runtime_and": "Total Module Runtime",
"multiple_AI_conversations": "Multiple AI Conversations",
"new_chat": "New Conversation",
"new_input_guide_lexicon": "New Lexicon",
"no_workflow_response": "No workflow data",
"plugins_output": "Plugin Output",
"question_tip": "From top to bottom, the response order of each module",
"rearrangement": "Rearrangement of Retrieval Results",
"response": {
"node_inputs": "Node Inputs"
},
Expand All @@ -38,4 +36,4 @@
"stream_output": "Stream Output",
"view_citations": "View References",
"web_site_sync": "Web Site Sync"
}
}
Loading

0 comments on commit c614f8b

Please sign in to comment.