@lobehub/chat 0.94.4 → 0.94.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.94.5](https://github.com/lobehub/lobe-chat/compare/v0.94.4...v0.94.5)
6
+
7
+ <sup>Released on **2023-10-22**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fallback agent market index to en when not find correct locale.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fallback agent market index to en when not find correct locale, closes [#355](https://github.com/lobehub/lobe-chat/issues/355) ([7a45ab4](https://github.com/lobehub/lobe-chat/commit/7a45ab4))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.94.4](https://github.com/lobehub/lobe-chat/compare/v0.94.3...v0.94.4)
6
31
 
7
32
  <sup>Released on **2023-10-21**</sup>
@@ -0,0 +1,88 @@
1
+ # Lobe Chat - Contributing Guide 🌟
2
+
3
+ We're thrilled that you want to contribute to Lobe Chat, the future of communication! 😄
4
+
5
+ Lobe Chat is an open-source project, and we welcome your collaboration. Before you jump in, let's make sure you're all set to contribute effectively and have loads of fun along the way!
6
+
7
+ ## Table of Contents
8
+
9
+ - [Fork the Repository](#fork-the-repository)
10
+ - [Clone Your Fork](#clone-your-fork)
11
+ - [Create a New Branch](#create-a-new-branch)
12
+ - [Code Like a Wizard](#code-like-a-wizard)
13
+ - [Committing Your Work](#committing-your-work)
14
+ - [Sync with Upstream](#sync-with-upstream)
15
+ - [Open a Pull Request](#open-a-pull-request)
16
+ - [Review and Collaboration](#review-and-collaboration)
17
+ - [Celebrate 🎉](#celebrate-)
18
+
19
+ ## Fork the Repository
20
+
21
+ 🍴 Fork this repository to your GitHub account by clicking the "Fork" button at the top right. This creates a personal copy of the project you can work on.
22
+
23
+ ## Clone Your Fork
24
+
25
+ 📦 Clone your forked repository to your local machine using the `git clone` command:
26
+
27
+ ```bash
28
+ git clone https://github.com/YourUsername/lobe-chat.git
29
+ ```
30
+
31
+ ## Create a New Branch
32
+
33
+ 🌿 Create a new branch for your contribution. This helps keep your work organized and separate from the main codebase.
34
+
35
+ ```bash
36
+ git checkout -b your-branch-name
37
+ ```
38
+
39
+ Choose a meaningful branch name related to your work. It makes collaboration easier!
40
+
41
+ ## Code Like a Wizard
42
+
43
+ 🧙‍♀️ Time to work your magic! Write your code, fix bugs, or add new features. Be sure to follow our project's coding style. You can check if your code adheres to our style using:
44
+
45
+ ```bash
46
+ yarn lint
47
+ ```
48
+
49
+ This adds a bit of enchantment to your coding experience! ✨
50
+
51
+ ## Committing Your Work
52
+
53
+ 📝 Ready to save your progress? Commit your changes to your branch.
54
+
55
+ ```bash
56
+ git add .
57
+ git commit -m "Your meaningful commit message"
58
+ ```
59
+
60
+ Please keep your commits focused and clear. And remember to be kind to your fellow contributors; keep your commits concise.
61
+
62
+ ## Sync with Upstream
63
+
64
+ ⚙️ Periodically, sync your forked repository with the original (upstream) repository to stay up-to-date with the latest changes.
65
+
66
+ ```bash
67
+ git remote add upstream https://github.com/lobehub/lobe-chat.git
68
+ git fetch upstream
69
+ git merge upstream/main
70
+ ```
71
+
72
+ This ensures you're working on the most current version of Lobe Chat. Stay fresh! 💨
73
+
74
+ ## Open a Pull Request
75
+
76
+ 🚀 Time to share your contribution! Head over to the original Lobe Chat repository and open a Pull Request (PR). Our maintainers will review your work.
77
+
78
+ ## Review and Collaboration
79
+
80
+ 👓 Your PR will undergo thorough review and testing. The maintainers will provide feedback, and you can collaborate to make your contribution even better. We value teamwork!
81
+
82
+ ## Celebrate 🎉
83
+
84
+ 🎈 Congratulations! Your contribution is now part of Lobe Chat. 🥳
85
+
86
+ Thank you for making Lobe Chat even more magical. We can't wait to see what you create! 🌠
87
+
88
+ Happy Coding! 🚀🦄
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.94.4",
3
+ "version": "0.94.5",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -1,32 +1,12 @@
1
- import { cookies } from 'next/headers';
2
-
3
- import { LOBE_LOCALE_COOKIE } from '@/const/locale';
4
- import { getAgentIndexJSON } from '@/const/url';
5
- import { Locales } from '@/locales/resources';
6
- import { LobeChatAgentsMarketIndex } from '@/types/market';
7
1
  import { isMobileDevice } from '@/utils/responsive';
8
2
 
9
3
  import DesktopPage from './(desktop)';
10
4
  import MobilePage from './(mobile)';
11
5
 
12
- const getAgentList = async (): Promise<LobeChatAgentsMarketIndex> => {
13
- const cookieStore = cookies();
14
- const lang = cookieStore.get(LOBE_LOCALE_COOKIE);
15
-
16
- try {
17
- const res = await fetch(getAgentIndexJSON(lang?.value as Locales));
18
-
19
- return await res.json();
20
- } catch {
21
- return { agents: [], schemaVersion: 1 };
22
- }
23
- };
24
-
25
- export default async () => {
26
- const data = await getAgentList();
6
+ export default () => {
27
7
  const mobile = isMobileDevice();
28
8
 
29
9
  const Page = mobile ? MobilePage : DesktopPage;
30
10
 
31
- return <Page defaultAgents={data.agents} />;
11
+ return <Page />;
32
12
  };
@@ -1,3 +1,4 @@
1
+ import { getCurrentLanguage } from '@/store/global/helpers';
1
2
  import { OpenAIChatStreamPayload } from '@/types/openai/chat';
2
3
 
3
4
  /**
@@ -7,24 +8,28 @@ import { OpenAIChatStreamPayload } from '@/types/openai/chat';
7
8
  export const chainSummaryAgentName = (content: string): Partial<OpenAIChatStreamPayload> => ({
8
9
  messages: [
9
10
  {
10
- content: `你是一名擅长起名的起名大师,名字需要有文学内涵,注重精炼和赋子意境,你需要将用户的描述总结为 20 个字以内的角色, 格式要求如下:\n输入: {文本作为JSON引用字符串}\n输出: {角色名}`,
11
+ content: `你是一名擅长起名的起名大师,名字需要有文学内涵,注重精炼和赋子意境,你需要将用户的描述总结为 10 个字以内的角色,并翻译为目标语言。格式要求如下:\n输入: {文本作为JSON引用字符串} [locale]\n输出: {角色名}`,
11
12
  role: 'system',
12
13
  },
13
14
  {
14
- content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。}`,
15
+ content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。} [zh-CN]`,
15
16
  role: 'user',
16
17
  },
17
- { content: '创意命名师', role: 'assistant' },
18
18
  {
19
- content: `输入: {你是一名前端代码专家,请将下面的代码转成 ts,不要修改实现。如果原本 js 中没有定义的全局变量,需要补充 declare 的类型声明。}`,
19
+ content: `输入: {你是一名 UX Writer,擅长将平平无奇的描述转换为精妙的表达。接下来用户会输入一段文本,你需要转成更加棒的表述方式,长度不超过40个字。} [ru-RU]`,
20
20
  role: 'user',
21
21
  },
22
- { content: 'ts转换魔术师', role: 'assistant' },
22
+ { content: 'Творческий редактор UX', role: 'assistant' },
23
23
  {
24
- content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。}`,
24
+ content: `输入: {你是一名前端代码专家,请将下面的代码转成 ts,不要修改实现。如果原本 js 中没有定义的全局变量,需要补充 declare 的类型声明。} [en-US]`,
25
25
  role: 'user',
26
26
  },
27
- { content: '创业咨询专家', role: 'assistant' },
28
- { content: `输入: {${content}}`, role: 'user' },
27
+ { content: 'TS Transformer', role: 'assistant' },
28
+ {
29
+ content: `输入: {Improve my English language use by replacing basic A0-level expressions with more sophisticated, advanced-level phrases while maintaining the conversation's essence. Your responses should focus solely on corrections and enhancements, avoiding additional explanations.} [zh-CN]`,
30
+ role: 'user',
31
+ },
32
+ { content: '邮件优化助理', role: 'assistant' },
33
+ { content: `输入: {${content}} [${getCurrentLanguage()}]`, role: 'user' },
29
34
  ],
30
35
  });
@@ -1,26 +1,49 @@
1
+ import { getCurrentLanguage } from '@/store/global/helpers';
1
2
  import { OpenAIChatStreamPayload } from '@/types/openai/chat';
2
3
 
3
4
  export const chainSummaryDescription = (content: string): Partial<OpenAIChatStreamPayload> => ({
4
5
  messages: [
5
6
  {
6
- content: `你是一名擅长技能总结的助理,你需要将用户的输入的内容总结为一个角色技能简介,确保信息清晰、逻辑清晰,并有效地传达角色的技能和经验,不超过 20 个字, 格式要求如下:\n输入: {文本作为JSON引用字符串}\n输出: {角色技能简介}`,
7
+ content: `你是一名擅长技能总结的助理,你需要将用户的输入的内容总结为一个角色技能简介,不超过 20 个字。内容需要确保信息清晰、逻辑清晰,并有效地传达角色的技能和经验,需要并翻译为目标语言:${getCurrentLanguage()}。格式要求如下:\n输入: {文本作为JSON引用字符串} [locale]\n输出: {简介}`,
7
8
  role: 'system',
8
9
  },
9
10
  {
10
- content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。}`,
11
+ content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。} [zh-CN]`,
11
12
  role: 'user',
12
13
  },
13
14
  { content: '擅长文创艺术作品起名', role: 'assistant' },
14
15
  {
15
- content: `输入: {你是一名前端代码专家,请将下面的代码转成 ts,不要修改实现。如果原本 js 中没有定义的全局变量,需要补充 declare 的类型声明。}`,
16
+ content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。} [en-US]`,
17
+ role: 'user',
18
+ },
19
+ { content: 'Good at business plan writing and consulting', role: 'assistant' },
20
+ {
21
+ content: `输入: {You are a frontend expert. Please convert the code below to TS without modifying the implementation. If there are global variables not defined in the original JS, you need to add type declarations using declare.} [zh-CN]`,
16
22
  role: 'user',
17
23
  },
18
24
  { content: '擅长 ts 转换和补充类型声明', role: 'assistant' },
19
25
  {
20
- content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。}`,
26
+ content: `输入: {
27
+ 用户正常书写面向开发者的 API 用户使用文档。你需要从用户的视角来提供比较易用易读的文档内容。\n\n一个标准的 API 文档示例如下:\n\n\`\`\`markdown
28
+ ---
29
+ title: useWatchPluginMessage
30
+ description: 监听获取 LobeChat 发过来的插件消息
31
+ nav: API
32
+ ---\n\n\`useWatchPluginMessage\` 是 Chat Plugin SDK 封装一个的 React Hook,用于监听从 LobeChat 发过来的插件消息。
33
+ } [ru-RU]`,
34
+ role: 'user',
35
+ },
36
+ {
37
+ content:
38
+ 'Специализируется на создании хорошо структурированной и профессиональной документации README для GitHub с точными техническими терминами',
39
+ role: 'assistant',
40
+ },
41
+ {
42
+ content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。} [zh-CN]`,
21
43
  role: 'user',
22
44
  },
23
45
  { content: '擅长创业计划撰写与咨询', role: 'assistant' },
24
- { content: `输入: {${content}}`, role: 'user' },
46
+ { content: `输入: {${content}} [${getCurrentLanguage()}]`, role: 'user' },
25
47
  ],
48
+ temperature: 0,
26
49
  });
@@ -1,27 +1,28 @@
1
+ import { getCurrentLanguage } from '@/store/global/helpers';
1
2
  import { OpenAIChatStreamPayload } from '@/types/openai/chat';
2
3
 
3
4
  export const chainSummaryTags = (content: string): Partial<OpenAIChatStreamPayload> => ({
4
5
  messages: [
5
6
  {
6
7
  content:
7
- '你是一名擅长会话标签总结的助理,你需要将用户的输入的内容提炼出分类标签,使用`,`分隔,不超过 5 个标签, 格式要求如下:\n输入: {文本作为JSON引用字符串}\n输出: {角色名}',
8
+ '你是一名擅长会话标签总结的助理,你需要将用户的输入的内容提炼出分类标签,使用`,`分隔,不超过 5 个标签,并翻译为目标语言。 格式要求如下:\n输入: {文本作为JSON引用字符串} [locale]\n输出: {标签}',
8
9
  role: 'system',
9
10
  },
10
11
  {
11
- content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。}`,
12
+ content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。} [zh-CN]`,
12
13
  role: 'user',
13
14
  },
14
15
  { content: '起名,写作,创意', role: 'assistant' },
15
16
  {
16
- content: `输入: {你是一名前端专家,请将下面的代码转成 ts,不要修改实现。如果原本 js 中没有定义的全局变量,需要补充 declare 的类型声明。}`,
17
+ content: `输入: {You are a professional translator proficient in Simplified Chinese, and have participated in the translation work of the Chinese versions of The New York Times and The Economist. Therefore, you have a deep understanding of translating news and current affairs articles. I hope you can help me translate the following English news paragraphs into Chinese, with a style similar to the Chinese versions of the aforementioned magazines.} [zh-CN]`,
17
18
  role: 'user',
18
19
  },
19
- { content: '代码,软件开发,效率', role: 'assistant' },
20
+ { content: '翻译,写作,文案', role: 'assistant' },
20
21
  {
21
- content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。}`,
22
+ content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。} [en-US]`,
22
23
  role: 'user',
23
24
  },
24
- { content: '创业,计划,咨询', role: 'assistant' },
25
- { content: `输入: {${content}}`, role: 'user' },
25
+ { content: 'entrepreneurship,planning,consulting', role: 'assistant' },
26
+ { content: `输入: {${content}} [${getCurrentLanguage()}]`, role: 'user' },
26
27
  ],
27
28
  });
@@ -1,3 +1,4 @@
1
+ import { getCurrentLanguage } from '@/store/global/helpers';
1
2
  import { chatHelpers } from '@/store/session/slices/chat/helpers';
2
3
  import { LanguageModel } from '@/types/llm';
3
4
  import { OpenAIChatMessage, OpenAIChatStreamPayload } from '@/types/openai/chat';
@@ -5,16 +6,17 @@ import { OpenAIChatMessage, OpenAIChatStreamPayload } from '@/types/openai/chat'
5
6
  export const chainSummaryTitle = async (
6
7
  messages: OpenAIChatMessage[],
7
8
  ): Promise<Partial<OpenAIChatStreamPayload>> => {
9
+ const lang = getCurrentLanguage();
10
+
8
11
  const finalMessages: OpenAIChatMessage[] = [
9
12
  {
10
- content:
11
- '你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,不需要包含标点符号',
13
+ content: '你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题',
12
14
  role: 'system',
13
15
  },
14
16
  {
15
17
  content: `${messages.map((message) => `${message.role}: ${message.content}`).join('\n')}
16
18
 
17
- 请总结上述对话为10个字以内的标题,不需要包含标点符号`,
19
+ 请总结上述对话为10个字以内的标题,不需要包含标点符号,输出语言语种为:${lang}`,
18
20
  role: 'user',
19
21
  },
20
22
  ];
@@ -1,14 +1,18 @@
1
1
  import { getAgentIndexJSON, getAgentJSON } from '@/const/url';
2
- import { settingsSelectors, useGlobalStore } from '@/store/global';
2
+ import { getCurrentLanguage } from '@/store/global/helpers';
3
3
  import { LobeChatAgentsMarketIndex } from '@/types/market';
4
4
 
5
5
  /**
6
6
  * 请求助手列表
7
7
  */
8
8
  export const getAgentList = async () => {
9
- const res = await fetch(
10
- getAgentIndexJSON(settingsSelectors.currentLanguage(useGlobalStore.getState())),
11
- );
9
+ let res: Response;
10
+
11
+ res = await fetch(getAgentIndexJSON(getCurrentLanguage()));
12
+
13
+ if (res.status === 404) {
14
+ res = await fetch(getAgentIndexJSON('en-US'));
15
+ }
12
16
 
13
17
  const data: LobeChatAgentsMarketIndex = await res.json();
14
18
 
@@ -20,9 +24,7 @@ export const getAgentList = async () => {
20
24
  */
21
25
  export const getAgentManifest = async (identifier?: string) => {
22
26
  if (!identifier) return;
23
- const res = await fetch(
24
- getAgentJSON(identifier, settingsSelectors.currentLanguage(useGlobalStore.getState())),
25
- );
27
+ const res = await fetch(getAgentJSON(identifier, getCurrentLanguage()));
26
28
 
27
29
  return res.json();
28
30
  };
@@ -1,11 +1,11 @@
1
1
  import { getPluginIndexJSON } from '@/const/url';
2
- import { settingsSelectors, useGlobalStore } from '@/store/global';
2
+ import { getCurrentLanguage } from '@/store/global/helpers';
3
3
 
4
4
  /**
5
5
  * fetch Plugin Market List
6
6
  */
7
7
  export const getPluginList = async () => {
8
- const url = getPluginIndexJSON(settingsSelectors.currentLanguage(useGlobalStore.getState()));
8
+ const url = getPluginIndexJSON(getCurrentLanguage());
9
9
 
10
10
  const res = await fetch(url);
11
11
 
@@ -0,0 +1,5 @@
1
+ import { settingsSelectors } from './selectors';
2
+ import { useGlobalStore } from './store';
3
+
4
+ export const getCurrentLanguage = () =>
5
+ settingsSelectors.currentLanguage(useGlobalStore.getState());
@@ -36,6 +36,7 @@ export const exportSettings = (s: GlobalStore) => {
36
36
 
37
37
  const currentLanguage = (s: GlobalStore) => {
38
38
  const locale = s.settings.language;
39
+
39
40
  if (locale === 'auto') {
40
41
  if (isOnServerSide) return DEFAULT_LANG;
41
42