|
1 | 1 | # GraphRAG4OpenWebUI |
2 | 2 |
|
3 | | -<details open><summary>English</summary> |
| 3 | +<div align="center"> |
| 4 | + <p><strong>Integrate Microsoft's GraphRAG Technology into Open WebUI for Advanced Information Retrieval</strong></p> |
| 5 | + English | <a href="README_ZH-CN.md">简体中文</a> |
| 6 | +</div> |
4 | 7 |
|
5 | 8 | GraphRAG4OpenWebUI is an API interface specifically designed for Open WebUI, aiming to integrate Microsoft Research's GraphRAG (Graph-based Retrieval-Augmented Generation) technology. This project provides a powerful information retrieval system that supports multiple search models, particularly suitable for use in open web user interfaces. |
6 | 9 |
|
@@ -120,128 +123,3 @@ Pull requests are welcome. For major changes, please open an issue first to disc |
120 | 123 | ## License |
121 | 124 |
|
122 | 125 | [Apache-2.0 License](LICENSE) |
123 | | - |
124 | | -</details> |
125 | | - |
126 | | -<details><summary>中文</summary> |
127 | | - |
128 | | -GraphRAG4OpenWebUI 是一个专为 Open WebUI 设计的 API 接口,旨在集成微软研究院的 GraphRAG(Graph-based Retrieval-Augmented Generation)技术。该项目提供了一个强大的信息检索系统,支持多种搜索模型,特别适合在开放式 Web 用户界面中使用。 |
129 | | - |
130 | | -## 项目概述 |
131 | | - |
132 | | -本项目的主要目标是为 Open WebUI 提供一个便捷的接口,以利用 GraphRAG 的强大功能。它集成了三种主要的检索方法,并提供了一个综合搜索选项,使用户能够获得全面而精确的搜索结果。 |
133 | | - |
134 | | -### 主要检索功能 |
135 | | - |
136 | | -1. **本地搜索(Local Search)** |
137 | | - - 利用 GraphRAG 技术在本地知识库中进行高效检索 |
138 | | - - 适用于快速访问预先定义的结构化信息 |
139 | | - - 利用图结构提高检索的准确性和相关性 |
140 | | - |
141 | | -2. **全局搜索(Global Search)** |
142 | | - - 在更广泛的范围内搜索信息,超越本地知识库的限制 |
143 | | - - 适用于需要更全面信息的查询 |
144 | | - - 利用 GraphRAG 的全局上下文理解能力,提供更丰富的搜索结果 |
145 | | - |
146 | | -3. **Tavily 搜索** |
147 | | - - 集成外部 Tavily 搜索 API |
148 | | - - 提供额外的互联网搜索能力,扩展信息源 |
149 | | - - 适用于需要最新或广泛网络信息的查询 |
150 | | - |
151 | | -4. **全模型搜索(Full Model Search)** |
152 | | - - 综合上述三种搜索方法 |
153 | | - - 提供最全面的搜索结果,满足复杂的信息需求 |
154 | | - - 自动整合和排序来自不同来源的信息 |
155 | | - |
156 | | -## 安装 |
157 | | - |
158 | | -确保你的系统中已安装 Python 3.8 或更高版本。然后,按照以下步骤安装: |
159 | | - |
160 | | -1. 克隆仓库: |
161 | | - ``` |
162 | | - git clone https://github.com/your-username/GraphRAG4OpenWebUI.git |
163 | | - cd GraphRAG4OpenWebUI |
164 | | - ``` |
165 | | - |
166 | | -2. 创建并激活虚拟环境: |
167 | | - ``` |
168 | | - python -m venv venv |
169 | | - source venv/bin/activate # 在 Windows 上使用 venv\Scripts\activate |
170 | | - ``` |
171 | | - |
172 | | -3. 安装依赖: |
173 | | - ``` |
174 | | - pip install fastapi uvicorn pandas tiktoken graphrag tavily-python pydantic python-dotenv asyncio aiohttp numpy scikit-learn matplotlib seaborn nltk spacy transformers torch torchvision torchaudio |
175 | | - ``` |
176 | | - |
177 | | - 注意:`graphrag` 包可能需要从特定的源安装。如果上述命令无法安装 `graphrag`,请参考微软研究院的具体说明或联系维护者获取正确的安装方法。 |
178 | | - |
179 | | -## 配置 |
180 | | - |
181 | | -在运行 API 之前,需要设置以下环境变量。你可以通过创建 `.env` 文件或直接在终端中导出这些变量: |
182 | | - |
183 | | -```bash |
184 | | -export GRAPHRAG_API_KEY="your_graphrag_api_key" |
185 | | -export TAVILY_API_KEY="your_tavily_api_key" |
186 | | -export GRAPHRAG_LLM_MODEL="gpt-3.5-turbo" |
187 | | -export GRAPHRAG_EMBEDDING_MODEL="text-embedding-3-small" |
188 | | -export INPUT_DIR="/path/to/your/input/directory" |
189 | | -``` |
190 | | - |
191 | | -确保将上述命令中的占位符替换为实际的 API 密钥和路径。 |
192 | | - |
193 | | -## 使用方法 |
194 | | - |
195 | | -1. 启动服务器: |
196 | | - ``` |
197 | | - python main.py |
198 | | - ``` |
199 | | - 服务器将在 `http://localhost:8012` 上运行。 |
200 | | - |
201 | | -2. API 端点: |
202 | | - - `/v1/chat/completions`: POST 请求,用于执行搜索 |
203 | | - - `/v1/models`: GET 请求,获取可用模型列表 |
204 | | - |
205 | | -3. 在 Open WebUI 中集成: |
206 | | - 在 Open WebUI 的配置中,将 API 端点设置为 `http://localhost:8012/v1/chat/completions`。这将允许 Open WebUI 使用 GraphRAG4OpenWebUI 的搜索功能。 |
207 | | - |
208 | | -4. 发送搜索请求示例: |
209 | | - ```python |
210 | | - import requests |
211 | | - import json |
212 | | - |
213 | | - url = "http://localhost:8012/v1/chat/completions" |
214 | | - headers = {"Content-Type": "application/json"} |
215 | | - data = { |
216 | | - "model": "full-model:latest", |
217 | | - "messages": [{"role": "user", "content": "你的搜索查询"}], |
218 | | - "temperature": 0.7 |
219 | | - } |
220 | | - |
221 | | - response = requests.post(url, headers=headers, data=json.dumps(data)) |
222 | | - print(response.json()) |
223 | | - ``` |
224 | | - |
225 | | -## 可用模型 |
226 | | - |
227 | | -- `graphrag-local-search:latest`: 本地搜索 |
228 | | -- `graphrag-global-search:latest`: 全局搜索 |
229 | | -- `tavily-search:latest`: Tavily 搜索 |
230 | | -- `full-model:latest`: 综合搜索(包含上述所有搜索方法) |
231 | | - |
232 | | -## 注意事项 |
233 | | - |
234 | | -- 确保在 `INPUT_DIR` 目录中有正确的输入文件(如 Parquet 文件)。 |
235 | | -- API 使用异步编程,确保你的环境支持异步操作。 |
236 | | -- 对于大规模部署,考虑使用生产级的 ASGI 服务器。 |
237 | | -- 本项目专为 Open WebUI 设计,可以轻松集成到各种基于 Web 的应用中。 |
238 | | - |
239 | | -## 贡献 |
240 | | - |
241 | | -欢迎提交 Pull Requests 来改进这个项目。对于重大变更,请先开 issue 讨论你想要改变的内容。 |
242 | | - |
243 | | -## 许可证 |
244 | | - |
245 | | -[Apache-2.0 许可证](LICENSE) |
246 | | - |
247 | | -</details> |
0 commit comments