@lobehub/chat 0.143.0 → 0.144.1
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/self-hosting/advanced/authentication.mdx +3 -1
- package/docs/self-hosting/advanced/authentication.zh-CN.mdx +3 -1
- package/docs/self-hosting/advanced/sso-providers/authentik.mdx +56 -0
- package/docs/self-hosting/advanced/sso-providers/authentik.zh-CN.mdx +54 -0
- package/docs/self-hosting/environment-variables/basic.mdx +35 -8
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +34 -8
- package/package.json +1 -1
- package/src/app/api/auth/next-auth.ts +14 -0
- package/src/config/modelProviders/ollama.ts +3 -3
- package/src/config/server/app.ts +3 -0
- package/src/libs/agent-runtime/ollama/index.test.ts +46 -1
- package/src/libs/agent-runtime/ollama/index.ts +40 -0
- package/src/libs/agent-runtime/types/chat.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.144.1](https://github.com/lobehub/lobe-chat/compare/v0.144.0...v0.144.1)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-03-29**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **ollama**: Suppport vision for LLaVA models.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **ollama**: Suppport vision for LLaVA models, closes [#1791](https://github.com/lobehub/lobe-chat/issues/1791) ([e2d3de6](https://github.com/lobehub/lobe-chat/commit/e2d3de6))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## [Version 0.144.0](https://github.com/lobehub/lobe-chat/compare/v0.143.0...v0.144.0)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2024-03-29**</sup>
|
|
33
|
+
|
|
34
|
+
#### ✨ Features
|
|
35
|
+
|
|
36
|
+
- **misc**: Support authentik as sso.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's improved
|
|
44
|
+
|
|
45
|
+
- **misc**: Support authentik as sso, closes [#1650](https://github.com/lobehub/lobe-chat/issues/1650) ([181dfa5](https://github.com/lobehub/lobe-chat/commit/181dfa5))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
## [Version 0.143.0](https://github.com/lobehub/lobe-chat/compare/v0.142.9...v0.143.0)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2024-03-28**</sup>
|
|
@@ -6,12 +6,13 @@ Currently supported identity verification services include:
|
|
|
6
6
|
|
|
7
7
|
- [Auth0](/en/self-hosting/advanced/sso-providers/auth0)
|
|
8
8
|
- [Microsoft Entra ID](/en/self-hosting/advanced/sso-providers/microsoft-entra-id)
|
|
9
|
+
- [Authentik](/en/self-hosting/advanced/sso-providers/authentik)
|
|
9
10
|
|
|
10
11
|
Click on the links to view the corresponding platform's configuration documentation.
|
|
11
12
|
|
|
12
13
|
## Advanced Configuration
|
|
13
14
|
|
|
14
|
-
To simultaneously enable multiple identity verification sources, please set the `SSO_PROVIDERS` environment variable, separating them with commas, for example, `auth0,azure-ad`.
|
|
15
|
+
To simultaneously enable multiple identity verification sources, please set the `SSO_PROVIDERS` environment variable, separating them with commas, for example, `auth0,azure-ad,authentik`.
|
|
15
16
|
|
|
16
17
|
The order corresponds to the display order of the SSO providers.
|
|
17
18
|
|
|
@@ -19,6 +20,7 @@ The order corresponds to the display order of the SSO providers.
|
|
|
19
20
|
| ------------------ | ---------- |
|
|
20
21
|
| Auth0 | `auth0` |
|
|
21
22
|
| Microsoft Entra ID | `azure-ad` |
|
|
23
|
+
| Authentik | `authentik` |
|
|
22
24
|
|
|
23
25
|
## Other SSO Providers
|
|
24
26
|
|
|
@@ -6,12 +6,13 @@ LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用
|
|
|
6
6
|
|
|
7
7
|
- [Auth0](/zh/self-hosting/advanced/sso-providers/auth0)
|
|
8
8
|
- [Microsoft Entra ID](/zh/self-hosting/advanced/sso-providers/microsoft-entra-id)
|
|
9
|
+
- [Authentik](/zh/self-hosting/advanced/sso-providers/authentik)
|
|
9
10
|
|
|
10
11
|
点击链接可以查看对应平台的配置文档。
|
|
11
12
|
|
|
12
13
|
## 进阶配置
|
|
13
14
|
|
|
14
|
-
同时启用多个身份验证源请设置 `SSO_PROVIDERS` 环境变量,以逗号 `,` 分割,例如 `auth0,azure-ad`。
|
|
15
|
+
同时启用多个身份验证源请设置 `SSO_PROVIDERS` 环境变量,以逗号 `,` 分割,例如 `auth0,azure-ad,authentik`。
|
|
15
16
|
|
|
16
17
|
顺序为 SSO 提供商的显示顺序。
|
|
17
18
|
|
|
@@ -19,6 +20,7 @@ LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用
|
|
|
19
20
|
| ------------------ | ---------- |
|
|
20
21
|
| Auth0 | `auth0` |
|
|
21
22
|
| Microsoft Entra ID | `azure-ad` |
|
|
23
|
+
| Authentik | `authentik` |
|
|
22
24
|
|
|
23
25
|
## 其他 SSO 提供商
|
|
24
26
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
## Configuring Authentik Authentication Service
|
|
2
|
+
|
|
3
|
+
## Authentik Configuration Flow
|
|
4
|
+
|
|
5
|
+
<Steps>
|
|
6
|
+
### Create an Authentik Application Provider
|
|
7
|
+
|
|
8
|
+
In your Authentik instance, use the administrator account to go to **Admin Interface** -> **Applications** -> **Providers** and create a new provider.
|
|
9
|
+
|
|
10
|
+
Select **OAuth2/OpenID Provider** as the provider type. Fill in the provider name, select the authentication flow and authorization flow.
|
|
11
|
+
|
|
12
|
+
In the `Redirect URL/Origin (regex)` field, fill in:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
https://your-domain/api/auth/callback/authentik
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
<Callout type={'info'}>
|
|
19
|
+
- You can fill in or modify the `Redirect URL/Origin (regex)` later, but make sure the filled in URL matches the deployed URL.
|
|
20
|
+
- Replace `your-domain` with your own domain name
|
|
21
|
+
</Callout>
|
|
22
|
+
|
|
23
|
+
<Image alt="Create Authentik Provider" inStep src="[https://github.com/lobehub/lobe-chat/assets/67304509/4244634e-5f68-48d5-aac0-e5f4b06d1c4b](https://github.com/lobehub/lobe-chat/assets/67304509/4244634e-5f68-48d5-aac0-e5f4b06d1c4b)" />
|
|
24
|
+
|
|
25
|
+
Click **Done**
|
|
26
|
+
|
|
27
|
+
After the creation is successful, click **Applications** on the left -> **Create**, fill in the name and Slug, select the provider created in the previous step, and click **Create**.
|
|
28
|
+
|
|
29
|
+
After the application provider is created, click the corresponding provider to enter the details page, click **Edit**, and save the `Client ID` and `Client Secret`.
|
|
30
|
+
|
|
31
|
+
Copy the URL of `OpenID Configuration Issuer` and save it.
|
|
32
|
+
|
|
33
|
+
### Configure Environment Variables
|
|
34
|
+
|
|
35
|
+
When deploying LobeChat, you need to configure the following environment variables:
|
|
36
|
+
|
|
37
|
+
| Environment Variable | Type | Description |
|
|
38
|
+
| ------------------------ | -- | ------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `ENABLE_OAUTH_SSO` | Required | Enable Single Sign-On (SSO) for LobeChat. Set to `1` to enable SSO. |
|
|
40
|
+
| `NEXTAUTH_SECRET` | Required | The secret used to encrypt Auth.js session tokens. You can generate a secret using the following command: `openssl rand -base64 32` |
|
|
41
|
+
| `SSO_PROVIDERS` | Required | Select the SSO provider for LoboChat. Use `authentik` for Authentik. |
|
|
42
|
+
| `AUTHENTIK_CLIENT_ID` | Required | The Client ID from the Authentik application provider details page |
|
|
43
|
+
| `AUTHENTIK_CLIENT_SECRET` | Required | The Client Secret from the Authentik application provider details page |
|
|
44
|
+
| `AUTHENTIK_ISSUER` | Required | The OpenID Configuration Issuer from the Authentik application provider details page |
|
|
45
|
+
| `ACCESS_CODE` | Required | Add a password to access this service, you can set a sufficiently long random password to "disable" access code authorization |
|
|
46
|
+
| `NEXTAUTH_URL` | Optional | This URL is used to specify the callback address for Auth.js when performing OAuth authentication. It only needs to be set when the default generated redirect address is incorrect. `https://example.com/api/auth` |
|
|
47
|
+
|
|
48
|
+
<Callout type={'tip'}>
|
|
49
|
+
Go to Environment Variables: /en/self-hosting/environment-variable#Authentik for details about the variables.
|
|
50
|
+
</Callout>
|
|
51
|
+
</Steps>
|
|
52
|
+
|
|
53
|
+
<Callout type={'info'}>
|
|
54
|
+
After a successful deployment, users will be able to use LobeChat by authenticating with the users configured in Authentik.
|
|
55
|
+
</Callout>
|
|
56
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 配置 Authentik 身份验证服务
|
|
2
|
+
|
|
3
|
+
## Authentik 配置流程
|
|
4
|
+
|
|
5
|
+
<Steps>
|
|
6
|
+
### 创建 Authentik 提供应用
|
|
7
|
+
|
|
8
|
+
在你的 Authentik 实例中使用管理员账号进入 管理员界面 -> 应用程序 -> 提供程序 创建一个新的提供程序。
|
|
9
|
+
|
|
10
|
+
选择 OAuth2/OpenID Provider 作为提供程序类型。填写提供程序的名称,选择身份流程和授权流程。
|
|
11
|
+
|
|
12
|
+
在 `重定向 URL/Origin(正则)` 处填写:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
https://your-domain/api/auth/callback/authentik
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
<Callout type={'info'}>
|
|
19
|
+
- 可以之后再填写或修改 `重定向 URL/Origin(正则)`,但是务必保证填写的 URL 与部署的 URL 一致。
|
|
20
|
+
- your-domain 请替换为自己的域名
|
|
21
|
+
</Callout>
|
|
22
|
+
|
|
23
|
+
<Image alt="创建 Authentik 提供程序" inStep src="https://github.com/lobehub/lobe-chat/assets/67304509/4244634e-5f68-48d5-aac0-e5f4b06d1c4b" />
|
|
24
|
+
|
|
25
|
+
点击「完成」
|
|
26
|
+
|
|
27
|
+
创建成功后,点击左侧的「应用程序」-> 创建,填写名称和 Slug ,提供程序选择上一步创建的提供程序,点击「创建」。
|
|
28
|
+
|
|
29
|
+
提供程序创建成功后,点击相应的提供程序,进入详情页,点击「编辑」,将 `客户端 ID` 和 `客户端 Secret` 保存下来。
|
|
30
|
+
复制 `OpenID 配置颁发者` 的 URL,保存下来。
|
|
31
|
+
|
|
32
|
+
### 配置环境变量
|
|
33
|
+
|
|
34
|
+
在部署 LobeChat 时,你需要配置以下环境变量:
|
|
35
|
+
|
|
36
|
+
| 环境变量 | 类型 | 描述 |
|
|
37
|
+
| ------------------------ | -- | ------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `ENABLE_OAUTH_SSO` | 必选 | 为 LobeChat 启用单点登录 (SSO)。设置为 `1` 以启用单点登录。 |
|
|
39
|
+
| `NEXTAUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
|
|
40
|
+
| `SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Authentik 请填写 `authentik`。 |
|
|
41
|
+
| `AUTHENTIK_CLIENT_ID` | 必选 | Authentik 提供程序详情页的 客户端 ID |
|
|
42
|
+
| `AUTHENTIK_CLIENT_SECRET` | 必选 | Authentik 提供程序详情页的 客户端 Secret |
|
|
43
|
+
| `AUTHENTIK_ISSUER` | 必选 | Authentik 提供程序详情页的 OpenID 配置颁发者 |
|
|
44
|
+
| `ACCESS_CODE` | 必选 | 添加访问此服务的密码,你可以设置一个足够长的随机密码以 “禁用” 访问码授权 |
|
|
45
|
+
| `NEXTAUTH_URL` | 可选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://example.com/api/auth` |
|
|
46
|
+
|
|
47
|
+
<Callout type={'tip'}>
|
|
48
|
+
前往 [📘 环境变量](/zh/self-hosting/environment-variable#Authentik) 可查阅相关变量详情。
|
|
49
|
+
</Callout>
|
|
50
|
+
</Steps>
|
|
51
|
+
|
|
52
|
+
<Callout type={'info'}>
|
|
53
|
+
部署成功后,用户将可以使用 Authentik 中配置的用户通过身份认证并使用 LobeChat。
|
|
54
|
+
</Callout>
|
|
@@ -65,9 +65,9 @@ Further reading:
|
|
|
65
65
|
#### `SSO_PROVIDERS`
|
|
66
66
|
|
|
67
67
|
- Type: Required
|
|
68
|
-
- Description: Select the single sign-on provider for LoboChat. For multiple SSO Providers separating them with commas, for example, `auth0,azure-ad
|
|
68
|
+
- Description: Select the single sign-on provider for LoboChat. For multiple SSO Providers separating them with commas, for example, `auth0,azure-ad,authentik`.
|
|
69
69
|
- Default: `auth0`
|
|
70
|
-
- Example: `auth0,azure-ad`
|
|
70
|
+
- Example: `auth0,azure-ad,authentik`
|
|
71
71
|
|
|
72
72
|
#### `NEXTAUTH_SECRET`
|
|
73
73
|
|
|
@@ -86,9 +86,8 @@ Further reading:
|
|
|
86
86
|
### Auth0
|
|
87
87
|
|
|
88
88
|
<Callout>
|
|
89
|
-
Currently, we only support the Auth0, Microsoft Entra ID identity verification service providers.
|
|
90
|
-
If you need to use other identity verification service providers, you can submit a [feature
|
|
91
|
-
request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
89
|
+
Currently, we only support the Auth0, Microsoft Entra ID, Authentik identity verification service providers.
|
|
90
|
+
If you need to use other identity verification service providers, you can submit a [feature request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
92
91
|
</Callout>
|
|
93
92
|
|
|
94
93
|
#### `AUTH0_CLIENT_ID`
|
|
@@ -115,9 +114,8 @@ Further reading:
|
|
|
115
114
|
### Microsoft Entra ID
|
|
116
115
|
|
|
117
116
|
<Callout>
|
|
118
|
-
Currently, we only support the Auth0, Microsoft Entra ID identity verification service providers.
|
|
119
|
-
|
|
120
|
-
request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
117
|
+
Currently, we only support the Auth0, Microsoft Entra ID, Authentik identity verification service providers. If you need to use
|
|
118
|
+
other identity verification service providers, you can submit a [feature request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
121
119
|
</Callout>
|
|
122
120
|
|
|
123
121
|
#### `AZURE_AD_CLIENT_ID`
|
|
@@ -141,6 +139,35 @@ Further reading:
|
|
|
141
139
|
- Default: `-`
|
|
142
140
|
- Example: `c8ae2f36-edf6-4cda-96b9-d3e198a47cba`
|
|
143
141
|
|
|
142
|
+
### Authentik
|
|
143
|
+
|
|
144
|
+
<Callout>
|
|
145
|
+
Currently, we only support the Auth0, Microsoft Entra ID, Authentik identity verification service providers. If you need to use
|
|
146
|
+
other identity verification service providers, you can submit a [feature
|
|
147
|
+
request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
148
|
+
</Callout>
|
|
149
|
+
|
|
150
|
+
#### `AUTHENTIK_CLIENT_ID`
|
|
151
|
+
|
|
152
|
+
- Type: Required
|
|
153
|
+
- Description: Client ID of the Authentik provider application. You can access it [here][auth0-client-page] and navigate to the application settings to view.
|
|
154
|
+
- Default: `-`
|
|
155
|
+
- Example: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
|
|
156
|
+
|
|
157
|
+
#### `AUTHENTIK_CLIENT_SECRET`
|
|
158
|
+
|
|
159
|
+
- Type: Required
|
|
160
|
+
- Description: Client Secret of the Authentik provider application.
|
|
161
|
+
- Default: `-`
|
|
162
|
+
- Example: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
|
|
163
|
+
|
|
164
|
+
#### `AUTHENTIK_ISSUER`
|
|
165
|
+
|
|
166
|
+
- Type: Required
|
|
167
|
+
- Description: Issuer/domain of the Authentik provider application.
|
|
168
|
+
- Default: `-`
|
|
169
|
+
- Example: `https://your-authentik-domain.com/application/o/slug/`
|
|
170
|
+
|
|
144
171
|
## Plugin Service
|
|
145
172
|
|
|
146
173
|
### `PLUGINS_INDEX_URL`
|
|
@@ -65,9 +65,9 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
65
65
|
#### `SSO_PROVIDERS`
|
|
66
66
|
|
|
67
67
|
- Type: 必需
|
|
68
|
-
- 描述:选择 LoboChat 的单点登录提供商。如果有多个单点登录提供商,请用逗号分隔,例如 `auth0,azure-ad`
|
|
68
|
+
- 描述:选择 LoboChat 的单点登录提供商。如果有多个单点登录提供商,请用逗号分隔,例如 `auth0,azure-ad,authentik`
|
|
69
69
|
- 默认值: `auth0`
|
|
70
|
-
- 示例: `auth0,azure-ad`
|
|
70
|
+
- 示例: `auth0,azure-ad,authentik`
|
|
71
71
|
|
|
72
72
|
#### `NEXTAUTH_SECRET`
|
|
73
73
|
|
|
@@ -86,9 +86,8 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
86
86
|
### Auth0
|
|
87
87
|
|
|
88
88
|
<Callout>
|
|
89
|
-
目前,我们仅支持 Auth0
|
|
90
|
-
|
|
91
|
-
[功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
89
|
+
目前,我们仅支持 Auth0,Microsoft Entra ID,Authentik 作为身份验证服务提供商。
|
|
90
|
+
如果您需要使用其他身份验证服务提供商,可以提交 [功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
92
91
|
</Callout>
|
|
93
92
|
|
|
94
93
|
#### `AUTH0_CLIENT_ID`
|
|
@@ -115,9 +114,8 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
115
114
|
### Microsoft Entra ID
|
|
116
115
|
|
|
117
116
|
<Callout>
|
|
118
|
-
目前,我们仅支持 Auth0
|
|
119
|
-
|
|
120
|
-
[功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
117
|
+
目前,我们仅支持 Auth0,Microsoft Entra ID,Authentik 作为身份验证服务提供商。
|
|
118
|
+
如果您需要使用其他身份验证服务提供商,可以提交 [功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
121
119
|
</Callout>
|
|
122
120
|
|
|
123
121
|
#### `AZURE_AD_CLIENT_ID`
|
|
@@ -141,6 +139,34 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
141
139
|
- 默认值:`-`
|
|
142
140
|
- 示例:`c8ae2f36-edf6-4cda-96b9-d3e198a47cba`
|
|
143
141
|
|
|
142
|
+
### Authentik
|
|
143
|
+
|
|
144
|
+
<Callout>
|
|
145
|
+
目前,我们仅支持 Auth0,Microsoft Entra ID,Authentik 作为身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交
|
|
146
|
+
[功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
147
|
+
</Callout>
|
|
148
|
+
|
|
149
|
+
#### `AUTHENTIK_CLIENT_ID`
|
|
150
|
+
|
|
151
|
+
- 类型:必选
|
|
152
|
+
- 描述: Authentik 提供程序的 Client ID
|
|
153
|
+
- 默认值: `-`
|
|
154
|
+
- 示例: `YNtbIRlYF8Kj66mTLue59nsGLlb7HNyx1qjPH6VS`
|
|
155
|
+
|
|
156
|
+
#### `AUTHENTIK_CLIENT_SECRET`
|
|
157
|
+
|
|
158
|
+
- 类型:必选
|
|
159
|
+
- 描述: Authentik 提供程序的 Client Secret
|
|
160
|
+
- 默认值: `-`
|
|
161
|
+
- 示例: `h3lMI1vPUzqyqqeIDUbH5UNNOxyQLXk35h89yETeaAwHk7qVXBG3sJQWeqHBU5pyggwhP9u0eaZ1eq6DHUddVPLoS4gncqD37yuCr8jI8dY66WAt45MStDsDcQm0Ygze`
|
|
162
|
+
|
|
163
|
+
#### `AUTHENTIK_ISSUER`
|
|
164
|
+
|
|
165
|
+
- 类型:必选
|
|
166
|
+
- 描述: Authentik 提供程序的 OpenID Connect 颁发者
|
|
167
|
+
- 默认值: `-`
|
|
168
|
+
- 示例: `https://your-authentik-domain.com/application/o/slug/`
|
|
169
|
+
|
|
144
170
|
## 插件服务
|
|
145
171
|
|
|
146
172
|
### `PLUGINS_INDEX_URL`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.144.1",
|
|
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",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import NextAuth from 'next-auth';
|
|
2
2
|
import Auth0 from 'next-auth/providers/auth0';
|
|
3
|
+
import Authentik from 'next-auth/providers/authentik';
|
|
3
4
|
import AzureAd from 'next-auth/providers/azure-ad';
|
|
4
5
|
|
|
5
6
|
import { getServerConfig } from '@/config/server';
|
|
@@ -13,6 +14,9 @@ const {
|
|
|
13
14
|
AZURE_AD_CLIENT_ID,
|
|
14
15
|
AZURE_AD_CLIENT_SECRET,
|
|
15
16
|
AZURE_AD_TENANT_ID,
|
|
17
|
+
AUTHENTIK_CLIENT_ID,
|
|
18
|
+
AUTHENTIK_CLIENT_SECRET,
|
|
19
|
+
AUTHENTIK_ISSUER,
|
|
16
20
|
NEXTAUTH_SECRET,
|
|
17
21
|
} = getServerConfig();
|
|
18
22
|
|
|
@@ -65,6 +69,16 @@ const nextAuth = NextAuth({
|
|
|
65
69
|
tenantId: AZURE_AD_TENANT_ID,
|
|
66
70
|
});
|
|
67
71
|
}
|
|
72
|
+
case 'authentik': {
|
|
73
|
+
return Authentik({
|
|
74
|
+
// Specify auth scope, at least include 'openid email'
|
|
75
|
+
// all scopes in Authentik ref: https://goauthentik.io/docs/providers/oauth2
|
|
76
|
+
authorization: { params: { scope: 'openid email profile' } },
|
|
77
|
+
clientId: AUTHENTIK_CLIENT_ID,
|
|
78
|
+
clientSecret: AUTHENTIK_CLIENT_SECRET,
|
|
79
|
+
issuer: AUTHENTIK_ISSUER,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
68
82
|
default: {
|
|
69
83
|
throw new Error(`[NextAuth] provider ${provider} is not supported`);
|
|
70
84
|
}
|
|
@@ -135,7 +135,7 @@ const Ollama: ModelProviderCard = {
|
|
|
135
135
|
hidden: true,
|
|
136
136
|
id: 'llava',
|
|
137
137
|
tokens: 4000,
|
|
138
|
-
vision:
|
|
138
|
+
vision: true,
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
141
|
displayName: 'LLaVA 13B',
|
|
@@ -143,7 +143,7 @@ const Ollama: ModelProviderCard = {
|
|
|
143
143
|
hidden: true,
|
|
144
144
|
id: 'llava:13b',
|
|
145
145
|
tokens: 4000,
|
|
146
|
-
vision:
|
|
146
|
+
vision: true,
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
displayName: 'LLaVA 34B',
|
|
@@ -151,7 +151,7 @@ const Ollama: ModelProviderCard = {
|
|
|
151
151
|
hidden: true,
|
|
152
152
|
id: 'llava:34b',
|
|
153
153
|
tokens: 4000,
|
|
154
|
-
vision:
|
|
154
|
+
vision: true,
|
|
155
155
|
},
|
|
156
156
|
],
|
|
157
157
|
id: 'ollama',
|
package/src/config/server/app.ts
CHANGED
|
@@ -65,6 +65,9 @@ export const getAppConfig = () => {
|
|
|
65
65
|
AZURE_AD_CLIENT_ID: process.env.AZURE_AD_CLIENT_ID || '',
|
|
66
66
|
AZURE_AD_CLIENT_SECRET: process.env.AZURE_AD_CLIENT_SECRET || '',
|
|
67
67
|
AZURE_AD_TENANT_ID: process.env.AZURE_AD_TENANT_ID || '',
|
|
68
|
+
AUTHENTIK_CLIENT_ID: process.env.AUTHENTIK_CLIENT_ID || '',
|
|
69
|
+
AUTHENTIK_CLIENT_SECRET: process.env.AUTHENTIK_CLIENT_SECRET || '',
|
|
70
|
+
AUTHENTIK_ISSUER: process.env.AUTHENTIK_ISSUER || '',
|
|
68
71
|
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET || '',
|
|
69
72
|
|
|
70
73
|
ENABLE_LANGFUSE: process.env.ENABLE_LANGFUSE === '1',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import OpenAI from 'openai';
|
|
3
3
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
|
|
5
|
-
import { ChatStreamCallbacks } from '@/libs/agent-runtime';
|
|
5
|
+
import { ChatStreamCallbacks, OpenAIChatMessage } from '@/libs/agent-runtime';
|
|
6
6
|
|
|
7
7
|
import * as debugStreamModule from '../utils/debugStream';
|
|
8
8
|
import { LobeOllamaAI } from './index';
|
|
@@ -317,4 +317,49 @@ describe('LobeOllamaAI', () => {
|
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
});
|
|
320
|
+
|
|
321
|
+
describe('private method', () => {
|
|
322
|
+
describe('convertContentToOllamaMessage', () => {
|
|
323
|
+
it('should format message array content of UserMessageContentPart to match ollama api', () => {
|
|
324
|
+
const message: OpenAIChatMessage = {
|
|
325
|
+
role: 'user',
|
|
326
|
+
content: [
|
|
327
|
+
{
|
|
328
|
+
type: 'text',
|
|
329
|
+
text: 'Hello',
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
type: 'image_url',
|
|
333
|
+
image_url: {
|
|
334
|
+
detail: 'auto',
|
|
335
|
+
url: 'data:image/png;base64,iVBO...',
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const ollamaMessage = instance['convertContentToOllamaMessage'](message);
|
|
342
|
+
|
|
343
|
+
expect(ollamaMessage).toEqual({
|
|
344
|
+
role: 'user',
|
|
345
|
+
content: 'Hello',
|
|
346
|
+
images: ['iVBO...'],
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should not affect string type message content', () => {
|
|
351
|
+
const message: OpenAIChatMessage = {
|
|
352
|
+
role: 'user',
|
|
353
|
+
content: 'Hello',
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const ollamaMessage = instance['convertContentToOllamaMessage'](message);
|
|
357
|
+
|
|
358
|
+
expect(ollamaMessage).toEqual({
|
|
359
|
+
role: 'user',
|
|
360
|
+
content: 'Hello',
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
});
|
|
320
365
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
|
2
2
|
import OpenAI, { ClientOptions } from 'openai';
|
|
3
3
|
|
|
4
|
+
import { OllamaChatMessage, OpenAIChatMessage } from '@/libs/agent-runtime';
|
|
5
|
+
|
|
4
6
|
import { LobeRuntimeAI } from '../BaseAI';
|
|
5
7
|
import { AgentRuntimeErrorType } from '../error';
|
|
6
8
|
import { ChatCompetitionOptions, ChatStreamPayload, ModelProvider } from '../types';
|
|
@@ -8,6 +10,7 @@ import { AgentRuntimeError } from '../utils/createError';
|
|
|
8
10
|
import { debugStream } from '../utils/debugStream';
|
|
9
11
|
import { desensitizeUrl } from '../utils/desensitizeUrl';
|
|
10
12
|
import { handleOpenAIError } from '../utils/handleOpenAIError';
|
|
13
|
+
import { parseDataUri } from '../utils/uriParser';
|
|
11
14
|
|
|
12
15
|
const DEFAULT_BASE_URL = 'http://127.0.0.1:11434/v1';
|
|
13
16
|
|
|
@@ -25,6 +28,8 @@ export class LobeOllamaAI implements LobeRuntimeAI {
|
|
|
25
28
|
|
|
26
29
|
async chat(payload: ChatStreamPayload, options?: ChatCompetitionOptions) {
|
|
27
30
|
try {
|
|
31
|
+
payload.messages = this.buildOllamaMessages(payload.messages);
|
|
32
|
+
|
|
28
33
|
const response = await this.client.chat.completions.create(
|
|
29
34
|
payload as unknown as OpenAI.ChatCompletionCreateParamsStreaming,
|
|
30
35
|
);
|
|
@@ -73,6 +78,41 @@ export class LobeOllamaAI implements LobeRuntimeAI {
|
|
|
73
78
|
});
|
|
74
79
|
}
|
|
75
80
|
}
|
|
81
|
+
|
|
82
|
+
private buildOllamaMessages(messages: OpenAIChatMessage[]) {
|
|
83
|
+
return messages.map((message) => this.convertContentToOllamaMessage(message));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private convertContentToOllamaMessage = (message: OpenAIChatMessage) => {
|
|
87
|
+
if (typeof message.content === 'string') {
|
|
88
|
+
return message;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const ollamaMessage: OllamaChatMessage = {
|
|
92
|
+
content: '',
|
|
93
|
+
role: message.role,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
for (const content of message.content) {
|
|
97
|
+
switch (content.type) {
|
|
98
|
+
case 'text': {
|
|
99
|
+
// keep latest text input
|
|
100
|
+
ollamaMessage.content = content.text;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case 'image_url': {
|
|
104
|
+
const { base64 } = parseDataUri(content.image_url.url);
|
|
105
|
+
if (base64) {
|
|
106
|
+
ollamaMessage.images ??= [];
|
|
107
|
+
ollamaMessage.images.push(base64);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return ollamaMessage;
|
|
115
|
+
};
|
|
76
116
|
}
|
|
77
117
|
|
|
78
118
|
export default LobeOllamaAI;
|
|
@@ -127,3 +127,10 @@ export interface ChatCompletionTool {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export type ChatStreamCallbacks = OpenAIStreamCallbacks;
|
|
130
|
+
|
|
131
|
+
export interface OllamaChatMessage extends OpenAIChatMessage {
|
|
132
|
+
/**
|
|
133
|
+
* @description images for ollama vision models (https://ollama.com/blog/vision-models)
|
|
134
|
+
*/
|
|
135
|
+
images?: string[];
|
|
136
|
+
}
|