@lobehub/chat 0.150.4 → 0.150.6
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 +50 -0
- package/docs/usage/providers/ollama.mdx +154 -43
- package/docs/usage/providers/ollama.zh-CN.mdx +147 -37
- package/package.json +5 -3
- package/src/app/api/proxy/route.ts +25 -3
- package/src/app/chat/features/SessionSearchBar/index.tsx +3 -7
- package/src/database/client/models/session.ts +5 -5
- package/src/server/routers/config/parseDefaultAgent.test.ts +14 -0
- package/src/server/routers/config/parseDefaultAgent.ts +5 -0
- package/src/store/agent/slices/chat/__snapshots__/selectors.test.ts.snap +1 -1
- package/src/store/session/slices/session/action.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.150.6](https://github.com/lobehub/lobe-chat/compare/v0.150.5...v0.150.6)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-04-28**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix `/api/proxy` internal proxy attack.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix `/api/proxy` internal proxy attack, closes [#2255](https://github.com/lobehub/lobe-chat/issues/2255) ([465665a](https://github.com/lobehub/lobe-chat/commit/465665a))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.150.5](https://github.com/lobehub/lobe-chat/compare/v0.150.4...v0.150.5)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2024-04-27**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Fix the plugin string env and search error.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Fix the plugin string env and search error, closes [#2239](https://github.com/lobehub/lobe-chat/issues/2239) ([74b1ae0](https://github.com/lobehub/lobe-chat/commit/74b1ae0))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
### [Version 0.150.4](https://github.com/lobehub/lobe-chat/compare/v0.150.3...v0.150.4)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2024-04-27**</sup>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Using Ollama in LobeChat
|
|
3
|
-
description:
|
|
3
|
+
description: >-
|
|
4
|
+
Learn how to use Ollama in LobeChat, run LLM locally, and experience
|
|
5
|
+
cutting-edge AI usage.
|
|
4
6
|
tags:
|
|
5
7
|
- Ollama
|
|
6
8
|
- LobeChat
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- 自定义配置
|
|
9
|
+
- Local LLM
|
|
10
|
+
- Ollama WebUI
|
|
10
11
|
---
|
|
11
12
|
|
|
12
13
|
# Using Ollama in LobeChat
|
|
@@ -18,76 +19,186 @@ tags:
|
|
|
18
19
|
src={'https://github.com/lobehub/lobe-chat/assets/28616219/a2a091b8-ac45-4679-b5e0-21d711e17fef'}
|
|
19
20
|
/>
|
|
20
21
|
|
|
21
|
-
Ollama is a powerful framework for running large language models (LLMs) locally, supporting various language models including Llama 2, Mistral, and more. Now, LobeChat supports integration with Ollama, meaning you can easily
|
|
22
|
+
Ollama is a powerful framework for running large language models (LLMs) locally, supporting various language models including Llama 2, Mistral, and more. Now, LobeChat supports integration with Ollama, meaning you can easily enhance your application by using the language models provided by Ollama in LobeChat.
|
|
22
23
|
|
|
23
24
|
This document will guide you on how to use Ollama in LobeChat:
|
|
24
25
|
|
|
26
|
+
<Video
|
|
27
|
+
alt="demonstration of using Ollama in LobeChat"
|
|
28
|
+
height={556}
|
|
29
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/c32b56db-c6a1-4876-9bc3-acbd37ec0c0c"
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
## Using Ollama on macOS
|
|
33
|
+
|
|
25
34
|
<Steps>
|
|
26
|
-
### Local Installation of Ollama
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
### Local Installation of Ollama
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
<Tab>[Download Ollama for macOS](https://ollama.com/download) and unzip it.</Tab>
|
|
38
|
+
[Download Ollama for macOS](https://ollama.com/download?utm_source=lobehub&utm_medium=docs&utm_campaign=download-macos) and unzip/install it.
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
````bash
|
|
35
|
-
Install using the following command:
|
|
40
|
+
### Configure Ollama for Cross-Origin Access
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
curl -fsSL https://ollama.com/install.sh | sh
|
|
39
|
-
````
|
|
42
|
+
Due to Ollama's default configuration, which restricts access to local only, additional environment variable setting `OLLAMA_ORIGINS` is required for cross-origin access and port listening. Use `launchctl` to set the environment variable:
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
```bash
|
|
45
|
+
launchctl setenv OLLAMA_ORIGINS "*"
|
|
46
|
+
```
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
After setting up, restart the Ollama application.
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
### Conversing with Local Large Models in LobeChat
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
If you prefer using Docker, Ollama also provides an official Docker image, which you can pull using the following command:
|
|
52
|
+
Now, you can start conversing with the local LLM in LobeChat.
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
<Image
|
|
55
|
+
alt="Chat with llama3 in LobeChat"
|
|
56
|
+
height="573"
|
|
57
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/7f9a9a9f-fd91-4f59-aac9-3f26c6d49a1e"
|
|
58
|
+
/>
|
|
53
59
|
|
|
54
|
-
</
|
|
60
|
+
</Steps>
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
## Using Ollama on Windows
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
<Steps>
|
|
65
|
+
|
|
66
|
+
### Local Installation of Ollama
|
|
67
|
+
|
|
68
|
+
[Download Ollama for Windows](https://ollama.com/download?utm_source=lobehub&utm_medium=docs&utm_campaign=download-windows) and install it.
|
|
69
|
+
|
|
70
|
+
### Configure Ollama for Cross-Origin Access
|
|
71
|
+
|
|
72
|
+
Since Ollama's default configuration allows local access only, additional environment variable setting `OLLAMA_ORIGINS` is needed for cross-origin access and port listening.
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
On Windows, Ollama inherits your user and system environment variables.
|
|
75
|
+
|
|
76
|
+
1. First, exit the Ollama program by clicking on it in the Windows taskbar.
|
|
77
|
+
2. Edit system environment variables from the Control Panel.
|
|
78
|
+
3. Edit or create the Ollama environment variable `OLLAMA_ORIGINS` for your user account, setting the value to `*`.
|
|
79
|
+
4. Click `OK/Apply` to save and restart the system.
|
|
80
|
+
5. Run `Ollama` again.
|
|
81
|
+
|
|
82
|
+
### Conversing with Local Large Models in LobeChat
|
|
83
|
+
|
|
84
|
+
Now, you can start conversing with the local LLM in LobeChat.
|
|
85
|
+
|
|
86
|
+
</Steps>
|
|
87
|
+
|
|
88
|
+
## Using Ollama on Linux
|
|
89
|
+
|
|
90
|
+
<Steps>
|
|
91
|
+
|
|
92
|
+
### Local Installation of Ollama
|
|
93
|
+
|
|
94
|
+
Install using the following command:
|
|
61
95
|
|
|
62
96
|
```bash
|
|
63
|
-
ollama
|
|
97
|
+
curl -fsSL https://ollama.com/install.sh | sh
|
|
64
98
|
```
|
|
65
99
|
|
|
66
|
-
|
|
100
|
+
Alternatively, you can refer to the [Linux manual installation guide](https://github.com/ollama/ollama/blob/main/docs/linux.md).
|
|
67
101
|
|
|
68
|
-
###
|
|
102
|
+
### Configure Ollama for Cross-Origin Access
|
|
69
103
|
|
|
70
|
-
|
|
104
|
+
Due to Ollama's default configuration, which allows local access only, additional environment variable setting `OLLAMA_ORIGINS` is required for cross-origin access and port listening. If Ollama runs as a systemd service, use `systemctl` to set the environment variable:
|
|
71
105
|
|
|
72
|
-
|
|
73
|
-
height={524}
|
|
74
|
-
inStep
|
|
75
|
-
src="https://github.com/lobehub/lobe-chat/assets/28616219/063788c8-9fef-4c6b-b837-96668ad6bc41"
|
|
76
|
-
/>
|
|
106
|
+
1. Edit the systemd service by calling `sudo systemctl edit ollama.service`:
|
|
77
107
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
108
|
+
```bash
|
|
109
|
+
sudo systemctl edit ollama.service
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
2. Add `Environment` under `[Service]` for each environment variable:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
[Service]
|
|
116
|
+
Environment="OLLAMA_HOST=0.0.0.0"
|
|
117
|
+
Environment="OLLAMA_ORIGINS=*"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
3. Save and exit.
|
|
121
|
+
4. Reload `systemd` and restart Ollama:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
sudo systemctl daemon-reload
|
|
125
|
+
sudo systemctl restart ollama
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Conversing with Local Large Models in LobeChat
|
|
129
|
+
|
|
130
|
+
Now, you can start conversing with the local LLM in LobeChat.
|
|
131
|
+
|
|
132
|
+
</Steps>
|
|
133
|
+
|
|
134
|
+
## Deploying Ollama using Docker
|
|
135
|
+
|
|
136
|
+
<Steps>
|
|
137
|
+
|
|
138
|
+
### Pulling Ollama Image
|
|
139
|
+
|
|
140
|
+
If you prefer using Docker, Ollama provides an official Docker image that you can pull using the following command:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
docker pull ollama/ollama
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Configure Ollama for Cross-Origin Access
|
|
147
|
+
|
|
148
|
+
Since Ollama's default configuration allows local access only, additional environment variable setting `OLLAMA_ORIGINS` is needed for cross-origin access and port listening.
|
|
149
|
+
|
|
150
|
+
If Ollama runs as a Docker container, you can add the environment variable to the `docker run` command.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
docker run -d --gpus=all -v ollama:/root/.ollama -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Conversing with Local Large Models in LobeChat
|
|
157
|
+
|
|
158
|
+
Now, you can start conversing with the local LLM in LobeChat.
|
|
81
159
|
|
|
82
|
-
</Callout>
|
|
83
160
|
</Steps>
|
|
84
161
|
|
|
162
|
+
## Installing Ollama Models
|
|
163
|
+
|
|
164
|
+
Ollama supports various models, which you can view in the [Ollama Library](https://ollama.com/library) and choose the appropriate model based on your needs.
|
|
165
|
+
|
|
166
|
+
### Installation in LobeChat
|
|
167
|
+
|
|
168
|
+
In LobeChat, we have enabled some common large language models by default, such as llama3, Gemma, Mistral, etc. When you select a model for conversation, we will prompt you to download that model.
|
|
169
|
+
|
|
170
|
+
<Image
|
|
171
|
+
alt="LobeChat guide your to install Ollama model"
|
|
172
|
+
height="460"
|
|
173
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/4e81decc-776c-43b8-9a54-dfb43e9f601a"
|
|
174
|
+
/>
|
|
175
|
+
|
|
176
|
+
Once downloaded, you can start conversing.
|
|
177
|
+
|
|
178
|
+
### Pulling Models to Local with Ollama
|
|
179
|
+
|
|
180
|
+
Alternatively, you can install models by executing the following command in the terminal, using llama3 as an example:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
ollama pull llama3
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
<Video
|
|
187
|
+
height="524"
|
|
188
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/95828c11-0ae5-4dfa-84ed-854124e927a6"
|
|
189
|
+
/>
|
|
190
|
+
|
|
85
191
|
## Custom Configuration
|
|
86
192
|
|
|
87
|
-
You can find Ollama's configuration options in `Settings` -> `Language
|
|
193
|
+
You can find Ollama's configuration options in `Settings` -> `Language Models`, where you can configure Ollama's proxy, model names, etc.
|
|
88
194
|
|
|
89
195
|
<Image
|
|
90
|
-
alt={'Ollama
|
|
196
|
+
alt={'Ollama Provider Settings'}
|
|
91
197
|
height={274}
|
|
92
|
-
src={'https://github.com/lobehub/lobe-chat/assets/28616219/
|
|
198
|
+
src={'https://github.com/lobehub/lobe-chat/assets/28616219/54b3696b-5b13-4761-8c1b-1e664867b2dd'}
|
|
93
199
|
/>
|
|
200
|
+
|
|
201
|
+
<Callout type={'info'}>
|
|
202
|
+
Visit [Integrating with Ollama](/docs/self-hosting/examples/ollama) to learn how to deploy
|
|
203
|
+
LobeChat to meet integration needs with Ollama.
|
|
204
|
+
</Callout>
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 在 LobeChat 中使用 Ollama
|
|
3
|
-
description:
|
|
3
|
+
description: 了解如何在 LobeChat 中使用 Ollama ,在你的本地运行大型语言模型,获得最前沿的 AI 使用体验。
|
|
4
4
|
tags:
|
|
5
5
|
- Ollama
|
|
6
6
|
- LobeChat
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- LLM
|
|
10
|
-
- 集成指南
|
|
7
|
+
- Local LLM
|
|
8
|
+
- Ollama WebUI
|
|
11
9
|
---
|
|
12
10
|
|
|
13
11
|
# 在 LobeChat 中使用 Ollama
|
|
@@ -23,64 +21,171 @@ Ollama 是一款强大的本地运行大型语言模型(LLM)的框架,支
|
|
|
23
21
|
|
|
24
22
|
本文档将指导你如何在 LobeChat 中使用 Ollama:
|
|
25
23
|
|
|
24
|
+
<Video
|
|
25
|
+
alt={'在 LobeChat 中使用 Ollama的完整演示'}
|
|
26
|
+
height={556}
|
|
27
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/c32b56db-c6a1-4876-9bc3-acbd37ec0c0c"
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
## 在 macOS 下使用 Ollama
|
|
31
|
+
|
|
26
32
|
<Steps>
|
|
27
|
-
### 本地安装 Ollama
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
### 本地安装 Ollama
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
<Tab>[下载 Ollama for macOS](https://ollama.com/download) 并解压。</Tab>
|
|
36
|
+
[下载 Ollama for macOS](https://ollama.com/download?utm_source=lobehub&utm_medium=docs&utm_campaign=download-macos) 并解压、安装。
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
通过以下命令安装:
|
|
38
|
+
### 配置 Ollama 允许跨域访问
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
curl -fsSL https://ollama.com/install.sh | sh
|
|
39
|
-
```
|
|
40
|
+
由于 Ollama 的默认参数配置,启动时设置了仅本地访问,所以跨域访问以及端口监听需要进行额外的环境变量设置 `OLLAMA_ORIGINS`。使用 `launchctl` 设置环境变量:
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
```bash
|
|
43
|
+
launchctl setenv OLLAMA_ORIGINS "*"
|
|
44
|
+
```
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
完成设置后,需要重启 Ollama 应用程序。
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
### 在 LobeChat 中与本地大模型对话
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
如果你更倾向于使用 Docker,Ollama 也提供了官方 Docker 镜像,你可以通过以下命令拉取:
|
|
50
|
+
接下来,你就可以使用 LobeChat 与本地 LLM 对话了。
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
<Image
|
|
53
|
+
alt="在 LobeChat 中与 llama3 对话"
|
|
54
|
+
height="573"
|
|
55
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/7f9a9a9f-fd91-4f59-aac9-3f26c6d49a1e"
|
|
56
|
+
/>
|
|
53
57
|
|
|
54
|
-
</
|
|
58
|
+
</Steps>
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
## 在 windows 下使用 Ollama
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
<Steps>
|
|
63
|
+
|
|
64
|
+
### 本地安装 Ollama
|
|
65
|
+
|
|
66
|
+
[下载 Ollama for Windows](https://ollama.com/download?utm_source=lobehub&utm_medium=docs&utm_campaign=download-windows) 并安装。
|
|
67
|
+
|
|
68
|
+
### 配置 Ollama 允许跨域访问
|
|
69
|
+
|
|
70
|
+
由于 Ollama 的默认参数配置,启动时设置了仅本地访问,所以跨域访问以及端口监听需要进行额外的环境变量设置 `OLLAMA_ORIGINS`。
|
|
71
|
+
|
|
72
|
+
在 Windows 上,Ollama 继承了您的用户和系统环境变量。
|
|
73
|
+
|
|
74
|
+
1. 首先通过 Windows 任务栏点击 Ollama 退出程序。
|
|
75
|
+
2. 从控制面板编辑系统环境变量。
|
|
76
|
+
3. 为您的用户账户编辑或新建 Ollama 的环境变量 `OLLAMA_ORIGINS`,值设为 `*` 。
|
|
77
|
+
4. 点击`OK/应用`保存后重启系统。
|
|
78
|
+
5. 重新运行`Ollama`。
|
|
79
|
+
|
|
80
|
+
### 在 LobeChat 中与本地大模型对话
|
|
81
|
+
|
|
82
|
+
接下来,你就可以使用 LobeChat 与本地 LLM 对话了。
|
|
59
83
|
|
|
60
|
-
|
|
84
|
+
</Steps>
|
|
85
|
+
|
|
86
|
+
## 在 linux 下使用 Ollama
|
|
87
|
+
|
|
88
|
+
<Steps>
|
|
89
|
+
|
|
90
|
+
### 本地安装 Ollama
|
|
91
|
+
|
|
92
|
+
通过以下命令安装:
|
|
61
93
|
|
|
62
94
|
```bash
|
|
63
|
-
ollama
|
|
95
|
+
curl -fsSL https://ollama.com/install.sh | sh
|
|
64
96
|
```
|
|
65
97
|
|
|
66
|
-
|
|
98
|
+
或者,你也可以参考 [Linux 手动安装指南](https://github.com/ollama/ollama/blob/main/docs/linux.md)。
|
|
99
|
+
|
|
100
|
+
### 配置 Ollama 允许跨域访问
|
|
101
|
+
|
|
102
|
+
由于 Ollama 的默认参数配置,启动时设置了仅本地访问,所以跨域访问以及端口监听需要进行额外的环境变量设置 `OLLAMA_ORIGINS`。如果 Ollama 作为 systemd 服务运行,应该使用`systemctl`设置环境变量:
|
|
103
|
+
|
|
104
|
+
1. 通过调用`sudo systemctl edit ollama.service`编辑 systemd 服务。
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
sudo systemctl edit ollama.service
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
2. 对于每个环境变量,在`[Service]`部分下添加`Environment`:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
[Service]
|
|
114
|
+
Environment="OLLAMA_HOST=0.0.0.0"
|
|
115
|
+
Environment="OLLAMA_ORIGINS=*"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
3. 保存并退出。
|
|
119
|
+
4. 重载 `systemd` 并重启 Ollama:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sudo systemctl daemon-reload
|
|
123
|
+
sudo systemctl restart ollama
|
|
124
|
+
```
|
|
67
125
|
|
|
68
|
-
### 在 LobeChat
|
|
126
|
+
### 在 LobeChat 中与本地大模型对话
|
|
69
127
|
|
|
70
128
|
接下来,你就可以使用 LobeChat 与本地 LLM 对话了。
|
|
71
129
|
|
|
130
|
+
</Steps>
|
|
131
|
+
|
|
132
|
+
## 使用 docker 部署使用 Ollama
|
|
133
|
+
|
|
134
|
+
<Steps>
|
|
135
|
+
|
|
136
|
+
### 拉取 Ollama 镜像
|
|
137
|
+
|
|
138
|
+
如果你更倾向于使用 Docker,Ollama 也提供了官方 Docker 镜像,你可以通过以下命令拉取:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
docker pull ollama/ollama
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 配置 Ollama 允许跨域访问
|
|
145
|
+
|
|
146
|
+
由于 Ollama 的默认参数配置,启动时设置了仅本地访问,所以跨域访问以及端口监听需要进行额外的环境变量设置 `OLLAMA_ORIGINS`。
|
|
147
|
+
|
|
148
|
+
如果 Ollama 作为 Docker 容器运行,你可以将环境变量添加到 `docker run` 命令中。
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
docker run -d --gpus=all -v ollama:/root/.ollama -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 在 LobeChat 中与本地大模型对话
|
|
155
|
+
|
|
156
|
+
接下来,你就可以使用 LobeChat 与本地 LLM 对话了。
|
|
157
|
+
|
|
158
|
+
</Steps>
|
|
159
|
+
|
|
160
|
+
## 安装 Ollama 模型
|
|
161
|
+
|
|
162
|
+
Ollama 支持多种模型,你可以在 [Ollama Library](https://ollama.com/library) 中查看可用的模型列表,并根据需求选择合适的模型。
|
|
163
|
+
|
|
164
|
+
### LobeChat 中安装
|
|
165
|
+
|
|
166
|
+
在 LobeChat 中,我们默认开启了一些常用的大语言模型,例如 llama3、 Gemma 、 Mistral 等。当你选中模型进行对话时,我们会提示你需要下载该模型。
|
|
167
|
+
|
|
168
|
+
<Image
|
|
169
|
+
alt="LobeChat 提示安装 Ollama 模型"
|
|
170
|
+
height="460"
|
|
171
|
+
src="https://github.com/lobehub/lobe-chat/assets/28616219/4e81decc-776c-43b8-9a54-dfb43e9f601a"
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
下载完成后即可开始对话。
|
|
175
|
+
|
|
176
|
+
### 用 Ollama 拉取模型到本地
|
|
177
|
+
|
|
178
|
+
当然,你也可以通过在终端执行以下命令安装模型,以 llama3 为例:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
ollama pull llama3
|
|
182
|
+
```
|
|
183
|
+
|
|
72
184
|
<Video
|
|
73
185
|
height={524}
|
|
74
|
-
inStep
|
|
75
186
|
src="https://github.com/lobehub/lobe-chat/assets/28616219/95828c11-0ae5-4dfa-84ed-854124e927a6"
|
|
76
187
|
/>
|
|
77
188
|
|
|
78
|
-
<Callout type={'info'}>
|
|
79
|
-
你可以前往 [与 Ollama 集成](/docs/self-hosting/examples/ollama) 了解如何部署 LobeChat ,以满足与 Ollama 的集成需求。
|
|
80
|
-
|
|
81
|
-
</Callout>
|
|
82
|
-
</Steps>
|
|
83
|
-
|
|
84
189
|
## 自定义配置
|
|
85
190
|
|
|
86
191
|
你可以在 `设置` -> `语言模型` 中找到 Ollama 的配置选项,你可以在这里配置 Ollama 的代理、模型名称等。
|
|
@@ -88,5 +193,10 @@ Ollama 支持多种模型,你可以在 [Ollama Library](https://ollama.com/lib
|
|
|
88
193
|
<Image
|
|
89
194
|
alt={'Ollama 服务商设置'}
|
|
90
195
|
height={274}
|
|
91
|
-
src={'https://github.com/lobehub/lobe-chat/assets/28616219/
|
|
196
|
+
src={'https://github.com/lobehub/lobe-chat/assets/28616219/54b3696b-5b13-4761-8c1b-1e664867b2dd'}
|
|
92
197
|
/>
|
|
198
|
+
|
|
199
|
+
<Callout type={'info'}>
|
|
200
|
+
你可以前往 [与 Ollama 集成](/zh/docs/self-hosting/examples/ollama) 了解如何部署 LobeChat
|
|
201
|
+
,以满足与 Ollama 的集成需求。
|
|
202
|
+
</Callout>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.150.
|
|
3
|
+
"version": "0.150.6",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@aws-sdk/client-bedrock-runtime": "^3.556.0",
|
|
87
87
|
"@azure/openai": "^1.0.0-beta.12",
|
|
88
88
|
"@cfworker/json-schema": "^1.12.8",
|
|
89
|
-
"@google/generative-ai": "^0.
|
|
89
|
+
"@google/generative-ai": "^0.8.0",
|
|
90
90
|
"@icons-pack/react-simple-icons": "^9.4.1",
|
|
91
91
|
"@lobehub/chat-plugin-sdk": "latest",
|
|
92
92
|
"@lobehub/chat-plugins-gateway": "latest",
|
|
@@ -118,6 +118,7 @@
|
|
|
118
118
|
"i18next-resources-to-backend": "^1.2.1",
|
|
119
119
|
"idb-keyval": "^6.2.1",
|
|
120
120
|
"immer": "^10.0.4",
|
|
121
|
+
"ip": "^2.0.1",
|
|
121
122
|
"jose": "^5.2.4",
|
|
122
123
|
"langfuse": "^3.7.0",
|
|
123
124
|
"langfuse-core": "^3.7.0",
|
|
@@ -132,7 +133,7 @@
|
|
|
132
133
|
"nuqs": "^1.17.1",
|
|
133
134
|
"ollama": "^0.5.0",
|
|
134
135
|
"openai": "^4.38.2",
|
|
135
|
-
"pino": "^
|
|
136
|
+
"pino": "^9.0.0",
|
|
136
137
|
"polished": "^4.3.1",
|
|
137
138
|
"posthog-js": "^1.128.1",
|
|
138
139
|
"query-string": "^9.0.0",
|
|
@@ -183,6 +184,7 @@
|
|
|
183
184
|
"@types/chroma-js": "^2.4.4",
|
|
184
185
|
"@types/debug": "^4.1.12",
|
|
185
186
|
"@types/diff": "^5.2.0",
|
|
187
|
+
"@types/ip": "^1.1.3",
|
|
186
188
|
"@types/json-schema": "^7.0.15",
|
|
187
189
|
"@types/lodash": "^4.17.0",
|
|
188
190
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { isPrivate } from 'ip';
|
|
2
|
+
import { NextResponse } from 'next/server';
|
|
3
|
+
import dns from 'node:dns';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
|
|
6
|
+
const lookupAsync = promisify(dns.lookup);
|
|
7
|
+
|
|
8
|
+
export const runtime = 'nodejs';
|
|
2
9
|
|
|
3
10
|
/**
|
|
4
11
|
* just for a proxy
|
|
5
12
|
*/
|
|
6
13
|
export const POST = async (req: Request) => {
|
|
7
|
-
const url = await req.text();
|
|
14
|
+
const url = new URL(await req.text());
|
|
15
|
+
let address;
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const lookupResult = await lookupAsync(url.hostname);
|
|
19
|
+
address = lookupResult.address;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error(`${url.hostname} DNS parser error:`, err);
|
|
22
|
+
|
|
23
|
+
return NextResponse.json({ error: 'DNS parser error' }, { status: 504 });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const isInternalHost = isPrivate(address);
|
|
27
|
+
|
|
28
|
+
if (isInternalHost)
|
|
29
|
+
return NextResponse.json({ error: 'Not support internal host proxy' }, { status: 400 });
|
|
8
30
|
|
|
9
|
-
const res = await fetch(url);
|
|
31
|
+
const res = await fetch(url.toString());
|
|
10
32
|
|
|
11
33
|
return new Response(res.body, { headers: res.headers });
|
|
12
34
|
};
|
|
@@ -8,9 +8,10 @@ import { useSessionStore } from '@/store/session';
|
|
|
8
8
|
const SessionSearchBar = memo<{ mobile?: boolean }>(({ mobile: controlledMobile }) => {
|
|
9
9
|
const { t } = useTranslation('chat');
|
|
10
10
|
|
|
11
|
-
const [keywords, useSearchSessions] = useSessionStore((s) => [
|
|
11
|
+
const [keywords, useSearchSessions, updateSearchKeywords] = useSessionStore((s) => [
|
|
12
12
|
s.sessionSearchKeywords,
|
|
13
13
|
s.useSearchSessions,
|
|
14
|
+
s.updateSearchKeywords,
|
|
14
15
|
]);
|
|
15
16
|
|
|
16
17
|
const { isValidating } = useSearchSessions(keywords);
|
|
@@ -24,12 +25,7 @@ const SessionSearchBar = memo<{ mobile?: boolean }>(({ mobile: controlledMobile
|
|
|
24
25
|
enableShortKey={!mobile}
|
|
25
26
|
loading={isValidating}
|
|
26
27
|
onChange={(e) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
useSessionStore.setState({
|
|
30
|
-
isSearching: !!newKeywords,
|
|
31
|
-
sessionSearchKeywords: newKeywords,
|
|
32
|
-
});
|
|
28
|
+
updateSearchKeywords(e.target.value);
|
|
33
29
|
}}
|
|
34
30
|
placeholder={t('searchAgentPlaceholder')}
|
|
35
31
|
shortKey={'k'}
|
|
@@ -81,15 +81,15 @@ class _SessionModel extends BaseModel {
|
|
|
81
81
|
async queryByKeyword(keyword: string): Promise<LobeSessions> {
|
|
82
82
|
if (!keyword) return [];
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
const startTime = Date.now();
|
|
85
85
|
const keywordLowerCase = keyword.toLowerCase();
|
|
86
86
|
|
|
87
87
|
// First, filter sessions by title and description
|
|
88
88
|
const matchingSessionsPromise = this.table
|
|
89
89
|
.filter((session) => {
|
|
90
90
|
return (
|
|
91
|
-
session.meta.title
|
|
92
|
-
session.meta.description
|
|
91
|
+
session.meta.title?.toLowerCase().includes(keywordLowerCase) ||
|
|
92
|
+
session.meta.description?.toLowerCase().includes(keywordLowerCase)
|
|
93
93
|
);
|
|
94
94
|
})
|
|
95
95
|
.toArray();
|
|
@@ -112,7 +112,7 @@ class _SessionModel extends BaseModel {
|
|
|
112
112
|
// match topics
|
|
113
113
|
const matchingTopicsPromise = this.db.topics
|
|
114
114
|
.filter((topic) => {
|
|
115
|
-
return topic.title
|
|
115
|
+
return topic.title?.toLowerCase().includes(keywordLowerCase);
|
|
116
116
|
})
|
|
117
117
|
.toArray();
|
|
118
118
|
|
|
@@ -139,7 +139,7 @@ class _SessionModel extends BaseModel {
|
|
|
139
139
|
.anyOf([...combinedSessionIds])
|
|
140
140
|
.toArray();
|
|
141
141
|
|
|
142
|
-
console.
|
|
142
|
+
console.log(`检索到 ${items.length} 项,耗时 ${Date.now() - startTime}ms`);
|
|
143
143
|
return this.mapToAgentSessions(items);
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -110,6 +110,20 @@ describe('parseAgentConfig', () => {
|
|
|
110
110
|
};
|
|
111
111
|
expect(parseAgentConfig(envStr)).toEqual(expected);
|
|
112
112
|
});
|
|
113
|
+
|
|
114
|
+
it('should parsers plugins correctly', () => {
|
|
115
|
+
const envStr =
|
|
116
|
+
'enableAutoCreateTopic=true;model=gemini-pro;provider=google;plugins=lobe-image-designer';
|
|
117
|
+
|
|
118
|
+
const expected = {
|
|
119
|
+
enableAutoCreateTopic: true,
|
|
120
|
+
model: 'gemini-pro',
|
|
121
|
+
plugins: ['lobe-image-designer'],
|
|
122
|
+
provider: 'google',
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
expect(parseAgentConfig(envStr)).toEqual(expected);
|
|
126
|
+
});
|
|
113
127
|
});
|
|
114
128
|
|
|
115
129
|
describe('Error Boundary', () => {
|
|
@@ -35,6 +35,11 @@ export const parseAgentConfig = (envStr: string) => {
|
|
|
35
35
|
finalValue = array.map((item) => (isNaN(item as any) ? item : Number(item)));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// handle plugins if it's a string
|
|
39
|
+
if (key === 'plugins') {
|
|
40
|
+
finalValue = typeof finalValue === 'string' ? [finalValue] : finalValue;
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
set(config, key, finalValue);
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -70,6 +70,8 @@ export interface SessionAction {
|
|
|
70
70
|
*/
|
|
71
71
|
removeSession: (id: string) => Promise<void>;
|
|
72
72
|
|
|
73
|
+
updateSearchKeywords: (keywords: string) => void;
|
|
74
|
+
|
|
73
75
|
useFetchSessions: () => SWRResponse<ChatSessionList>;
|
|
74
76
|
useSearchSessions: (keyword?: string) => SWRResponse<any>;
|
|
75
77
|
|
|
@@ -169,6 +171,13 @@ export const createSessionSlice: StateCreator<
|
|
|
169
171
|
}
|
|
170
172
|
},
|
|
171
173
|
|
|
174
|
+
updateSearchKeywords: (keywords) => {
|
|
175
|
+
set(
|
|
176
|
+
{ isSearching: !!keywords, sessionSearchKeywords: keywords },
|
|
177
|
+
false,
|
|
178
|
+
n('updateSearchKeywords'),
|
|
179
|
+
);
|
|
180
|
+
},
|
|
172
181
|
updateSessionGroupId: async (sessionId, group) => {
|
|
173
182
|
await get().internal_updateSession(sessionId, { group });
|
|
174
183
|
},
|