@lobehub/chat 1.77.18 → 1.79.0
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/.github/workflows/sync-database-schema.yml +1 -1
- package/.github/workflows/wiki-sync.yml +2 -2
- package/CHANGELOG.md +50 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/changelog/v1.json +18 -0
- package/{contributing/Basic/Add-New-Authentication-Providers.md → docs/development/basic/add-new-authentication-providers.mdx} +0 -10
- package/{contributing/Basic/Add-New-Authentication-Providers.zh-CN.md → docs/development/basic/add-new-authentication-providers.zh-CN.mdx} +0 -10
- package/{contributing/Basic/Architecture.md → docs/development/basic/architecture.mdx} +0 -10
- package/{contributing/Basic/Architecture.zh-CN.md → docs/development/basic/architecture.zh-CN.mdx} +0 -10
- package/{contributing/Basic/Chat-API.md → docs/development/basic/chat-api.mdx} +6 -12
- package/{contributing/Basic/Chat-API.zh-CN.md → docs/development/basic/chat-api.zh-CN.mdx} +6 -12
- package/{contributing/Basic/Contributing-Guidelines.md → docs/development/basic/contributing-guidelines.mdx} +0 -14
- package/{contributing/Basic/Contributing-Guidelines.zh-CN.md → docs/development/basic/contributing-guidelines.zh-CN.mdx} +0 -14
- package/{contributing/Basic/Feature-Development-Frontend.md → docs/development/basic/feature-development-frontend.mdx} +0 -8
- package/{contributing/Basic/Feature-Development-Frontend.zh-CN.md → docs/development/basic/feature-development-frontend.zh-CN.mdx} +0 -8
- package/{contributing/Basic/Feature-Development.md → docs/development/basic/feature-development.mdx} +9 -10
- package/{contributing/Basic/Feature-Development.zh-CN.md → docs/development/basic/feature-development.zh-CN.mdx} +14 -15
- package/{contributing/Basic/Resources.md → docs/development/basic/resources.mdx} +0 -6
- package/{contributing/Basic/Resources.zh-CN.md → docs/development/basic/resources.zh-CN.mdx} +0 -6
- package/{contributing/Basic/Setup-Development.md → docs/development/basic/setup-development.mdx} +0 -7
- package/{contributing/Basic/Setup-Development.zh-CN.md → docs/development/basic/setup-development.zh-CN.mdx} +0 -7
- package/{contributing/Basic/Test.md → docs/development/basic/test.mdx} +3 -11
- package/{contributing/Basic/Test.zh-CN.md → docs/development/basic/test.zh-CN.mdx} +3 -11
- package/{contributing/Internationalization/Add-New-Locale.md → docs/development/internationalization/add-new-locale.mdx} +0 -8
- package/{contributing/Internationalization/Add-New-Locale.zh-CN.md → docs/development/internationalization/add-new-locale.zh-CN.mdx} +0 -8
- package/{contributing/Internationalization/Internationalization-Implementation.md → docs/development/internationalization/internationalization-implementation.mdx} +3 -11
- package/{contributing/Internationalization/Internationalization-Implementation.zh-CN.md → docs/development/internationalization/internationalization-implementation.zh-CN.mdx} +3 -11
- package/{contributing/Others/Lighthouse.md → docs/development/others/lighthouse.mdx} +8 -13
- package/{contributing/Others/Lighthouse.zh-CN.md → docs/development/others/lighthouse.zh-CN.mdx} +8 -13
- package/{contributing/Basic/Intro.md → docs/development/start.mdx} +6 -15
- package/{contributing/Basic/Intro.zh-CN.md → docs/development/start.zh-CN.mdx} +6 -15
- package/{contributing/State-Management/State-Management-Intro.md → docs/development/state-management/state-management-intro.mdx} +4 -9
- package/{contributing/State-Management/State-Management-Intro.zh-CN.md → docs/development/state-management/state-management-intro.zh-CN.mdx} +11 -16
- package/docs/self-hosting/advanced/auth/next-auth/keycloak.mdx +119 -0
- package/docs/self-hosting/advanced/auth/next-auth/keycloak.zh-CN.mdx +116 -0
- package/docs/self-hosting/advanced/auth.mdx +3 -0
- package/docs/self-hosting/advanced/auth.zh-CN.mdx +3 -0
- package/docs/wiki/HOME.md +11 -0
- package/package.json +2 -2
- package/scripts/dbmlWorkflow/index.ts +1 -1
- package/src/libs/next-auth/sso-providers/index.ts +2 -0
- package/src/libs/next-auth/sso-providers/keycloak.ts +25 -0
- package/src/locales/default/tool.ts +10 -10
- package/src/server/modules/SearXNG.ts +7 -4
- package/src/server/routers/tools/search.ts +7 -5
- package/src/services/search.ts +1 -1
- package/src/store/chat/slices/builtinTool/actions/searXNG.test.ts +9 -9
- package/src/store/chat/slices/builtinTool/actions/searXNG.ts +7 -3
- package/src/tools/web-browsing/components/CategoryAvatar.tsx +1 -1
- package/src/tools/web-browsing/components/SearchBar.tsx +1 -3
- package/src/tools/web-browsing/const.ts +11 -11
- package/src/tools/web-browsing/index.ts +2 -2
- package/src/types/tool/search.ts +1 -1
- package/contributing/Home.md +0 -87
- package/contributing/Upstream-Sync.md +0 -58
- package/contributing/Upstream-Sync.zh-CN.md +0 -58
- package/contributing/_Footer.md +0 -1
- package/contributing/_Sidebar.md +0 -48
- /package/{contributing/Basic/Folder-Structure.md → docs/development/basic/folder-structure.mdx} +0 -0
- /package/{contributing/Basic/Folder-Structure.zh-CN.md → docs/development/basic/folder-structure.zh-CN.mdx} +0 -0
- /package/docs/{developer → development}/database-schema.dbml +0 -0
- /package/{contributing/State-Management/State-Management-Selectors.md → docs/development/state-management/state-management-selectors.mdx} +0 -0
- /package/{contributing/State-Management/State-Management-Selectors.zh-CN.md → docs/development/state-management/state-management-selectors.zh-CN.mdx} +0 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
---
|
2
|
+
title: 在 LobeChat 中配置 Keycloak 身份验证服务
|
3
|
+
description: 学习如何在 LobeChat 中配置 Keycloak 身份验证服务,包括部署、创建、设置权限和环境变量。
|
4
|
+
tags:
|
5
|
+
- Keycloak 身份验证
|
6
|
+
- 环境变量配置
|
7
|
+
- 单点登录
|
8
|
+
- LobeChat
|
9
|
+
---
|
10
|
+
|
11
|
+
# 配置 Keycloak 身份验证服务
|
12
|
+
|
13
|
+
[Keycloak](https://www.keycloak.org/) 是一个开源的身份和访问管理解决方案,提供单点登录、身份代理和社交登录等功能,适用于现代应用和服务。
|
14
|
+
|
15
|
+
<Callout type={'tip'}>
|
16
|
+
若你想要私有部署 Keycloak,我们建议你将之与 LobeChat 一同使用 Docker Compose 部署,这样可以更方便地管理服务。
|
17
|
+
</Callout>
|
18
|
+
|
19
|
+
## Keycloak 配置流程
|
20
|
+
|
21
|
+
若你使用局域网 IP 部署,下文假设:
|
22
|
+
|
23
|
+
- 你的 LobeChat 数据库版本 IP / 端口为 `http://LOBECHAT_IP:3210`。
|
24
|
+
- 你私有部署 Keycloak,其域名为 `http://KEYCLOAK_IP:8080`。
|
25
|
+
|
26
|
+
若你使用公网部署,下文假设:
|
27
|
+
|
28
|
+
- 你的 LobeChat 数据库版本域名为 `https://lobe.example.com`。
|
29
|
+
- 你私有部署 Keycloak,其域名为 `https://lobe-auth-api.example.com`。
|
30
|
+
|
31
|
+
<Steps>
|
32
|
+
### 创建 Keycloak 领域和客户端
|
33
|
+
|
34
|
+
访问你私有部署的 Keycloak 管理控制台(默认为 `http://localhost:8080/admin`),使用管理员账号登录。
|
35
|
+
|
36
|
+
1. 创建新领域(Realm)
|
37
|
+
- 点击左上角的下拉菜单,选择 "Create Realm"
|
38
|
+
- 输入名称,例如 "LobeChat",然后点击 "Create"
|
39
|
+
|
40
|
+
2. 创建客户端(Client)
|
41
|
+
- 在左侧菜单中选择 "Clients",然后点击 "Create client"
|
42
|
+
- 填写以下信息:
|
43
|
+
- Client ID: `lobechat`
|
44
|
+
- Client type: `OpenID Connect`
|
45
|
+
- 点击 "Next"
|
46
|
+
- 在 "Capability config" 页面:
|
47
|
+
- 启用 "Client authentication"
|
48
|
+
- 启用 "Standard flow"
|
49
|
+
- 点击 "Next"
|
50
|
+
- 在 "Login settings" 页面:
|
51
|
+
- Valid redirect URIs:
|
52
|
+
- 本地开发环境:`http://localhost:3210/api/auth/callback/keycloak`
|
53
|
+
- 局域网 IP 部署:`http://LOBECHAT_IP:3210/api/auth/callback/keycloak`
|
54
|
+
- 公网环境:`https://lobe.example.com/api/auth/callback/keycloak`
|
55
|
+
- Web origins: 添加你的 LobeChat 域名或 IP
|
56
|
+
- 点击 "Save"
|
57
|
+
|
58
|
+
3. 获取客户端密钥
|
59
|
+
- 在客户端详情页,切换到 "Credentials" 选项卡
|
60
|
+
- 复制 "Client secret" 的值,后续需要用到
|
61
|
+
|
62
|
+
### 配置用户和角色(可选)
|
63
|
+
|
64
|
+
1. 创建用户
|
65
|
+
- 在左侧菜单中选择 "Users",然后点击 "Add user"
|
66
|
+
- 填写用户信息,点击 "Create"
|
67
|
+
- 在用户详情页,切换到 "Credentials" 选项卡
|
68
|
+
- 设置密码,并根据需要禁用 "Temporary" 选项
|
69
|
+
- 点击 "Set Password" 保存
|
70
|
+
|
71
|
+
2. 创建角色和权限
|
72
|
+
- 在左侧菜单中选择 "Realm roles"
|
73
|
+
- 点击 "Create role"
|
74
|
+
- 创建所需角色,如 "admin"、"user" 等
|
75
|
+
- 为用户分配角色:在用户详情页,切换到 "Role mapping" 选项卡,分配相应角色
|
76
|
+
|
77
|
+
### 关闭注册(可选)
|
78
|
+
|
79
|
+
为了保证你的应用安全,建议控制 Keycloak 的注册功能。
|
80
|
+
|
81
|
+
1. 在左侧菜单中选择 "Realm settings"
|
82
|
+
2. 切换到 "Login" 选项卡
|
83
|
+
3. 在 "User registration" 部分,禁用 "User registration" 选项
|
84
|
+
4. 点击 "Save" 保存设置
|
85
|
+
|
86
|
+
<Callout type={'warning'}>
|
87
|
+
如果不关闭注册功能,任何人都可能注册并登录你的应用,请根据你的安全需求进行配置。
|
88
|
+
</Callout>
|
89
|
+
|
90
|
+
### 配置环境变量
|
91
|
+
|
92
|
+
将获取到的客户端 ID 和客户端密钥,设为 LobeChat 环境变量中的 `AUTH_KEYCLOAK_ID` 和 `AUTH_KEYCLOAK_SECRET`。
|
93
|
+
|
94
|
+
配置 LobeChat 环境变量中 `AUTH_KEYCLOAK_ISSUER` 为:
|
95
|
+
|
96
|
+
- `http://localhost:8080/realms/LobeChat`,若你是本地开发环境
|
97
|
+
- `http://KEYCLOAK_IP:8080/realms/LobeChat`,若你是局域网私有部署的 Keycloak
|
98
|
+
- `https://lobe-auth-api.example.com/realms/LobeChat`,若你是公网环境部署的 Keycloak
|
99
|
+
|
100
|
+
在部署 LobeChat 时,你需要配置以下环境变量:
|
101
|
+
|
102
|
+
| 环境变量 | 类型 | 描述 |
|
103
|
+
| ------------------------- | -- | ------------------------------------------------------------------------------------------------ |
|
104
|
+
| `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
|
105
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Keycloak 请填写 `keycloak`。 |
|
106
|
+
| `AUTH_KEYCLOAK_ID` | 必选 | Keycloak 客户端 ID |
|
107
|
+
| `AUTH_KEYCLOAK_SECRET` | 必选 | Keycloak 客户端密钥 |
|
108
|
+
| `AUTH_KEYCLOAK_ISSUER` | 必选 | Keycloak 提供程序的 OpenID Connect 颁发者 URL,格式为 `{keycloak_url}/realms/{realm_name}` |
|
109
|
+
| `NEXTAUTH_URL` | 必选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://lobe.example.com/api/auth` |
|
110
|
+
|
111
|
+
<Callout type={'tip'}>
|
112
|
+
前往 [📘 环境变量](/zh/docs/self-hosting/environment-variables/auth#keycloak) 可查阅相关变量详情。
|
113
|
+
</Callout>
|
114
|
+
</Steps>
|
115
|
+
|
116
|
+
<Callout type={'info'}>部署成功后,用户将可以通过 Keycloak 身份认证并使用 LobeChat。</Callout>
|
@@ -52,6 +52,8 @@ Currently supported identity verification services include:
|
|
52
52
|
<Card href={'/docs/self-hosting/advanced/auth/next-auth/authelia'} title={'Authelia'} />
|
53
53
|
|
54
54
|
<Card href={'/docs/self-hosting/advanced/auth/next-auth/logto'} title={'Logto'} />
|
55
|
+
|
56
|
+
<Card href={'/docs/self-hosting/advanced/auth/next-auth/keycloak'} title={'Keycloak'} />
|
55
57
|
</Cards>
|
56
58
|
|
57
59
|
Click on the links to view the corresponding platform's configuration documentation.
|
@@ -73,6 +75,7 @@ The order corresponds to the display order of the SSO providers.
|
|
73
75
|
| Logto | `logto` |
|
74
76
|
| Microsoft Entra ID | `microsoft-entra-id` |
|
75
77
|
| ZITADEL | `zitadel` |
|
78
|
+
| Keycloak | `keycloak` |
|
76
79
|
|
77
80
|
## Other SSO Providers
|
78
81
|
|
@@ -49,6 +49,8 @@ LobeChat 与 Clerk 做了深度集成,能够为用户提供一个更加安全
|
|
49
49
|
<Card href={'/zh/docs/self-hosting/advanced/auth/next-auth/authelia'} title={'Authelia'} />
|
50
50
|
|
51
51
|
<Card href={'/zh/docs/self-hosting/advanced/auth/next-auth/logto'} title={'Logto'} />
|
52
|
+
|
53
|
+
<Card href={'/zh/docs/self-hosting/advanced/auth/next-auth/keycloak'} title={'Keycloak'} />
|
52
54
|
</Cards>
|
53
55
|
|
54
56
|
点击即可查看对应平台的配置文档。
|
@@ -70,6 +72,7 @@ LobeChat 与 Clerk 做了深度集成,能够为用户提供一个更加安全
|
|
70
72
|
| Logto | `logto` |
|
71
73
|
| Microsoft Entra ID | `microsoft-entra-id` |
|
72
74
|
| ZITADEL | `zitadel` |
|
75
|
+
| Keycloak | `keycloak` |
|
73
76
|
|
74
77
|
## 其他 SSO 提供商
|
75
78
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div align="center">
|
2
|
+
|
3
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
4
|
+
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
5
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/robot.webp">
|
6
|
+
|
7
|
+
</div>
|
8
|
+
|
9
|
+

|
10
|
+
|
11
|
+
We've moved the contributing wiki to [this page](https://lobehub.com/zh/docs/development/start).
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.79.0",
|
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",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"db:push": "drizzle-kit push",
|
43
43
|
"db:push-test": "NODE_ENV=test drizzle-kit push",
|
44
44
|
"db:studio": "drizzle-kit studio",
|
45
|
-
"db:visualize": "dbdocs build docs/
|
45
|
+
"db:visualize": "dbdocs build docs/development/database-schema.dbml --project lobe-chat",
|
46
46
|
"db:z-pull": "drizzle-kit introspect",
|
47
47
|
"dev": "next dev --turbopack -p 3010",
|
48
48
|
"docs:i18n": "lobe-i18n md && npm run lint:md && npm run lint:mdx",
|
@@ -3,7 +3,7 @@ import { join } from 'node:path';
|
|
3
3
|
|
4
4
|
import * as schema from '../../src/database/schemas';
|
5
5
|
|
6
|
-
const out = join(__dirname,'../../docs/
|
6
|
+
const out = join(__dirname, '../../docs/development/database-schema.dbml');
|
7
7
|
const relational = true;
|
8
8
|
|
9
9
|
pgGenerate({ out, relational, schema });
|
@@ -6,6 +6,7 @@ import Casdoor from './casdoor';
|
|
6
6
|
import CloudflareZeroTrust from './cloudflare-zero-trust';
|
7
7
|
import GenericOIDC from './generic-oidc';
|
8
8
|
import Github from './github';
|
9
|
+
import Keycloak from './keycloak';
|
9
10
|
import Logto from './logto';
|
10
11
|
import MicrosoftEntraID from './microsoft-entra-id';
|
11
12
|
import WeChat from './wechat';
|
@@ -24,4 +25,5 @@ export const ssoProviders = [
|
|
24
25
|
Casdoor,
|
25
26
|
MicrosoftEntraID,
|
26
27
|
WeChat,
|
28
|
+
Keycloak,
|
27
29
|
];
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import Keycloak from 'next-auth/providers/keycloak';
|
2
|
+
|
3
|
+
import { CommonProviderConfig } from './sso.config';
|
4
|
+
|
5
|
+
const provider = {
|
6
|
+
id: 'keycloak',
|
7
|
+
provider: Keycloak({
|
8
|
+
...CommonProviderConfig,
|
9
|
+
// Specify auth scope, at least include 'openid email'
|
10
|
+
authorization: { params: { scope: 'openid email profile' } },
|
11
|
+
clientId: process.env.AUTH_KEYCLOAK_ID,
|
12
|
+
clientSecret: process.env.AUTH_KEYCLOAK_SECRET,
|
13
|
+
issuer: process.env.AUTH_KEYCLOAK_ISSUER,
|
14
|
+
profile(profile) {
|
15
|
+
return {
|
16
|
+
email: profile.email,
|
17
|
+
id: profile.sub,
|
18
|
+
name: profile.name,
|
19
|
+
providerAccountId: profile.sub,
|
20
|
+
};
|
21
|
+
},
|
22
|
+
}),
|
23
|
+
};
|
24
|
+
|
25
|
+
export default provider;
|
@@ -23,16 +23,16 @@ export default {
|
|
23
23
|
placeholder: '搜索类别',
|
24
24
|
title: '搜索类别:',
|
25
25
|
value: {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
files: '文件',
|
27
|
+
general: '通用',
|
28
|
+
images: '图片',
|
29
|
+
it: '信息技术',
|
30
|
+
map: '地图',
|
31
|
+
music: '音乐',
|
32
|
+
news: '新闻',
|
33
|
+
science: '科学',
|
34
|
+
social_media: '社交媒体',
|
35
|
+
videos: '视频',
|
36
36
|
},
|
37
37
|
},
|
38
38
|
searchEngine: {
|
@@ -14,10 +14,13 @@ export class SearXNGClient {
|
|
14
14
|
try {
|
15
15
|
const { time_range, ...otherParams } = optionalParams;
|
16
16
|
|
17
|
-
const processedParams = Object.entries(otherParams).reduce<Record<string, any>>(
|
18
|
-
acc[key
|
19
|
-
|
20
|
-
|
17
|
+
const processedParams = Object.entries(otherParams).reduce<Record<string, any>>(
|
18
|
+
(acc, [key, value]) => {
|
19
|
+
acc[key] = Array.isArray(value) ? value.join(',') : value;
|
20
|
+
return acc;
|
21
|
+
},
|
22
|
+
{},
|
23
|
+
);
|
21
24
|
|
22
25
|
const searchParams = qs.stringify({
|
23
26
|
...processedParams,
|
@@ -43,11 +43,13 @@ export const searchRouter = router({
|
|
43
43
|
query: searchProcedure
|
44
44
|
.input(
|
45
45
|
z.object({
|
46
|
-
optionalParams: z
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
optionalParams: z
|
47
|
+
.object({
|
48
|
+
searchCategories: z.array(z.string()).optional(),
|
49
|
+
searchEngines: z.array(z.string()).optional(),
|
50
|
+
searchTimeRange: z.string().optional(),
|
51
|
+
})
|
52
|
+
.optional(),
|
51
53
|
query: z.string(),
|
52
54
|
}),
|
53
55
|
)
|
package/src/services/search.ts
CHANGED
@@ -2,7 +2,7 @@ import { toolsClient } from '@/libs/trpc/client';
|
|
2
2
|
|
3
3
|
class SearchService {
|
4
4
|
search(query: string, optionalParams?: object) {
|
5
|
-
return toolsClient.search.query.query({ optionalParams, query});
|
5
|
+
return toolsClient.search.query.query({ optionalParams, query });
|
6
6
|
}
|
7
7
|
|
8
8
|
crawlPage(url: string) {
|
@@ -90,8 +90,8 @@ describe('searXNG actions', () => {
|
|
90
90
|
},
|
91
91
|
];
|
92
92
|
|
93
|
-
expect(
|
94
|
-
searchEngines: [
|
93
|
+
expect(searchService.search).toHaveBeenCalledWith('test query', {
|
94
|
+
searchEngines: ['google'],
|
95
95
|
});
|
96
96
|
expect(result.current.searchLoading[messageId]).toBe(false);
|
97
97
|
expect(result.current.internal_updateMessageContent).toHaveBeenCalledWith(
|
@@ -158,20 +158,20 @@ describe('searXNG actions', () => {
|
|
158
158
|
});
|
159
159
|
|
160
160
|
expect(searchService.search).toHaveBeenCalledTimes(3);
|
161
|
-
expect(searchService.search).toHaveBeenNthCalledWith(1,
|
162
|
-
|
163
|
-
|
161
|
+
expect(searchService.search).toHaveBeenNthCalledWith(1, 'test query', {
|
162
|
+
searchEngines: ['custom-engine'],
|
163
|
+
searchTimeRange: 'year',
|
164
164
|
});
|
165
|
-
expect(searchService.search).toHaveBeenNthCalledWith(2,
|
166
|
-
|
165
|
+
expect(searchService.search).toHaveBeenNthCalledWith(2, 'test query', {
|
166
|
+
searchTimeRange: 'year',
|
167
167
|
});
|
168
168
|
expect(result.current.updatePluginArguments).toHaveBeenCalledWith(messageId, {
|
169
169
|
optionalParams: {
|
170
|
-
|
170
|
+
searchTimeRange: 'year',
|
171
171
|
},
|
172
172
|
query: 'test query',
|
173
173
|
});
|
174
|
-
expect(searchService.search).toHaveBeenNthCalledWith(3,
|
174
|
+
expect(searchService.search).toHaveBeenNthCalledWith(3, 'test query');
|
175
175
|
expect(result.current.updatePluginArguments).toHaveBeenCalledWith(messageId, {
|
176
176
|
optionalParams: undefined,
|
177
177
|
query: 'test query',
|
@@ -146,13 +146,17 @@ export const searchSlice: StateCreator<
|
|
146
146
|
data = await searchService.search(params.query, params.optionalParams);
|
147
147
|
|
148
148
|
// 如果没有搜索到结果,则执行第一次重试(移除搜索引擎限制)
|
149
|
-
if (
|
149
|
+
if (
|
150
|
+
data?.results.length === 0 &&
|
151
|
+
params.optionalParams?.searchEngines &&
|
152
|
+
params.optionalParams?.searchEngines?.length > 0
|
153
|
+
) {
|
150
154
|
const paramsExcludeSearchEngines = {
|
151
155
|
...params,
|
152
156
|
optionalParams: {
|
153
157
|
...params.optionalParams,
|
154
|
-
searchEngines: undefined
|
155
|
-
}
|
158
|
+
searchEngines: undefined,
|
159
|
+
},
|
156
160
|
};
|
157
161
|
data = await searchService.search(params.query, paramsExcludeSearchEngines.optionalParams);
|
158
162
|
get().updatePluginArguments(id, paramsExcludeSearchEngines);
|
@@ -191,9 +191,7 @@ const SearchBar = memo<SearchBarProps>(
|
|
191
191
|
)}
|
192
192
|
|
193
193
|
<Flexbox align={'center'} gap={16} horizontal wrap={'wrap'}>
|
194
|
-
<Typography.Text type={'secondary'}>
|
195
|
-
{t('search.searchTimeRange.title')}
|
196
|
-
</Typography.Text>
|
194
|
+
<Typography.Text type={'secondary'}>{t('search.searchTimeRange.title')}</Typography.Text>
|
197
195
|
<Radio.Group
|
198
196
|
onChange={(e) => setTimeRange(e.target.value)}
|
199
197
|
optionType="button"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
2
|
CodeIcon,
|
3
3
|
FileIcon,
|
4
4
|
FlaskConicalIcon,
|
@@ -12,16 +12,16 @@ import {
|
|
12
12
|
} from 'lucide-react';
|
13
13
|
|
14
14
|
export const CATEGORY_ICON_MAP: Record<string, any> = {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
files: FileIcon,
|
16
|
+
general: SearchIcon,
|
17
|
+
images: ImageIcon,
|
18
|
+
it: CodeIcon,
|
19
|
+
map: MapIcon,
|
20
|
+
music: MusicIcon,
|
21
|
+
news: NewspaperIcon,
|
22
|
+
science: FlaskConicalIcon,
|
23
|
+
social_media: Share2Icon,
|
24
|
+
videos: VideoIcon,
|
25
25
|
};
|
26
26
|
|
27
27
|
export const ENGINE_ICON_MAP: Record<string, string> = {
|
@@ -19,7 +19,7 @@ export const WebBrowsingManifest: BuiltinToolManifest = {
|
|
19
19
|
parameters: {
|
20
20
|
properties: {
|
21
21
|
optionalParams: {
|
22
|
-
description:
|
22
|
+
description: 'The optional parameters for search query',
|
23
23
|
properties: {
|
24
24
|
searchCategories: {
|
25
25
|
description: 'The search categories you can set:',
|
@@ -68,7 +68,7 @@ export const WebBrowsingManifest: BuiltinToolManifest = {
|
|
68
68
|
type: 'array',
|
69
69
|
},
|
70
70
|
searchTimeRange: {
|
71
|
-
description:
|
71
|
+
description: 'The time range you can set:',
|
72
72
|
enum: ['anytime', 'day', 'week', 'month', 'year'],
|
73
73
|
type: 'string',
|
74
74
|
},
|
package/src/types/tool/search.ts
CHANGED
package/contributing/Home.md
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
<div align="center">
|
2
|
-
|
3
|
-
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
4
|
-
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
5
|
-
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/robot.webp">
|
6
|
-
|
7
|
-
<h1>Lobe Chat Contributing Wiki</h1>
|
8
|
-
|
9
|
-
LobeChat is an open-source, extensible ([Function Calling][fc-url]), high-performance chatbot framework. <br/> It supports one-click free deployment of your private ChatGPT/LLM web application.
|
10
|
-
|
11
|
-
[Usage Documents](https://lobehub.com/docs) | [使用指南](https://lobehub.com/docs)
|
12
|
-
|
13
|
-
</div>
|
14
|
-
|
15
|
-

|
16
|
-
|
17
|
-
<!-- DOCS LIST -->
|
18
|
-
|
19
|
-
### 🤯 Basic
|
20
|
-
|
21
|
-
- [Architecture Design](https://github.com/lobehub/lobe-chat/wiki/Architecture) | [架构设计](https://github.com/lobehub/lobe-chat/wiki/Architecture.zh-CN)
|
22
|
-
- [Development Environment Setup Guide](https://github.com/lobehub/lobe-chat/wiki/Setup-Development) | [配置开发环境指南](https://github.com/lobehub/lobe-chat/wiki/Setup-Development.zh-CN)
|
23
|
-
- [Project Directory Structure](https://github.com/lobehub/lobe-chat/wiki/Folder-Structure) | [项目目录架构](https://github.com/lobehub/lobe-chat/wiki/Folder-Structure.zh-CN)
|
24
|
-
- [Technical Development Getting Started Guide](https://github.com/lobehub/lobe-chat/wiki/Intro) | [技术开发上手指南](https://github.com/lobehub/lobe-chat/wiki/Intro.zh-CN)
|
25
|
-
- [Code Style and Contribution Guidelines](https://github.com/lobehub/lobe-chat/wiki/Contributing-Guidelines) | [代码风格与贡献指南](https://github.com/lobehub/lobe-chat/wiki/Contributing-Guidelines.zh-CN)
|
26
|
-
- [How to Develop a New Feature](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend) | [如何开发一个新功能:前端实现](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend.zh-CN)
|
27
|
-
- [Complete Guide to LobeChat Feature Development](https://github.com/lobehub/lobe-chat/wiki/Feature-Development) | [LobeChat 功能开发完全指南](https://github.com/lobehub/lobe-chat/wiki/Feature-Development.zh-CN)
|
28
|
-
- [Conversation API Implementation Logic](https://github.com/lobehub/lobe-chat/wiki/Chat-API) | [会话 API 实现逻辑](https://github.com/lobehub/lobe-chat/wiki/Chat-API.zh-CN)
|
29
|
-
- [New Authentication Provider Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers) | [新身份验证方式开发指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers.zh-CN)
|
30
|
-
- [Testing Guide](https://github.com/lobehub/lobe-chat/wiki/Test) | [测试指南](https://github.com/lobehub/lobe-chat/wiki/Test.zh-CN)
|
31
|
-
- [Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources) | [资源与参考](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN)
|
32
|
-
|
33
|
-
<br/>
|
34
|
-
|
35
|
-
### 🌎 Internationalization
|
36
|
-
|
37
|
-
- [Internationalization Implementation Guide](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation) | [国际化实现指南](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation.zh-CN)
|
38
|
-
- [New Locale Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale) | [新语种添加指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale.zh-CN)
|
39
|
-
|
40
|
-
<br/>
|
41
|
-
|
42
|
-
### ⌨️ State Management
|
43
|
-
|
44
|
-
- [Best Practices for State Management](https://github.com/lobehub/lobe-chat/wiki/State-Management-Intro) | [状态管理最佳实践](https://github.com/lobehub/lobe-chat/wiki/State-Management-Intro.zh-CN)
|
45
|
-
- [Data Store Selector](https://github.com/lobehub/lobe-chat/wiki/State-Management-Selectors) | [数据存储取数模块](https://github.com/lobehub/lobe-chat/wiki/State-Management-Selectors.zh-CN)
|
46
|
-
|
47
|
-
<br/>
|
48
|
-
|
49
|
-
### 🤖 Agents
|
50
|
-
|
51
|
-
- [Agent Index and Submit](https://github.com/lobehub/lobe-chat-agents) | [助手索引与提交](https://github.com/lobehub/lobe-chat-agents/blob/main/README.zh-CN.md)
|
52
|
-
|
53
|
-
<br/>
|
54
|
-
|
55
|
-
### 🧩 Plugins
|
56
|
-
|
57
|
-
- [Plugin Index and Submit](https://github.com/lobehub/lobe-chat-plugins) | [插件索引与提交](https://github.com/lobehub/lobe-chat-plugins/blob/main/README.zh-CN.md)
|
58
|
-
- [Plugin SDK Docs](https://chat-plugin-sdk.lobehub.com) | [插件 SDK 文档](https://chat-plugin-sdk.lobehub.com)
|
59
|
-
|
60
|
-
<br/>
|
61
|
-
|
62
|
-
### 📊 Others
|
63
|
-
|
64
|
-
- [Lighthouse Reports](https://github.com/lobehub/lobe-chat/wiki/Lighthouse) | [Lighthouse 测试报告](https://github.com/lobehub/lobe-chat/wiki/Lighthouse.zh-CN)
|
65
|
-
|
66
|
-
<br/>
|
67
|
-
|
68
|
-
<!-- DOCS LIST -->
|
69
|
-
|
70
|
-
---
|
71
|
-
|
72
|
-
<details><summary><h4>📝 License</h4></summary>
|
73
|
-
|
74
|
-
[![][fossa-license-shield]][fossa-license-url]
|
75
|
-
|
76
|
-
</details>
|
77
|
-
|
78
|
-
Copyright © 2023 [LobeHub][profile-url]. <br />
|
79
|
-
This project is [MIT][license-url] licensed.
|
80
|
-
|
81
|
-
<!-- LINK GROUP -->
|
82
|
-
|
83
|
-
[fc-url]: https://sspai.com/post/81986
|
84
|
-
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat.svg?type=large
|
85
|
-
[fossa-license-url]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat
|
86
|
-
[license-url]: https://github.com/lobehub/lobe-chat/blob/main/LICENSE
|
87
|
-
[profile-url]: https://github.com/lobehub
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# Upstream Sync
|
2
|
-
|
3
|
-
English | [简体中文](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
|
4
|
-
|
5
|
-
## `A` Vercel / Zeabur Deployment
|
6
|
-
|
7
|
-
If you have deployed your own project following the one-click deployment steps in the README, you might encounter constant prompts indicating "updates available". This is because Vercel defaults to creating a new project instead of forking this one, resulting in an inability to accurately detect updates. We suggest you redeploy using the following steps:
|
8
|
-
|
9
|
-
- Remove the original repository;
|
10
|
-
- Use the <kbd>Fork</kbd> button at the top right corner of the page to fork this project;
|
11
|
-
- Re-select and deploy on `Vercel`.
|
12
|
-
|
13
|
-
## Enabling Automatic Updates
|
14
|
-
|
15
|
-
> \[!NOTE]
|
16
|
-
>
|
17
|
-
> If you encounter an error executing Upstream Sync, manually Sync Fork once
|
18
|
-
|
19
|
-
Once you have forked the project, due to Github restrictions, you will need to manually enable Workflows on the Actions page of your forked project and activate the Upstream Sync Action. Once enabled, you can set up hourly automatic updates.
|
20
|
-
|
21
|
-

|
22
|
-

|
23
|
-
|
24
|
-
## `B` Docker Deployment
|
25
|
-
|
26
|
-
Upgrading the Docker deployment version is very simple, just redeploy the latest image of LobeChat. Here are the instructions to perform these steps:
|
27
|
-
|
28
|
-
1. Stop and delete the currently running LobeChat container (assuming the name of the LobeChat container is `lobe-chat`):
|
29
|
-
|
30
|
-
```fish
|
31
|
-
docker stop lobe-chat
|
32
|
-
docker rm lobe-chat
|
33
|
-
```
|
34
|
-
|
35
|
-
2. Pull the latest Docker image of LobeChat:
|
36
|
-
|
37
|
-
```fish
|
38
|
-
docker pull lobehub/lobe-chat
|
39
|
-
```
|
40
|
-
|
41
|
-
3. Redeploy the LobeChat container using the newly pulled image:
|
42
|
-
|
43
|
-
```fish
|
44
|
-
docker run -d -p 3210:3210 \
|
45
|
-
-e OPENAI_API_KEY=sk-xxxx \
|
46
|
-
-e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
|
47
|
-
-e ACCESS_CODE=lobe66 \
|
48
|
-
--name lobe-chat \
|
49
|
-
lobehub/lobe-chat
|
50
|
-
```
|
51
|
-
|
52
|
-
Make sure you have sufficient permissions to stop and delete the container before executing these commands, and Docker has sufficient permissions to pull the new image.
|
53
|
-
|
54
|
-
> \[!NOTE]
|
55
|
-
>
|
56
|
-
> If I redeploy, will my local chat history be lost?
|
57
|
-
>
|
58
|
-
> Don't worry, all of LobeChat's chat history is stored in your local browser. Therefore, when you redeploy LobeChat using Docker, your chat history will not be lost.
|