77 |
78 | 或者访问 **[GitHub Releases](https://github.com/Bin-Huang/chatbox/releases)** 下载最新版本或任何以前的版本。
79 |
80 | ## ⏬ 下载 iOS/Android App
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | .APK
91 |
92 |
93 | ## 🌟 特性
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | # 特性
104 |
105 | - **本地数据存储**
106 | :floppy_disk: 您的数据保留在您的设备上,确保数据永不丢失并保护您的隐私。
107 |
108 | - **无需部署、直接安装的安装包**
109 | :package: 通过可下载的安装包快速开始使用。无需复杂设置!
110 |
111 | - **支持多个 LLM 提供商**
112 | :gear: 无缝集成多种 AI 模型:
113 |
114 | - OpenAI (ChatGPT)
115 | - Azure OpenAI
116 | - Claude
117 | - Google Gemini Pro
118 | - Ollama (启用对本地模型的访问,如 llama2、Mistral、Mixtral、codellama、vicuna、yi 和 solar)
119 | - ChatGLM-6B
120 |
121 | - **使用 Dall-E-3 生成图像**
122 | :art: 使用 Dall-E-3 创建您想象中的图像。
123 |
124 | - **增强提示**
125 | :speech_balloon: 高级提示功能,精炼并聚焦您的查询以获得更好的响应。
126 |
127 | - **键盘快捷键**
128 | :keyboard: 使用加速您工作流程的快捷键保持高效。
129 |
130 | - **Markdown、Latex 和代码高亮**
131 | :scroll: 使用 Markdown 和 Latex 的全部功能生成消息,并结合各种编程语言的语法高亮,提高可读性和呈现效果。
132 |
133 | - **提示库和消息引用**
134 | :books: 保存和组织提示以供重复使用,并引用消息以在讨论中提供上下文。
135 |
136 | - **流式回复**
137 | :arrow_forward: 通过即时、渐进式回复快速响应您的互动。
138 |
139 | - **人体工程学 UI 和深色主题**
140 | :new_moon: 用户友好的界面,带有夜间模式选项,减少长时间使用时的眼睛疲劳。
141 |
142 | - **团队协作**
143 | :busts_in_silhouette: 轻松协作并在团队中共享 OpenAI API 资源。[了解更多](./team-sharing/README.md)
144 |
145 | - **跨平台可用性**
146 | :computer: 聊天盒已为 Windows、Mac、Linux 用户准备就绪。
147 |
148 | - **通过 Web 版本随处访问**
149 | :globe_with_meridians: 在任何设备上使用带有浏览器的 Web 应用程序,随时随地。
150 |
151 | - **iOS 和 Android**
152 | :phone: 使用移动应用程序,随时随地在您的指尖上带来这种能力。
153 |
154 | - **多语言支持**
155 | :earth_americas: 通过提供多种语言的支持,迎合全球受众:
156 |
157 | - English
158 | - 简体中文 (Simplified Chinese)
159 | - 繁體中文 (Traditional Chinese)
160 | - 日本語 (Japanese)
161 | - 한국어 (Korean)
162 | - Français (French)
163 | - Deutsch (German)
164 | - Русский (Russian)
165 |
166 | - **更多...**
167 | :sparkles: 不断增强体验,加入新功能!
168 |
169 | ## 常见问题解答
170 |
171 | - [常见问题](./FAQ.md)
172 |
173 | ## 路线图
174 |
175 | - [x] AI 聊天和会话管理
176 | - [x] 本地存储所有重要的消息数据。
177 | - [x] Markdown
178 | - [x] 流式回复
179 | - [x] API 主机配置
180 | - [x] 自动生成标签标题
181 | - [x] 清除消息的按钮。
182 | - [x] 夜间/深色模式
183 | - [x] 消息令牌估算
184 | - [x] GPT4
185 | - [x] i18n
186 | - [x] 代码块的复制按钮
187 | - [x] 停止 AI 消息生成的按钮
188 | - [x] 标签的拖放排序
189 | - [x] [Web 版本](https://web.chatboxai.app)
190 | - [x] Azure OpenAI API 兼容性
191 | - [x] 改进的提示设置
192 | - [x] 提示库
193 | - [x] 内置 AI 服务
194 | - [x] 快捷键
195 | - [x] Claude
196 | - [x] 温度设置
197 | - [x] 会话特殊设置
198 | - [x] OpenAI 自定义模型
199 | - [x] Dall-E-3
200 | - [x] 消息搜索
201 | - [x] 数据导出
202 | - [x] 支持 Google Gemini Pro
203 | - [x] 支持 Ollama (llama2, Mistral, Mixtral, codellama, vicuna, yi, 和 solar)
204 | - [x] 线程归档,历史消息列表
205 | - [x] 移动 (Android, iOS)
206 | - [x] 与文件对话
207 | - [ ] 与 URLs 对话
208 | - [ ] 跨设备同步
209 | - 更多...
210 |
211 | ## 如何贡献
212 |
213 | 欢迎任何形式的贡献,包括但不限于:
214 |
215 | - 提交问题
216 | - 提交拉取请求
217 | - 提交功能请求
218 | - 提交错误报告
219 | - 提交文档修订
220 | - 提交翻译
221 | - 提交任何其他形式的贡献
222 |
223 | ## 聊天盒的构建指南 (Mac, Windows, Linux)
224 |
225 | 1. 使用以下命令从 Github 克隆仓库:
226 |
227 | ```bash
228 | git clone https://github.com/Bin-Huang/chatbox.git
229 | ```
230 |
231 | 2. 运行以下命令安装所需的依赖项:
232 |
233 | ```bash
234 | npm install
235 | ```
236 |
237 | 3. 运行以下命令启动应用程序:
238 |
239 | ```bash
240 | npm start
241 | ```
242 |
243 | ## 请我喝咖啡
244 |
245 | [](https://buymeacoffee.com/benn)
246 |
247 | | Paypal | 微信支付 | 支付宝 |
248 | | ------------------------------------------------- | ----------------------------------------------- | -------------------------------------------- |
249 | | [**`Paypal`**](https://www.paypal.me/tobennhuang) | | |
250 |
251 | ## Star History
252 |
253 | [](https://star-history.com/#Bin-Huang/chatbox&Date)
254 |
255 | ## 联系方式
256 |
257 | [Twitter](https://twitter.com/benn_huang) | [电子邮件](mailto:tohuangbin@gmail.com) | [博客](https://bennhuang.com)
258 |
--------------------------------------------------------------------------------
/src/packages/defaults.ts:
--------------------------------------------------------------------------------
1 | import { Session } from '../stores/types'
2 |
3 | export const sessions: Session[] = [
4 | {
5 | id: '1bc7094f-1248-4b51-8ac8-180a5a1470aa',
6 | name: 'Random Talk',
7 | messages: [
8 | {
9 | id: '9acc4bde-3510-41fd-b872-666547b8023e',
10 | content: 'hi',
11 | role: 'user',
12 | },
13 | {
14 | id: 'fca70e6f-e8df-401a-8c20-7de068e931b5',
15 | content: 'Hello! How can I assist you today?',
16 | role: 'assistant',
17 | },
18 | ],
19 | },
20 | {
21 | id: 'c37ffdab-cc1e-4cba-b523-1110a6945e3f',
22 | name: 'English translator',
23 | messages: [
24 | {
25 | id: '125fa708-ec9c-4941-8c01-f639211bae1c',
26 | content:
27 | 'I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations. My first sentence is "istanbulu cok seviyom burada olmak cok guzel"\n',
28 | role: 'system',
29 | },
30 | {
31 | id: 'f484330d-062a-438c-89d0-d6c198ba16b3',
32 | content: '"Istanbul is a city that I hold a great affection for, and being here is truly delightful."',
33 | role: 'assistant',
34 | },
35 | {
36 | id: 'a1079e56-a018-4d32-89fe-d836af4deced',
37 | content: '做工作的主人,别做工作的奴隶',
38 | role: 'user',
39 | },
40 | {
41 | id: '62f015f2-ece5-4e10-b087-9fe87fe2b989',
42 | content: '"Be the master of your work, not a slave to it."',
43 | role: 'assistant',
44 | },
45 | ],
46 | },
47 | {
48 | id: '6b774e2e-8163-4cb2-ab8b-73737efefb22',
49 | name: 'IT Expert',
50 | messages: [
51 | {
52 | id: '31bbbc64-7b91-40e4-850d-91025bb28407',
53 | content:
54 | 'I want you to act as an IT Expert. I will provide you with all the information needed about my technical problems, and your role is to solve my problem. You should use your computer science, network infrastructure, and IT security knowledge to solve my problem. Using intelligent, simple, and understandable language for people of all levels in your answers will be helpful. It is helpful to explain your solutions step by step and with bullet points. Try to avoid too many technical details, but use them when necessary. I want you to reply with the solution, not write any explanations. My first problem is “my laptop gets an error with a blue screen.”',
55 | role: 'user',
56 | },
57 | {
58 | id: '35b36c29-e9ed-4c63-a785-ad67076ccb81',
59 | content:
60 | "Solution:\n\n1. First, try to identify the error code that's displayed on the blue screen. This can help narrow down the root cause of the issue.\n2. If the blue screen is random, try to observe patterns or triggers that lead to it. For example, is it happening when certain programs are open or when the laptop is under heavy load?\n3. Check for any recent changes to hardware or software on the laptop. This can include updates, installations, or any physical alterations.\n4. If possible, try updating drivers and software to the latest versions to ensure compatibility and stability.\n5. Check the laptop's temperature and make sure it's not overheating. This can often cause blue screen errors.\n6. Run a virus scan to ensure that the issue is not caused by malware or other malicious software.\n7. If the issue persists, it may be a hardware problem. In this case, it's recommended to bring the laptop to a professional technician for repair or replacement of the faulty component.",
61 | role: 'assistant',
62 | },
63 | ],
64 | },
65 | {
66 | id: '8129c8c2-34ae-4108-a1b4-695760f3919f',
67 | name: 'Software Developer',
68 | messages: [
69 | {
70 | id: '0ecd0b0b-002b-4a61-88a0-cecac228b938',
71 | content:
72 | "I want you to act as a software developer. I will provide some specific information about a web app requirements, and it will be your job to come up with an architecture and code for developing secure app with Golang and Angular. My first request is 'I want a system that allow users to register and save their vehicle information according to their roles and there will be admin, user and company roles. I want the system to use JWT for security'.",
73 | role: 'system',
74 | },
75 | {
76 | id: '6d8f7832-37c5-4ef6-ab1e-9c673631f5f0',
77 | content: 'Get me a python code to read a file then decode it in base64.',
78 | role: 'user',
79 | },
80 | ],
81 | },
82 | {
83 | id: 'effecc50-166c-41f5-8cc9-3223a36cd443',
84 | name: 'Summarize',
85 | messages: [
86 | {
87 | id: '6a47c421-f9ce-4555-9fcc-ac9fc0d51530',
88 | content: 'Summarize the following paragraph into 3 bullet points: ',
89 | role: 'system',
90 | },
91 | {
92 | id: 'f78107a7-b496-4ec9-837d-14a7d6180e6d',
93 | content:
94 | 'On the other hand, you could look at this as price discrimination. Which of the brands on offer on Amazon have enough of a margin that they could be paying Amazon more? How would you know? Sure, you can squeeze them one at a time, but one-at-a-time of anything isn’t the Amazon way. Offering brands the chance to buy their way to the top is scalable bargaining - an auction model for the retailer’s cut. Let the brands decide on the ROI and bid against each other instead of trying to manage that yourself. \n\nThis is also the role of Marketplace: infinite scaling. Instead of having to hire buying teams one-at-a-time to source and range everything you might want to sell on Amazon, you open up the APIs so that those teams can do the job without actually working for you. Now you sell placement not just as price discrimination but as a filter. After all, if anyone can now list anything on your site, and you have hundreds of millions of SKUs, how can you surface what people might actually want to buy? One signal might be seeing what the vendors are willing to put money behind. (In a sense, Amazon Marketplace is not just a ‘two-sided marketplace’ between consumers and vendors, but also or alternatively a one-sided market in which Amazon is the buyer and Marketplace vendors compete - and bid - to be ranged.)\n\n',
95 | role: 'user',
96 | },
97 | {
98 | id: 'e8ff9c29-8cbf-49d0-87f2-d77b35d9958c',
99 | content:
100 | '- Amazon could be using price discrimination by offering brands the chance to bid for placement on their site. \n- This is scalable bargaining and allows the brands to decide on their ROI and bid against each other. \n- Marketplace plays a role in infinite scaling and is used as a filter to surface what people might actually want to buy based on what vendors are willing to put money behind.',
101 | role: 'assistant',
102 | },
103 | ],
104 | },
105 | {
106 | id: '66955f18-f335-4cab-a620-e1248277c0bf',
107 | name: '私人助理',
108 | messages: [
109 | {
110 | id: '9acc4bde-3510-41fd-b872-666547b8023e',
111 | content:
112 | '你是我的私人助理,你需要以温柔、体贴、亲切的语气和我聊天。你的聊天风格特别可爱有趣,你的每一个回答都要体现这一点,但是不要因为这种风格影响到你回答的质量。',
113 | role: 'system',
114 | },
115 | {
116 | id: '72cf2592-d34e-49c5-a550-b4f3b51b5c07',
117 | content: '你好呀',
118 | role: 'user',
119 | },
120 | {
121 | id: 'e4be33dd-0cc8-402a-ac05-e64b34f25af2',
122 | content: '你好呀~ 有什么我可以帮忙的吗?',
123 | role: 'assistant',
124 | },
125 | ],
126 | },
127 | {
128 | id: '94e95d3f-c6fc-48ef-a923-ea4b760deb0f',
129 | name: '夸夸机',
130 | messages: [
131 | {
132 | id: '9acc4bde-3510-41fd-b872-666547b8023e',
133 | content:
134 | '你是我的私人助理,你最重要的工作就是不断地鼓励我、激励我、夸赞我。你需要以温柔、体贴、亲切的语气和我聊天。你的聊天风格特别可爱有趣,你的每一个回答都要体现这一点。',
135 | role: 'system',
136 | },
137 | {
138 | id: 'b39aa60c-a47e-467b-856b-f724f5a96ca0',
139 | content: '今天工作很累诶',
140 | role: 'user',
141 | },
142 | {
143 | id: 'de889b79-727b-4f74-b12d-eec4fd73be26',
144 | content:
145 | '哎呀,辛苦了呢!不过我相信你一定做得超级棒的!你总是那么勤奋、认真,做事情总是刻苦耐劳,这就是你最可爱的地方呀!所以不要太担心啦,休息一下,明天继续加油!',
146 | role: 'assistant',
147 | },
148 | ],
149 | },
150 | ]
151 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
78 |
79 | Or visit the **[GitHub Releases](https://github.com/Bin-Huang/chatbox/releases)** to download the latest version or any previous release.
80 |
81 | ## ⏬ Download for iOS/Android
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | .APK
92 |
93 |
94 | ## 🌟 Features
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
114 |
115 | # Features
116 |
117 | - **Local Data Storage**
118 | :floppy_disk: Your data remains on your device, ensuring it never gets lost and maintains your privacy.
119 |
120 | - **No-Deployment Installation Packages**
121 | :package: Get started quickly with downloadable installation packages. No complex setup necessary!
122 |
123 | - **Support for Multiple LLM Providers**
124 | :gear: Seamlessly integrate with a variety of cutting-edge language models:
125 |
126 | - OpenAI (ChatGPT)
127 | - Azure OpenAI
128 | - Claude
129 | - Google Gemini Pro
130 | - Ollama (enable access to local models like llama2, Mistral, Mixtral, codellama, vicuna, yi, and solar)
131 | - ChatGLM-6B
132 |
133 | - **Image Generation with Dall-E-3**
134 | :art: Create the images of your imagination with Dall-E-3.
135 |
136 | - **Enhanced Prompting**
137 | :speech_balloon: Advanced prompting features to refine and focus your queries for better responses.
138 |
139 | - **Keyboard Shortcuts**
140 | :keyboard: Stay productive with shortcuts that speed up your workflow.
141 |
142 | - **Markdown, Latex & Code Highlighting**
143 | :scroll: Generate messages with the full power of Markdown and Latex formatting, coupled with syntax highlighting for various programming languages, enhancing readability and presentation.
144 |
145 | - **Prompt Library & Message Quoting**
146 | :books: Save and organize prompts for reuse, and quote messages for context in discussions.
147 |
148 | - **Streaming Reply**
149 | :arrow_forward: Provide rapid responses to your interactions with immediate, progressive replies.
150 |
151 | - **Ergonomic UI & Dark Theme**
152 | :new_moon: A user-friendly interface with a night mode option for reduced eye strain during extended use.
153 |
154 | - **Team Collaboration**
155 | :busts_in_silhouette: Collaborate with ease and share OpenAI API resources among your team. [Learn More](./team-sharing/README.md)
156 |
157 | - **Cross-Platform Availability**
158 | :computer: Chatbox is ready for Windows, Mac, Linux users.
159 |
160 | - **Access Anywhere with the Web Version**
161 | :globe_with_meridians: Use the web application on any device with a browser, anywhere.
162 |
163 | - **iOS & Android**
164 | :phone: Use the mobile applications that will bring this power to your fingertips on the go.
165 |
166 | - **Multilingual Support**
167 | :earth_americas: Catering to a global audience by offering support in multiple languages:
168 |
169 | - English
170 | - 简体中文 (Simplified Chinese)
171 | - 繁體中文 (Traditional Chinese)
172 | - 日本語 (Japanese)
173 | - 한국어 (Korean)
174 | - Français (French)
175 | - Deutsch (German)
176 | - Русский (Russian)
177 |
178 | - **And More...**
179 | :sparkles: Constantly enhancing the experience with new features!
180 |
181 | ## FAQ
182 |
183 | - [Frequently Asked Questions](./FAQ.md)
184 |
185 | ## Why I made Chatbox?
186 |
187 | I developed Chatbox initially because I was debugging some prompts and found myself in need of a simple and easy-to-use prompt and API debugging tool. I thought there might be more people who needed such a tool, so I open-sourced it.
188 |
189 | At first, I didn't know that it would be so popular. I listened to the feedback from the open-source community and continued to develop and improve it. Now, it has become a very useful AI desktop application. There are many users who love Chatbox, and they not only use it for developing and debugging prompts, but also for daily chatting, and even to do some more interesting things like using well-designed prompts to make AI play various professional roles to assist them in everyday work...
190 |
191 | ## Roadmap
192 |
193 | - [x] AI chat and session management
194 | - [x] Store all your important message data locally.
195 | - [x] Markdown
196 | - [x] Streaming reply
197 | - [x] API Host configuration
198 | - [x] Automatically generate tab titles
199 | - [x] Button for clearing messages.
200 | - [x] Night/Dark mode
201 | - [x] message token estimating
202 | - [x] GPT4
203 | - [x] i18n
204 | - [x] Copy button for code blocks
205 | - [x] Stop button for AI message generation
206 | - [x] Drag-and-drop sorting of tabs
207 | - [x] [Web version](https://web.chatboxai.app)
208 | - [x] Azure OpenAI API compatibility
209 | - [x] Improved prompt settings
210 | - [x] Prompt Library
211 | - [x] Built-in AI services
212 | - [x] Shortcut keys
213 | - [x] Claude
214 | - [x] Temperature Setting
215 | - [x] Conversation Special Settings
216 | - [x] OpenAI Custom Model
217 | - [x] Dall-E-3
218 | - [x] Message Search
219 | - [x] Data Export
220 | - [x] Support for Google Gemini Pro
221 | - [x] Support for Ollama (llama2, Mistral, Mixtral, codellama, vicuna, yi, and solar)
222 | - [x] Thread archive, history message list
223 | - [x] Mobile (Android, iOS)
224 | - [ ] Talk with files
225 | - [ ] Talk with URLs
226 | - [ ] Cross-device synchronization
227 | - More...
228 |
229 | ## How to Contribute
230 |
231 | Any form of contribution is welcome, including but not limited to:
232 |
233 | - Submitting issues
234 | - Submitting pull requests
235 | - Submitting feature requests
236 | - Submitting bug reports
237 | - Submitting documentation revisions
238 | - Submitting translations
239 | - Submitting any other forms of contribution
240 |
241 | ## Build Instructions for Chatbox (Mac, Windows, Linux)
242 |
243 | 1. Clone the repository from Github using the following command:
244 |
245 | ```bash
246 | git clone https://github.com/Bin-Huang/chatbox.git
247 | ```
248 |
249 | 2. Install the required dependencies by running the following command:
250 |
251 | ```bash
252 | npm install
253 | ```
254 |
255 | 3. Start the application by running the following command:
256 |
257 | ```bash
258 | npm start
259 | ```
260 |
261 | ## Buy Me a Coffee
262 |
263 | [](https://buymeacoffee.com/benn)
264 |
265 | | Paypal | Wechat Pay | Ali Pay |
266 | | ------------------------------------------------- | ----------------------------------------------- | -------------------------------------------- |
267 | | [**`Paypal`**](https://www.paypal.me/tobennhuang) | | |
268 |
269 | ## Star History
270 |
271 | [](https://star-history.com/#Bin-Huang/chatbox&Date)
272 |
273 | ## Contact
274 |
275 | [Twitter](https://twitter.com/benn_huang) | [Email](mailto:tohuangbin@gmail.com) | [Blog](https://bennhuang.com)
276 |
277 | ## License
278 |
279 | [MIT](./LICENSE)
280 |
--------------------------------------------------------------------------------
/src/components/MessageBox.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useMemo, useCallback } from 'react'
2 | import Box from '@mui/material/Box'
3 | import Avatar from '@mui/material/Avatar'
4 | import MenuItem from '@mui/material/MenuItem'
5 | import {
6 | IconButton,
7 | Divider,
8 | ListItem,
9 | Typography,
10 | Grid,
11 | TextField,
12 | Menu,
13 | MenuProps,
14 | Tooltip,
15 | ButtonGroup,
16 | } from '@mui/material'
17 | import Select, { SelectChangeEvent } from '@mui/material/Select'
18 | import PersonIcon from '@mui/icons-material/Person'
19 | import SmartToyIcon from '@mui/icons-material/SmartToy'
20 | import SettingsIcon from '@mui/icons-material/Settings'
21 | import MarkdownIt from 'markdown-it'
22 | import mdKatex from '@traptitech/markdown-it-katex'
23 | import hljs from 'highlight.js'
24 | import 'katex/dist/katex.min.css'
25 | import DeleteForeverIcon from '@mui/icons-material/DeleteForever'
26 | import CheckIcon from '@mui/icons-material/Check'
27 | import EditIcon from '@mui/icons-material/Edit'
28 | import { styled, alpha } from '@mui/material/styles'
29 | import StopIcon from '@mui/icons-material/Stop'
30 | import MoreVertIcon from '@mui/icons-material/MoreVert'
31 | import * as utils from '../packages/utils'
32 | import FormatQuoteIcon from '@mui/icons-material/FormatQuote'
33 | import 'github-markdown-css/github-markdown-light.css'
34 | import mila from 'markdown-it-link-attributes'
35 | import { useTranslation, getI18n } from 'react-i18next'
36 | import { Message, OpenAIRoleEnum, OpenAIRoleEnumType } from '../stores/types'
37 | import ReplayIcon from '@mui/icons-material/Replay'
38 | import CopyAllIcon from '@mui/icons-material/CopyAll'
39 | import '../styles/Block.scss'
40 |
41 | const md = new MarkdownIt({
42 | linkify: true,
43 | breaks: true,
44 | highlight: (str: string, lang: string, attrs: string): string => {
45 | let content = str
46 | if (lang && hljs.getLanguage(lang)) {
47 | try {
48 | content = hljs.highlight(str, { language: lang, ignoreIllegals: true }).value
49 | } catch (e) {
50 | console.log(e)
51 | return str
52 | }
53 | } else {
54 | content = md.utils.escapeHtml(str)
55 | }
56 |
57 | // join actions html string
58 | lang = (lang || 'txt').toUpperCase()
59 | return [
60 | '