Skip to content

Commit 3888609

Browse files
committed
docs: readme file add web search section
Signed-off-by: Bob Du <i@bobdu.cc>
1 parent 5427d17 commit 3888609

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-0
lines changed

README.en.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Some unique features have been added:
3232

3333
[] Implement SSO login through the auth proxy feature (need to integrate a third-party authentication reverse proxy, it can support login protocols such as LDAP/OIDC/SAML)
3434

35+
[] Web Search functionality (Real-time web search based on Tavily API)
36+
3537
> [!CAUTION]
3638
> This project is only published on GitHub, based on the MIT license, free and for open source learning usage. And there will be no any form of account selling, paid service, discussion group, discussion group and other behaviors. Beware of being deceived.
3739
@@ -72,6 +74,13 @@ Some unique features have been added:
7274
- [Manual packaging](#manual-packaging)
7375
- [Backend service](#backend-service-1)
7476
- [Frontend webpage](#frontend-webpage-1)
77+
- [Auth Proxy Mode](#auth-proxy-mode)
78+
- [Web Search Functionality](#web-search-functionality)
79+
- [Features](#features)
80+
- [Configuration](#configuration)
81+
- [Usage](#usage)
82+
- [Technical Implementation](#technical-implementation)
83+
- [Notes](#notes)
7584
- [Frequently Asked Questions](#frequently-asked-questions)
7685
- [Contributing](#contributing)
7786
- [Sponsorship](#sponsorship)
@@ -347,6 +356,92 @@ Recommended for current IdP to use LDAP protocol, using [authelia](https://www.a
347356

348357
Recommended for current IdP to use OIDC protocol, using [oauth2-proxy](https://oauth2-proxy.github.io/oauth2-proxy)
349358

359+
## Web Search Functionality
360+
361+
> [!TIP]
362+
> Web Search functionality is based on [Tavily API](https://tavily.com/) implementation, allowing ChatGPT to access the latest web information to answer questions.
363+
364+
### Features
365+
366+
- **Real-time Web Search**: Get the latest web information based on Tavily API
367+
- **Intelligent Query Extraction**: Automatically extract the most relevant search keywords from user questions
368+
- **Search Result Integration**: Seamlessly integrate search results into AI conversations
369+
- **Per-session Control**: Each conversation can independently enable or disable search functionality
370+
- **Search History**: Save search queries and results to database
371+
- **Configurable System Messages**: Support custom search-related system prompt messages
372+
373+
### Configuration
374+
375+
#### 1. Get Tavily API Key
376+
377+
1. Visit [Tavily Official Website](https://tavily.com/) to register an account
378+
2. Obtain API Key
379+
380+
#### 2. Administrator Configuration
381+
382+
1. Login to the system as an administrator
383+
2. Go to system settings page
384+
3. Find "Web Search Configuration" option
385+
4. Fill in the following configurations:
386+
- **Enable Status**: Turn on/off global search functionality
387+
- **API Key**: Enter Tavily API Key
388+
- **Search Query System Message**: Prompt template for extracting search keywords
389+
- **Search Result System Message**: Prompt template for processing search results
390+
391+
#### 3. System Message Templates
392+
393+
**Search Query Extraction Template** (for extracting search keywords from user questions):
394+
```
395+
You are a search query extraction assistant. Extract the most relevant search query from user's question and wrap it with <search_query></search_query> tags.
396+
Current time: {current_time}
397+
```
398+
399+
**Search Result Processing Template** (for processing conversations with search results):
400+
```
401+
You are a helpful assistant with access to real-time web search results. Use the provided search information to give accurate and up-to-date responses.
402+
Current time: {current_time}
403+
```
404+
405+
### Usage
406+
407+
#### User Operations
408+
409+
1. **Enable Search Functionality**:
410+
- In the conversation interface, find the search toggle button
411+
- Click to enable web search functionality for the current session
412+
413+
2. **Ask Questions for Real-time Information**:
414+
- After enabling search, directly ask ChatGPT questions that require real-time information
415+
- The system will automatically search for relevant information and integrate it into the response
416+
417+
3. **View Search History**:
418+
- Search queries and results are saved in the database
419+
- You can view specific search records through the database
420+
421+
#### Workflow
422+
423+
1. **User Question**: User asks a question in a search-enabled session
424+
2. **Query Extraction**: System uses AI to extract search keywords from the question
425+
3. **Web Search**: Call Tavily API for real-time search
426+
4. **Result Integration**: Provide search results as context to AI
427+
5. **Generate Response**: AI generates more accurate responses based on search results
428+
429+
### Technical Implementation
430+
431+
- **Search Engine**: Tavily API
432+
- **Query Extraction**: Use OpenAI API to intelligently extract keywords
433+
- **Result Format**: JSON format to store complete search results
434+
- **Data Storage**: MongoDB stores search queries and results
435+
- **Timeout Setting**: Search request timeout is 300 seconds
436+
437+
### Notes
438+
439+
- Web Search functionality requires additional Tavily API costs
440+
- Search functionality will increase response time
441+
- It is recommended to enable selectively based on actual needs
442+
- Administrators can control the global search functionality status
443+
- Each session can independently control whether to use search functionality
444+
350445
351446
## Contributing
352447

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
[] 通过 auth proxy 功能实现sso登录 (配合第三方身份验证反向代理 可实现支持 LDAP/OIDC/SAML 等协议登录)
3434

35+
[] Web Search 网络搜索功能 (基于 Tavily API 实现实时网络搜索)
36+
3537

3638
> [!CAUTION]
3739
> 声明:此项目只发布于 Github,基于 MIT 协议,免费且作为开源学习使用。并且不会有任何形式的卖号、付费服务、讨论群、讨论组等行为。谨防受骗。
@@ -74,6 +76,13 @@
7476
- [手动打包](#手动打包)
7577
- [后端服务](#后端服务-1)
7678
- [前端网页](#前端网页-1)
79+
- [Auth Proxy Mode](#auth-proxy-mode)
80+
- [Web Search 网络搜索功能](#web-search-网络搜索功能)
81+
- [功能特性](#功能特性)
82+
- [配置方式](#配置方式)
83+
- [使用方式](#使用方式)
84+
- [技术实现](#技术实现)
85+
- [注意事项](#注意事项)
7786
- [常见问题](#常见问题)
7887
- [参与贡献](#参与贡献)
7988
- [赞助](#赞助)
@@ -358,6 +367,92 @@ pnpm build
358367

359368
当前 Idp 使用 OIDC 协议的 可以选择使用 [oauth2-proxy](https://oauth2-proxy.github.io/oauth2-proxy)
360369

370+
## Web Search 网络搜索功能
371+
372+
> [!TIP]
373+
> Web Search 功能基于 [Tavily API](https://tavily.com/) 实现,可以让 ChatGPT 获取最新的网络信息来回答问题。
374+
375+
### 功能特性
376+
377+
- **实时网络搜索**: 基于 Tavily API 获取最新的网络信息
378+
- **智能查询提取**: 自动从用户问题中提取最相关的搜索关键词
379+
- **搜索结果整合**: 将搜索结果无缝整合到 AI 对话中
380+
- **按会话控制**: 每个对话可以独立开启或关闭搜索功能
381+
- **搜索历史记录**: 保存搜索查询和结果到数据库
382+
- **可配置系统消息**: 支持自定义搜索相关的系统提示消息
383+
384+
### 配置方式
385+
386+
#### 1. 获取 Tavily API Key
387+
388+
1. 访问 [Tavily 官网](https://tavily.com/) 注册账号
389+
2. 获取 API Key
390+
391+
#### 2. 管理员配置
392+
393+
1. 以管理员身份登录系统
394+
2. 进入系统设置页面
395+
3. 找到 "Web Search 配置" 选项
396+
4. 填写以下配置:
397+
- **启用状态**: 开启/关闭全局搜索功能
398+
- **API Key**: 填入 Tavily API Key
399+
- **搜索查询系统消息**: 用于提取搜索关键词的提示模板
400+
- **搜索结果系统消息**: 用于处理搜索结果的提示模板
401+
402+
#### 3. 系统消息模板
403+
404+
**搜索查询提取模板** (用于从用户问题中提取搜索关键词):
405+
```
406+
You are a search query extraction assistant. Extract the most relevant search query from user's question and wrap it with <search_query></search_query> tags.
407+
Current time: {current_time}
408+
```
409+
410+
**搜索结果处理模板** (用于处理包含搜索结果的对话):
411+
```
412+
You are a helpful assistant with access to real-time web search results. Use the provided search information to give accurate and up-to-date responses.
413+
Current time: {current_time}
414+
```
415+
416+
### 使用方式
417+
418+
#### 用户端操作
419+
420+
1. **开启搜索功能**:
421+
- 在对话界面中,找到搜索开关按钮
422+
- 点击开启当前会话的网络搜索功能
423+
424+
2. **提问获取实时信息**:
425+
- 开启搜索后,直接向 ChatGPT 提问需要实时信息的问题
426+
- 系统会自动搜索相关信息并整合到回答中
427+
428+
3. **查看搜索历史**:
429+
- 搜索查询和结果会保存在数据库中
430+
- 可以通过数据库查看具体的搜索记录
431+
432+
#### 工作流程
433+
434+
1. **用户提问**: 用户在开启搜索的会话中提问
435+
2. **查询提取**: 系统使用 AI 从问题中提取搜索关键词
436+
3. **网络搜索**: 调用 Tavily API 进行实时搜索
437+
4. **结果整合**: 将搜索结果作为上下文提供给 AI
438+
5. **生成回答**: AI 基于搜索结果生成更准确的回答
439+
440+
### 技术实现
441+
442+
- **搜索引擎**: Tavily API
443+
- **查询提取**: 使用 OpenAI API 智能提取关键词
444+
- **结果格式**: JSON 格式存储完整搜索结果
445+
- **数据存储**: MongoDB 存储搜索查询和结果
446+
- **超时设置**: 搜索请求超时时间为 300 秒
447+
448+
### 注意事项
449+
450+
- Web Search 功能需要额外的 Tavily API 费用
451+
- 搜索功能会增加响应时间
452+
- 建议根据实际需求选择性开启
453+
- 管理员可以控制全局搜索功能的开启状态
454+
- 每个会话可以独立控制是否使用搜索功能
455+
361456

362457
## 常见问题
363458
Q: 为什么 `Git` 提交总是报错?

0 commit comments

Comments
 (0)