@lobehub/chat 0.96.8 → 0.96.9

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.
Files changed (59) hide show
  1. package/.github/workflows/release.yml +3 -0
  2. package/CHANGELOG.md +25 -0
  3. package/CODE_OF_CONDUCT.md +21 -21
  4. package/CONTRIBUTING.md +1 -1
  5. package/README.md +26 -9
  6. package/README.zh-CN.md +29 -12
  7. package/docs/Deploy-with-Azure-OpenAI.md +6 -6
  8. package/docs/Home.md +14 -2
  9. package/docs/Lighthouse.md +8 -8
  10. package/docs/Plugin-Development.md +3 -3
  11. package/docs/Plugin-Development.zh-CN.md +3 -3
  12. package/docs/Usage-Agents.md +195 -0
  13. package/docs/Usage-Agents.zh-CN.md +196 -0
  14. package/docs/Usage-Topics.md +31 -0
  15. package/docs/Usage-Topics.zh-CN.md +31 -0
  16. package/docs/_Sidebar.md +10 -2
  17. package/locales/en_US/chat.json +8 -2
  18. package/locales/ja_JP/chat.json +7 -1
  19. package/locales/ko_KR/chat.json +7 -1
  20. package/locales/ru_RU/chat.json +7 -1
  21. package/locales/zh_CN/chat.json +5 -1
  22. package/locales/zh_TW/chat.json +7 -1
  23. package/next.config.mjs +9 -1
  24. package/package.json +6 -7
  25. package/scripts/readmeWorkflow/const.ts +19 -0
  26. package/scripts/readmeWorkflow/index.ts +12 -0
  27. package/scripts/readmeWorkflow/syncAgentIndex.ts +47 -0
  28. package/scripts/readmeWorkflow/syncPluginIndex.ts +43 -0
  29. package/scripts/readmeWorkflow/utlis.ts +52 -0
  30. package/src/app/chat/(desktop)/features/ChatHeader.tsx +11 -1
  31. package/src/app/chat/(desktop)/features/SessionList.tsx +1 -1
  32. package/src/app/chat/(desktop)/features/SideBar.tsx +1 -1
  33. package/src/app/chat/(mobile)/features/ChatHeader.tsx +2 -6
  34. package/src/app/chat/(mobile)/features/TopicList.tsx +1 -1
  35. package/src/app/chat/features/Conversation/ChatList/Actions/Error.tsx +1 -7
  36. package/src/app/chat/features/Conversation/ChatList/Actions/User.tsx +0 -1
  37. package/src/app/chat/features/Conversation/ChatList/Actions/index.ts +48 -0
  38. package/src/app/chat/features/Conversation/ChatList/Messages/index.ts +27 -0
  39. package/src/app/chat/features/Conversation/ChatList/index.tsx +7 -29
  40. package/src/app/chat/features/{TopicListContent/SystemRole/Header.tsx → SidebarHeader/index.tsx} +9 -8
  41. package/src/app/chat/features/{TopicListContent/SystemRole → SystemRole}/index.tsx +45 -16
  42. package/src/app/chat/features/TopicListContent/Header.tsx +86 -0
  43. package/src/app/chat/features/TopicListContent/Topic/SkeletonList.tsx +1 -1
  44. package/src/app/chat/features/TopicListContent/TopicSearchBar/index.tsx +8 -3
  45. package/src/app/chat/features/TopicListContent/index.tsx +18 -7
  46. package/src/app/settings/features/SideBar/index.tsx +1 -1
  47. package/src/features/AgentInfo/index.tsx +3 -1
  48. package/src/features/AgentSetting/AgentMeta/index.tsx +5 -1
  49. package/src/features/PluginDevModal/MetaForm.tsx +4 -3
  50. package/src/layout/GlobalLayout/Locale.tsx +12 -2
  51. package/src/locales/default/chat.ts +5 -1
  52. package/src/store/global/initialState.ts +2 -0
  53. package/src/store/global/slices/common.ts +7 -0
  54. package/src/store/session/slices/chat/actions/topic.ts +30 -0
  55. package/src/store/session/slices/chat/selectors/index.ts +2 -1
  56. package/src/store/session/slices/chat/selectors/topic.ts +4 -0
  57. package/src/components/EmojiPicker/index.tsx +0 -56
  58. package/src/components/EmojiPicker/style.ts +0 -30
  59. /package/src/app/chat/features/{TopicListContent/SystemRole → SystemRole}/style.ts +0 -0
@@ -0,0 +1,195 @@
1
+ # Custom Agents Guide
2
+
3
+ #### TOC
4
+
5
+ - [Adding Custom Agents](#adding-custom-agents)
6
+ - [`A` Add through the Agent Marketplace](#a-add-through-the-agent-marketplace)
7
+ - [`B` Create a Custom Agent](#b-create-a-custom-agent)
8
+ - [Basic Concepts of Prompts](#basic-concepts-of-prompts)
9
+ - [How to write a structured prompt](#how-to-write-a-structured-prompt)
10
+ - [How to improve quality and effectiveness](#how-to-improve-quality-and-effectiveness)
11
+ - [Model Concepts](#model-concepts)
12
+ - [ChatGPT](#chatgpt)
13
+ - [Model Parameter Concepts](#model-parameter-concepts)
14
+ - [`temperature`](#temperature)
15
+ - [`top_p`](#top_p)
16
+ - [`presence_penalty`](#presence_penalty)
17
+ - [`frequency_penalty`](#frequency_penalty)
18
+ - [Further Reading](#further-reading)
19
+
20
+ ## Adding Custom Agents
21
+
22
+ As the fundamental unit of LobeChat, adding and iterating on agents is crucial. Now you can add agents to your favorites list in two ways:
23
+
24
+ ### `A` Add through the Agent Marketplace
25
+
26
+ If you're new to writing prompts, you might want to browse the Agent Marketplace in LobeChat. Here, you can find commonly used agents submitted by others and add them to your list with just one click, making it very convenient.
27
+
28
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279588466-4c32041b-a8e6-4703-ba4a-f91b7800e359.png)
29
+
30
+ ### `B` Create a Custom Agent
31
+
32
+ When you need to handle specific tasks, you'll want to consider creating a custom agent to help you solve the problem. You can add and configure the agent in detail using the following steps:
33
+
34
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587283-a3ea8dfd-70fb-47ee-ab00-e3911ac6a939.png)
35
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587292-a3d102c6-f61e-4578-91f1-c0a4c97588e1.png)
36
+
37
+ > **Note**\
38
+ > Quick setting tip: You can conveniently modify the prompt by using the quick edit button in the sidebar.
39
+
40
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587294-388d1877-193e-4a50-9fe8-8fbcc3ccefa0.png)
41
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587298-333da153-13b8-4557-a0a2-cff55e7bc1c0.png)
42
+
43
+ Continue reading to understand the writing techniques and common model parameter settings for prompts.
44
+
45
+ <br/>
46
+
47
+ ## Basic Concepts of Prompts
48
+
49
+ Generative AI is very useful, but it requires human guidance. In most cases, generative AI is like a capable intern who needs clear instructions to perform well. Being able to guide generative AI correctly is a powerful skill. You can guide generative AI by sending a prompt, which is typically a text instruction. The prompt is the input you provide to the agent, and it will influence the output. A good prompt should be structured, clear, concise, and directive.
50
+
51
+ ### How to write a structured prompt
52
+
53
+ > **Important**\
54
+ > A structured prompt refers to the construction of the prompt having clear logic and structure. For example, if you want the model to generate an article, your prompt may need to include the topic of the article, its outline, and its style.
55
+
56
+ Let's look at a basic example of a discussion question:
57
+
58
+ > _"What are the most urgent environmental issues our planet faces, and what can individuals do to help address these problems?"_
59
+
60
+ We can turn this into a simple prompt by answering the following question upfront.
61
+
62
+ ```
63
+ Answer the following question:
64
+ What are the most urgent environmental issues our planet faces, and what can individuals do to help address these problems?
65
+ ```
66
+
67
+ Since the results generated by this prompt are inconsistent, with some only consisting of one or two sentences, it is not ideal for a typical discussion answer that should have multiple paragraphs. A good prompt should provide specific formatting and content instructions. You need to eliminate ambiguity in the language to improve consistency and quality. Here's a better prompt:
68
+
69
+ ```
70
+ Write an in-depth essay that includes an introduction, body paragraphs, and a conclusion, answering the following question:
71
+ What are the most urgent environmental issues our planet faces, and what can individuals do to help address these problems?
72
+ ```
73
+
74
+ The second prompt generates longer outputs with better structure. The use of the word "essay" in the prompt is intentional because agent can understand the definition of an essay, making it more likely to generate coherent and structured answers.
75
+
76
+ <br/>
77
+
78
+ ### How to improve quality and effectiveness
79
+
80
+ > **Important**\
81
+ > There are several ways to improve the quality and effectiveness of prompts:
82
+ >
83
+ > - Be as clear as possible about your needs. The model will try to fulfill your requirements, so if your requirements are not clear, the output may not meet your expectations.
84
+ > - Use correct grammar and spelling. The model will try to mimic your language style, so if your language style is problematic, the output may also be problematic.
85
+ > - Provide sufficient contextual information. The model will generate output based on the contextual information you provide, so if you provide insufficient contextual information, it may not be able to generate the desired results.
86
+
87
+ After formulating effective prompts for discussion questions, you now need to refine the generated results. This may involve adjusting the output to fit constraints such as word count or combining concepts from different generated results.
88
+
89
+ A simple iteration method is to generate multiple outputs and examine them to understand the concepts and structure used by agent. Once the outputs have been evaluated, you can select the most suitable ones and combine them into a coherent answer. Another iterative approach is to start gradually and then expand step by step. This requires more than one prompt: an initial prompt for writing the first one or two paragraphs, followed by additional prompts to expand on the content already written. Here's a potential philosophical discussion prompt:
90
+
91
+ > _"Is mathematics invented or discovered? Explain your answer with careful reasoning."_
92
+
93
+ Add it to a simple prompt like this:
94
+
95
+ ```
96
+ Write an opening paragraph answering the following question:
97
+ Is mathematics invented or discovered? Explain your answer with careful reasoning.
98
+ ```
99
+
100
+ I generated a few answers and found one that I liked:
101
+
102
+ ```
103
+ Philosophers and mathematicians have debated whether mathematics is invented or discovered.
104
+ Some argue that the concepts and principles of mathematics exist independently of human thought, so they can be considered discovered rather than invented.
105
+ For example, the concepts of numbers, ratios, and geometric shapes are observed in the natural world and can be abstracted and studied systematically.
106
+ ```
107
+
108
+ It's a good start. Then I used another prompt to expand:
109
+
110
+ ```
111
+ I'm writing a detailed essay answering the following prompt:
112
+ Is mathematics invented or discovered? Explain your answer with careful reasoning. Here's where I'm at so far: Philosophers and mathematicians have debated whether mathematics is invented or discovered.
113
+ Some argue that the concepts and principles of mathematics exist independently of human thought, so they can be considered discovered rather than invented.
114
+ For example, the concepts of numbers, ratios, and geometric shapes are observed in the natural world and can be abstracted and studied systematically. Write the next paragraph of my essay.
115
+ ```
116
+
117
+ I used this prompt to generate several expansions and selected one that I liked, resulting in the following:
118
+
119
+ ```
120
+ Philosophers and mathematicians have debated whether mathematics is invented or discovered.
121
+ Some argue that the concepts and principles of mathematics exist independently of human thought, so they can be considered discovered rather than invented.
122
+ For example, the concepts of numbers, ratios, and geometric shapes are observed in the natural world and can be abstracted and studied systematically.
123
+ On the other hand, some argue that mathematics is largely an invention of human thought.
124
+ Mathematical principles are based on logical reasoning, which is a characteristic of human thought.
125
+ For example, Euclidean geometry is based on abstract axioms and assumptions that are accepted as true without needing to be proven.
126
+ Therefore, geometry can be seen as an invention of human thought rather than a discovery.
127
+ Similarly, mathematical formulas and equations are used to model and predict physical phenomena, which are the result of human reasoning.
128
+ ```
129
+
130
+ Using expansion prompts, we can gradually write and iterate at each step. This is useful for situations where you need to generate higher-quality output and want to make incremental modifications.
131
+
132
+ <br/>
133
+
134
+ ## Model Concepts
135
+
136
+ ### ChatGPT
137
+
138
+ - **gpt-3.5-turbo**: The fastest generating chatgpt model currently available, but it may sacrifice some text quality. The context length is 4k.
139
+ - **gpt-3.5-turbo-16k**: Same as gpt-4, but with an increased context limit of 16k tokens and a higher cost rate.
140
+ - **gpt-4**: ChatGPT 4.0 has improved language understanding and generation capabilities compared to 3.5. It has a better understanding of context and can generate more accurate and natural responses. This is due to improvements in the GPT-4 model, including better language modeling and deeper semantic understanding, but it may be slower than other models. The context length is 8k.
141
+ - **gpt-4-32k**: Same as gpt-4, but with an increased context limit of 32k tokens and a higher cost rate.
142
+
143
+ <br/>
144
+
145
+ ## Model Parameter Concepts
146
+
147
+ LLM may seem magical, but it is essentially a probability problem. The neural network generates a set of candidate words from the pre-trained model based on the input text and selects the highest probability as the output. Most of the related parameters are about sampling (i.e., how to select the output from the candidate words).
148
+
149
+ ### `temperature`
150
+
151
+ Controls the randomness of the model's output. Higher values increase randomness. In general, if you input the same prompt multiple times, the model's output will be different each time.
152
+
153
+ - Set to 0 for a fixed output for each prompt.
154
+ - Lower values make the output more focused and deterministic.
155
+ - Higher values make the output more random and creative.
156
+
157
+ > **Note**\
158
+ > Generally, the longer and clearer the prompt, the better the quality and confidence of the generated output. In this case, you can increase the temperature value. Conversely, if the prompt is short and ambiguous, setting a higher temperature value will make the model's output less stable.
159
+
160
+ <br/>
161
+
162
+ ### `top_p`
163
+
164
+ Top-p nucleus sampling is another sampling parameter that is different from temperature. Before the model generates the output, it generates a set of tokens. In top-p sampling mode, the candidate word list is dynamic and selected from the tokens based on a percentage. Top-p introduces randomness to the selection of tokens, allowing other high-scoring tokens to have a chance of being selected instead of always choosing the highest-scoring one.
165
+
166
+ > **Note**\
167
+ > Top-p is similar to randomness. In general, it is not recommended to change it together with the randomness parameter, temperature.
168
+
169
+ <br/>
170
+
171
+ ### `presence_penalty`
172
+
173
+ The presence penalty parameter can be seen as a punishment for repetitive content in the generated text. When this parameter is set high, the generative model will try to avoid generating repeated words, phrases, or sentences. Conversely, if the presence penalty parameter is low, the generated text may contain more repeated content. By adjusting the value of the presence penalty parameter, you can control the originality and diversity of the generated text. The importance of this parameter is mainly reflected in the following aspects:
174
+
175
+ - Increasing the originality and diversity of the generated text: In some application scenarios, such as creative writing or generating news headlines, it is desirable for the generated text to have high originality and diversity. By increasing the value of the presence penalty parameter, the probability of generating repeated content in the generated text can be effectively reduced, thereby improving its originality and diversity.
176
+ - Preventing generation loops and meaningless content: In some cases, the generative model may produce repetitive and meaningless text that fails to convey useful information. By appropriately increasing the value of the presence penalty parameter, the probability of generating this type of meaningless content can be reduced, thereby improving the readability and usefulness of the generated text.
177
+
178
+ > **Note**\
179
+ > It is worth noting that the presence penalty parameter, along with other parameters such as temperature and top-p, collectively affect the quality of the generated text. Compared to other parameters, the presence penalty parameter focuses more on the originality and repetitiveness of the text, while the temperature and top-p parameters have a greater impact on the randomness and determinism of the generated text. By adjusting these parameters properly, comprehensive control of the quality of the generated text can be achieved.
180
+
181
+ <br/>
182
+
183
+ ### `frequency_penalty`
184
+
185
+ Frequency penalty is a mechanism that penalizes frequent occurrences of new vocabulary in the generated text, reducing the likelihood of the model repeating the same words. The higher the value, the more likely it is to reduce repeated words.
186
+
187
+ - `-2.0` When the morning news starts playing, I noticed that my TV now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now now _(The most frequent word is "now" with a percentage of 44.79%)_
188
+ - `-1.0` He always watches the news in the morning, watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching watching _(The most frequent word is "watching" with a percentage of 57.69%)_
189
+ - `0.0` When the morning sun shines into the small restaurant, a tired mailman appears at the door, holding a bag of mail in his hand. The owner warmly prepares breakfast for him, and he starts sorting the mail while enjoying his breakfast. **_(The most frequent word is "the" with a percentage of 8.45%)_**
190
+ - `1.0` A deep sleep girl is awakened by a warm sunbeam. She sees the first ray of sunlight in the morning, surrounded by the sounds of birds and the fragrance of flowers, everything is full of vitality. _(The most frequent word is "the" with a percentage of 5.45%)_
191
+ - `2.0` Every morning, he sits on the balcony to have breakfast. In the gentle sunset, everything looks very peaceful. However, one day, as he was about to pick up his breakfast, an optimistic little bird flew by, bringing him a good mood for the day. _(The most frequent word is "the" with a percentage of 4.94%)_
192
+
193
+ ## Further Reading
194
+
195
+ - **Learn Prompting** - <https://learnprompting.org/docs/intro>
@@ -0,0 +1,196 @@
1
+ # 自定义助手指南
2
+
3
+ #### TOC
4
+
5
+ - [添加自定义助手](#添加自定义助手)
6
+ - [`A` 通过角色市场添加](#a-通过角色市场添加)
7
+ - [`B` 通过新建自定义助手](#b-通过新建自定义助手)
8
+ - [Prompt 基本概念](#prompt-基本概念)
9
+ - [如何写好一个结构化 prompt](#如何写好一个结构化-prompt)
10
+ - [如何提升其质量和效果](#如何提升其质量和效果)
11
+ - [模型的概念](#模型的概念)
12
+ - [ChatGPT](#chatgpt)
13
+ - [模型参数概念](#模型参数概念)
14
+ - [`temperature`](#temperature)
15
+ - [`top_p`](#top_p)
16
+ - [`presence_penalty`](#presence_penalty)
17
+ - [`frequency_penalty`](#frequency_penalty)
18
+ - [扩展阅读](#扩展阅读)
19
+
20
+ ## 添加自定义助手
21
+
22
+ 作为 LobeChat 的基础职能单位,助手的添加和迭代是非常重要的。现在你可以通过两种方式将助手添加到你的常用列表中
23
+
24
+ ### `A` 通过角色市场添加
25
+
26
+ 如果你是一个 Prompt 编写的新手,不妨先浏览一下 LobeChat 的助手市场。在这里,你可以找到其他人提交的常用助手,并且只需一键添加到你的列表中,非常方便。
27
+
28
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279588466-4c32041b-a8e6-4703-ba4a-f91b7800e359.png)
29
+
30
+ ### `B` 通过新建自定义助手
31
+
32
+ 当你需要处理一些特定的任务时,你就需要考虑创建一个自定义助手来帮助你解决问题。可以通过以下方式添加并进行助手的详细配置
33
+
34
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587283-a3ea8dfd-70fb-47ee-ab00-e3911ac6a939.png)
35
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587292-a3d102c6-f61e-4578-91f1-c0a4c97588e1.png)
36
+
37
+ > **Note**\
38
+ > 快捷设置技巧:可以通过侧边栏的快捷编辑按钮进行 Prompt 的便捷修改
39
+
40
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587294-388d1877-193e-4a50-9fe8-8fbcc3ccefa0.png)
41
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279587298-333da153-13b8-4557-a0a2-cff55e7bc1c0.png)
42
+
43
+ 请继续阅读下文,理解 Prompt 编写技巧和常见的模型参数设置
44
+
45
+ <br/>
46
+
47
+ ## Prompt 基本概念
48
+
49
+ 生成式 AI 非常有用,但它需要人类指导。通常情况下,生成式 AI 能就像公司新来的实习生一样,非常有能力,但需要清晰的指示才能做得好。能够正确地指导生成式 AI 是一项非常强大的技能。你可以通过发送一个 prompt 来指导生成式 AI,这通常是一个文本指令。Prompt 是向助手提供的输入,它会影响输出结果。一个好的 Prompt 应该是结构化的,清晰的,简洁的,并且具有指向性。
50
+
51
+ ### 如何写好一个结构化 prompt
52
+
53
+ > **Important**\
54
+ > 结构化 prompt 是指 prompt 的构造应该有明确的逻辑和结构。例如,如果你想让模型生成一篇文章,你的 prompt 可能需要包括文章的主题,文章的大纲,文章的风格等信息。
55
+
56
+ 让我们看一个基本的讨论问题的例子:
57
+
58
+ > _"我们星球面临的最紧迫的环境问题是什么,个人可以采取哪些措施来帮助解决这些问题?"_
59
+
60
+ 我们可以将其转化为简单的助手提示,将回答以下问题:放在前面。
61
+
62
+ ```
63
+ 回答以下问题:
64
+ 我们星球面临的最紧迫的环境问题是什么,个人可以采取哪些措施来帮助解决这些问题?
65
+ ```
66
+
67
+ 由于这个提示生成的结果并不一致,有些只有一两个句子。一个典型的讨论回答应该有多个段落,因此这些结果并不理想。一个好的提示应该给出**具体的格式和内容指令**。您需要消除语言中的歧义以提高一致性和质量。这是一个更好的提示。
68
+
69
+ ```
70
+ 写一篇高度详细的论文,包括引言、正文和结论段,回答以下问题:
71
+ 我们星球面临的最紧迫的环境问题是什么,
72
+ 个人可以采取哪些措施来帮助解决这些问题?
73
+ ```
74
+
75
+ 第二个提示生成了更长的输出和更好的结构。提示中使用 “论文” 一词是有意的,因为助手可以理解论文的定义,因此更有可能生成连贯的、结构化的回答。
76
+
77
+ <br/>
78
+
79
+ ### 如何提升其质量和效果
80
+
81
+ > **Important**\
82
+ > 提升 prompt 质量和效果的方法主要有以下几点:
83
+ >
84
+ > - 尽量明确你的需求。模型的输出会尽可能满足你的需求,所以如果你的需求不明确,输出可能会不如预期。
85
+ > - 使用正确的语法和拼写。模型会尽可能模仿你的语言风格,所以如果你的语言风格有问题,输出可能也会有问题。
86
+ > - 提供足够的上下文信息。模型会根据你提供的上下文信息生成输出,所以如果你提供的上下文信息不足,可能无法生成你想要的结果。
87
+
88
+ 在为讨论问题制定有效的提示后,您现在需要细化生成的结果。这可能涉及到调整输出以符合诸如字数等限制,或将不同生成的结果的概念组合在一起。
89
+
90
+ 迭代的一个简单方法是生成多个输出并查看它们,以了解正在使用的概念和结构。一旦评估了输出,您就可以选择最合适的输出并将它们组合成一个连贯的回答。另一种迭代的方法是逐步开始,然后**逐步扩展**。这需要不止一个提示:一个起始提示,用于撰写最初的一两段,然后是其他提示,以扩展已经写过的内容。以下是一个潜在的哲学讨论问题:
91
+
92
+ > _"数学是发明还是发现?用仔细的推理来解释你的答案。"_
93
+
94
+ 将其添加到一个简单的提示中,如下所示:
95
+
96
+ ```
97
+ 写一个起始段回答以下问题:
98
+ 数学是发明还是发现?用仔细的推理来解释你的答案。
99
+ ```
100
+
101
+ 我生成了一些回答,找到了一个我喜欢的:
102
+
103
+ ```
104
+ 哲学家和数学家之间争论不休,数学是发明还是发现。
105
+ 一些人认为,数学的概念和原则独立于人类思维存在,因此可以被认为是被发现而不是被发明的。
106
+ 例如,数字、比率和几何形状的概念在自然界中被观察到,可以被抽象化和系统化地研究。
107
+ ```
108
+
109
+ 是一个不错的开端。然后我使用另一个提示来扩展:
110
+
111
+ ```
112
+ 我正在撰写一篇详细的短文,回答以下提示:
113
+ 数学是发明还是发现?用仔细的推理来解释你的答案。这是我目前的情况: 哲学家和数学家之间争论不休,数学是发明还是发现。
114
+ 一些人认为,数学的概念和原则独立于人类思维存在,因此可以被认为是被发现而不是被发明的。
115
+ 例如,数字、比率和几何形状的概念在自然界中被观察到,可以被抽象化和系统化地研究。写下我文章的下一段。
116
+ ```
117
+
118
+ 我使用此提示生成了几个扩展,并选择了一个我喜欢的,最终得到了以下结果:
119
+
120
+ ```
121
+ 哲学家和数学家之间争论不休,数学是发明还是发现。
122
+ 一些人认为,数学的概念和原则独立于人类思维存在,因此可以被认为是被发现而不是被发明的。
123
+ 例如,数字、比率和几何形状的概念在自然界中被观察到,可以被抽象化和系统化地研究。
124
+ 另一方面,有人认为数学在很大程度上是人类思维的发明。
125
+ 数学原理基于逻辑推理,这是人类思维的一个特征。
126
+ 例如,欧几里德几何基于抽象的公理和前提,被接受为真实而无需证明。
127
+ 因此,可以认为几何是人类思维的发明,而不是一种发现。
128
+ 同样,数学公式和方程用于模拟和预测物理现象,这又是人类推理的结果。
129
+ ```
130
+
131
+ 使用扩展提示,我们可以逐步地写作并在每个步骤上进行迭代。这对于需要**生成更高质量的输出并希望逐步修改**的情况非常有用。
132
+
133
+ <br/>
134
+
135
+ ## 模型的概念
136
+
137
+ ### ChatGPT
138
+
139
+ - **gpt-3.5-turbo**:目前最生成速度最快的 chatgpt 模型更快,但可能会牺牲一些生成文本的质量,上下文长度为 4k。
140
+ - **gpt-3.5-turbo-16k**:同 gpt-4,上下文限制增加到 16k token,同时费率更高。
141
+ - **gpt-4**:ChatGPT 4.0 在语言理解和生成能力方面相对于 3.5 有所提升。它可以更好地理解上下文和语境,并生成更准确、自然的回答。这得益于 GPT-4 模型的改进,包括更好的语言建模和更深入的语义理解,但它的速度可能比其他模型慢,上下文长度为 8k。
142
+ - **gpt-4-32k**:同 gpt-4,上下文限制增加到 32k token,同时费率更高。
143
+
144
+ <br/>
145
+
146
+ ## 模型参数概念
147
+
148
+ LLM 看似很神奇,但本质还是一个概率问题,神经网络根据输入的文本,从预训练的模型里面生成一堆候选词,选择概率高的作为输出,相关的参数,大多都是跟采样有关(也就是要如何从候选词里选择输出)。
149
+
150
+ ### `temperature`
151
+
152
+ 用于控制模型输出的结果的随机性,这个值越大随机性越大。一般我们多次输入相同的 prompt 之后,模型的每次输出都不一样。
153
+
154
+ - 设置为 0,对每个 prompt 都生成固定的输出
155
+ - 较低的值,输出更集中,更有确定性
156
+ - 较高的值,输出更随机(更有创意 )
157
+
158
+ > **Note**\
159
+ > 一般来说,prompt 越长,描述得越清楚,模型生成的输出质量就越好,置信度越高,这时可以适当调高 temperature 的值;反过来,如果 prompt 很短,很含糊,这时再设置一个比较高的 temperature 值,模型的输出就很不稳定了。
160
+
161
+ <br/>
162
+
163
+ ### `top_p`
164
+
165
+ 核采样 top_p 也是采样参数,跟 temperature 不一样的采样方式。模型在输出之前,会生成一堆 token,这些 token 根据质量高低排名,核采样模式中候选词列表是动态的,从 tokens 里按百分比选择候选词。 top-p 为选择 token 引入了随机性,让其他高分的 token 有被选择的机会,不会总是选最高分的。
166
+
167
+ > **Note**\
168
+ > top_p 与随机性类似,一般来说不建议和随机性 temperature 一起更改
169
+
170
+ <br/>
171
+
172
+ ### `presence_penalty`
173
+
174
+ Presence Penalty 参数可以看作是对生成文本中重复内容的一种惩罚。当该参数设置较高时,生成模型会尽量避免产生重复的词语、短语或句子。相反,如果 Presence Penalty 参数较低,则生成的文本可能会包含更多重复的内容。通过调整 Presence Penalty 参数的值,可以实现对生成文本的原创性和多样性的控制。参数的重要性主要体现在以下几个方面:
175
+
176
+ - 提高生成文本的独创性和多样性:在某些应用场景下,如创意写作、生成新闻标题等,需要生成的文本具有较高的独创性和多样性。通过增加 Presence Penalty 参数的值,可以有效减少生成文本中的重复内容,从而提高文本的独创性和多样性。
177
+ - 防止生成循环和无意义的内容:在某些情况下,生成模型可能会产生循环、重复的文本,这些文本通常无法传达有效的信息。通过适当增加 Presence Penalty 参数的值,可以降低生成这类无意义内容的概率,提高生成文本的可读性和实用性。
178
+
179
+ > **Note**\
180
+ > 值得注意的是,Presence Penalty 参数与其他参数(如 Temperature 和 top-p)共同影响着生成文本的质量。对比其他参数,Presence Penalty 参数主要关注文本的独创性和重复性,而 Temperature 和 top-p 参数则更多地影响着生成文本的随机性和确定性。通过合理地调整这些参数,可以实现对生成文本质量的综合控制
181
+
182
+ <br/>
183
+
184
+ ### `frequency_penalty`
185
+
186
+ 是一种机制,通过对文本中频繁出现的新词汇施加惩罚,以减少模型重复同一词语的可能性,值越大,越有可能降低重复字词。
187
+
188
+ - `-2.0` 当早间新闻开始播出,我发现我家电视现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在现在 _(频率最高的词是 “现在”,占比 44.79%)_
189
+ - `-1.0` 他总是在清晨看新闻,在电视前看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看 _(频率最高的词是 “看”,占比 57.69%)_
190
+ - `0.0` 当清晨的阳光洒进小餐馆时,一名疲倦的邮递员出现在门口,他的手中提着一袋信件。店主热情地为他准备了一份早餐,他在享用早餐的同时开始整理邮件。**(频率最高的词是 “的”,占比 8.45%)**
191
+ - `1.0` 一个深度睡眠的女孩被一阵温暖的阳光唤醒,她看到了早晨的第一缕阳光,周围是鸟语花香,一切都充满了生机。_(频率最高的词是 “的”,占比 5.45%)_
192
+ - `2.0` 每天早上,他都会在阳台上坐着吃早餐。在柔和的夕阳照耀下,一切看起来都非常宁静。然而有一天,当他准备端起早餐的时候,一只乐观的小鸟飞过,给他带来了一天的好心情。 _(频率最高的词是 “的”,占比 4.94%)_
193
+
194
+ ## 扩展阅读
195
+
196
+ - **Learn Prompting** - <https://learnprompting.org/zh-Hans/docs/intro>
@@ -0,0 +1,31 @@
1
+ # Topic Guide
2
+
3
+ #### TOC
4
+
5
+ - [Explanation of Agent and Topic Concepts](#explanation-of-agent-and-topic-concepts)
6
+ - [User Guide](#user-guide)
7
+
8
+ ## Explanation of Agent and Topic Concepts
9
+
10
+ In the official ChatGPT app, there is only the concept of topics, as shown in the figure, the sidebar contains the user's historical conversation topic list.
11
+
12
+ > **Note**
13
+ >
14
+ > However, in our use, we actually find that this mode has many problems, such as the information indexing of historical conversations is too scattered, and when dealing with some repetitive tasks, it is difficult to have a stable entrance. For example, I hope there is a stable entrance to allow ChatGPT to help me translate documents. In this mode, I need to constantly create new topics and then set the translation Prompt I created before. When there are high-frequency tasks, this will be a very low-efficiency interaction form.
15
+
16
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279602474-fe7cb3f3-8eb7-40d3-a69f-6615393bbd4e.png)
17
+
18
+ Therefore, in LobeChat, we introduced the concept of `Agent`. The agent is a complete functional module, and each agent has its own responsibilities and tasks. The agent can help you handle various tasks and provide professional advice and guidance.
19
+
20
+ At the same time, we index the topic into each agent. The advantage of this is that each agent has an independent topic list, you can choose the corresponding agent according to the current task, and quickly switch historical conversation records. This way is more in line with the user's use habits of common chat software, and improves the interaction efficiency.
21
+
22
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279602489-89893e61-2791-4083-9b57-ed80884ad58b.png)
23
+
24
+ <br/>
25
+
26
+ ## User Guide
27
+
28
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279602496-fd72037a-735e-4cc2-aa56-2994bceaba81.png)
29
+
30
+ - **Save Topic:** During the chat, if you want to save the current context and start a new topic, you can click the save button next to the send button.
31
+ - **Topic List:** Clicking on the topic in the list can quickly switch historical conversation records and continue the conversation. You can also click the star icon <kbd>⭐️</kbd> to bookmark the topic to the top, or rename and delete the topic through the more button on the right.
@@ -0,0 +1,31 @@
1
+ # 话题指南
2
+
3
+ #### TOC
4
+
5
+ - [助手与话题概念解析](#助手与话题概念解析)
6
+ - [使用指南](#使用指南)
7
+
8
+ ## 助手与话题概念解析
9
+
10
+ 在 ChatGPT 官方应用中,只存在话题的概念,如图所示,在侧边栏中是用户的历史对话话题列表。
11
+
12
+ > **Note**
13
+ >
14
+ > 但在我们的使用过程中其实会发现这种模式存在很多问题,比如历史对话的信息索引过于分散问题,同时当处理一些重复任务时很难有一个稳定的入口,比如我希望有一个稳定的入口可以让 ChatGPT 帮助我翻译文档,在这个模式下,我需要不断新建新的话题同时再设置我之前创建好的翻译 Prompt 设定,当有高频任务存在时,这将是一个效率很低的交互形式。
15
+
16
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279602474-fe7cb3f3-8eb7-40d3-a69f-6615393bbd4e.png)
17
+
18
+ 因此在 LobeChat 中,我们引入了 **助手** 的概念。助手是一个完整的功能模块,每个助手都有自己的职责和任务。助手可以帮助你处理各种任务,并提供专业的建议和指导。
19
+
20
+ 与此同时,我们将话题索引到每个助手内部。这样做的好处是,每个助手都有一个独立的话题列表,你可以根据当前任务选择对应的助手,并快速切换历史对话记录。这种方式更符合用户对常见聊天软件的使用习惯,提高了交互的效率。
21
+
22
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279602489-89893e61-2791-4083-9b57-ed80884ad58b.png)
23
+
24
+ <br/>
25
+
26
+ ## 使用指南
27
+
28
+ ![](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/279602496-fd72037a-735e-4cc2-aa56-2994bceaba81.png)
29
+
30
+ - **保存话题:** 在聊天过程中,如果想要保存当前上下文并开启新的话题,可以点击发送按钮旁边的保存按钮。
31
+ - **话题列表:** 点击列表中的话题可以快速切换历史对话记录,并继续对话。你还可以通过点击星标图标 <kbd>⭐️</kbd> 将话题收藏置顶,或者通过右侧更多按钮对话题进行重命名和删除操作。
package/docs/_Sidebar.md CHANGED
@@ -4,13 +4,17 @@
4
4
 
5
5
  - [TOC](Home) | [目录](Home)
6
6
 
7
- #### 🤯 LobeChat
7
+ #### 🤯 LobeChat Usage
8
+
9
+ - [Custom Agents Guide](Usage-Agents) | [中文](Usage-Agents.zh-CN)
10
+ - [Topics Guide](Usage-Topics) | [中文](Usage-Topics.zh-CN)
11
+
12
+ #### 🛳 Self Hosting
8
13
 
9
14
  - [Environment Variables](Environment-Variable) | [中文](Environment-Variable.zh-CN)
10
15
  - [Upstream Sync](Upstream-Sync) | [中文](Upstream-Sync.zh-CN)
11
16
  - [Deploying with Azure OpenAI](Deploy-with-Azure-OpenAI) | [中文](Deploy-with-Azure-OpenAI.zh-CN)
12
17
  - [Docker Deployment Guide](Docker-Deployment) | [中文](Docker-Deployment.zh-CN)
13
- - [Lighthouse Report](Lighthouse) | [中文](Lighthouse.zh-CN)
14
18
 
15
19
  #### 🤖 Agents
16
20
 
@@ -22,6 +26,10 @@
22
26
  - [Plugin Development](Plugin-Development) | [中文](Plugin-Development.zh-CN)
23
27
  - [Plugin SDK Docs][plugin-sdk] | [中文][plugin-skd-cn]
24
28
 
29
+ #### 📊 Other
30
+
31
+ - [Lighthouse Report](Lighthouse) | [中文](Lighthouse.zh-CN)
32
+
25
33
  <!-- LINK GROUP -->
26
34
 
27
35
  [agent-index]: https://github.com/lobehub/lobe-chat-agents
@@ -22,7 +22,7 @@
22
22
  "searchAgentPlaceholder": "Search agents and conversations...",
23
23
  "send": "Send",
24
24
  "sendPlaceholder": "Enter chat content...",
25
- "sessionList": "Assistant List",
25
+ "sessionList": "Agent List",
26
26
  "shareModal": {
27
27
  "download": "Download Screenshot",
28
28
  "imageType": "Image Format",
@@ -47,7 +47,13 @@
47
47
  "defaultTitle": "Default Topic",
48
48
  "saveCurrentMessages": "Save Current Session as Topic",
49
49
  "searchPlaceholder": "Search topics...",
50
- "title": "Topic"
50
+ "deleteAll": "Delete All Topics",
51
+ "deleteUnstarred": "Delete Unstarred Topics",
52
+ "title": "Topic List",
53
+ "confirmRemoveAll": "All topics will be deleted and cannot be recovered. Please proceed with caution.",
54
+ "confirmRemoveUnstarred": "All unstarred topics will be deleted and cannot be recovered. Please proceed with caution.",
55
+ "removeAll": "Remove All Topics",
56
+ "removeUnstarred": "Remove Unstarred Topics"
51
57
  },
52
58
  "translate": {
53
59
  "clear": "Clear Translation"
@@ -47,7 +47,13 @@
47
47
  "defaultTitle": "デフォルトトピック",
48
48
  "saveCurrentMessages": "現在の会話をトピックとして保存",
49
49
  "searchPlaceholder": "トピックを検索...",
50
- "title": "トピック"
50
+ "deleteAll": "すべてのトピックを削除する",
51
+ "deleteUnstarred": "スターを付けていないトピックを削除する",
52
+ "title": "トピックリスト",
53
+ "confirmRemoveAll": "すべてのトピックを削除します。削除後は元に戻すことはできませんので、注意して操作してください。",
54
+ "confirmRemoveUnstarred": "スターをつけていないトピックを削除します。削除後は元に戻すことはできませんので、注意して操作してください。",
55
+ "removeAll": "すべてのトピックを削除",
56
+ "removeUnstarred": "スターをつけていないトピックを削除"
51
57
  },
52
58
  "translate": {
53
59
  "clear": "翻訳をクリア"
@@ -47,7 +47,13 @@
47
47
  "defaultTitle": "기본 주제",
48
48
  "saveCurrentMessages": "현재 대화를 주제로 저장",
49
49
  "searchPlaceholder": "주제 검색...",
50
- "title": "주제"
50
+ "deleteAll": "모든 주제 삭제",
51
+ "deleteUnstarred": "스타가 없는 주제 삭제",
52
+ "title": "주제 목록",
53
+ "confirmRemoveAll": "모든 주제를 삭제하려고 합니다. 삭제 후에는 복구할 수 없으므로 신중하게 작업하십시오.",
54
+ "confirmRemoveUnstarred": "스타를 지정하지 않은 주제를 삭제하려고 합니다. 삭제 후에는 복구할 수 없으므로 신중하게 작업하십시오.",
55
+ "removeAll": "모든 주제 삭제",
56
+ "removeUnstarred": "스타를 지정하지 않은 주제 삭제"
51
57
  },
52
58
  "translate": {
53
59
  "clear": "번역 지우기"
@@ -47,7 +47,13 @@
47
47
  "defaultTitle": "Стандартная тема",
48
48
  "saveCurrentMessages": "Сохранить текущий разговор как тему",
49
49
  "searchPlaceholder": "Поиск темы...",
50
- "title": "Тема"
50
+ "deleteAll": "Удалить все темы",
51
+ "deleteUnstarred": "Удалить неотмеченные темы",
52
+ "title": "Список тем",
53
+ "confirmRemoveAll": "Вы собираетесь удалить все темы. После удаления их будет невозможно восстановить. Пожалуйста, будьте осторожны.",
54
+ "confirmRemoveUnstarred": "Вы собираетесь удалить неотмеченные темы. После удаления их будет невозможно восстановить. Пожалуйста, будьте осторожны.",
55
+ "removeAll": "Удалить все темы",
56
+ "removeUnstarred": "Удалить неотмеченные темы"
51
57
  },
52
58
  "translate": {
53
59
  "clear": "Очистить перевод"
@@ -43,11 +43,15 @@
43
43
  "used": "使用"
44
44
  },
45
45
  "topic": {
46
+ "confirmRemoveAll": "即将删除全部话题,删除后将不可恢复,请谨慎操作。",
46
47
  "confirmRemoveTopic": "即将删除该话题,删除后将不可恢复,请谨慎操作。",
48
+ "confirmRemoveUnstarred": "即将删除未收藏话题,删除后将不可恢复,请谨慎操作。",
47
49
  "defaultTitle": "默认话题",
50
+ "removeAll": "删除全部话题",
51
+ "removeUnstarred": "删除未收藏话题",
48
52
  "saveCurrentMessages": "将当前会话保存为话题",
49
53
  "searchPlaceholder": "搜索话题...",
50
- "title": "话题"
54
+ "title": "话题列表"
51
55
  },
52
56
  "translate": {
53
57
  "clear": "删除翻译"
@@ -47,7 +47,13 @@
47
47
  "defaultTitle": "默認話題",
48
48
  "saveCurrentMessages": "將當前會話保存為話題",
49
49
  "searchPlaceholder": "搜索話題...",
50
- "title": "話題"
50
+ "deleteAll": "刪除所有話題",
51
+ "deleteUnstarred": "刪除未收藏話題",
52
+ "title": "話題列表",
53
+ "confirmRemoveAll": "即將刪除全部話題,刪除後將無法恢復,請謹慎操作。",
54
+ "confirmRemoveUnstarred": "即將刪除未收藏話題,刪除後將無法恢復,請謹慎操作。",
55
+ "removeAll": "刪除全部話題",
56
+ "removeUnstarred": "刪除未收藏話題"
51
57
  },
52
58
  "translate": {
53
59
  "clear": "刪除翻譯"
package/next.config.mjs CHANGED
@@ -50,7 +50,15 @@ const nextConfig = {
50
50
  experimental: {
51
51
  webVitalsAttribution: ['CLS', 'LCP'],
52
52
  forceSwcTransforms: true,
53
- optimizePackageImports: ['modern-screenshot','emoji-mart','@emoji-mart/react','@emoji-mart/data','@icons-pack/react-simple-icons','gpt-tokenizer','chroma-js'],
53
+ optimizePackageImports: [
54
+ 'modern-screenshot',
55
+ 'emoji-mart',
56
+ '@emoji-mart/react',
57
+ '@emoji-mart/data',
58
+ '@icons-pack/react-simple-icons',
59
+ 'gpt-tokenizer',
60
+ 'chroma-js',
61
+ ],
54
62
  },
55
63
  transpilePackages: ['@lobehub/ui', 'antd-style', 'lodash-es'],
56
64