├── DifyAISearchEngine.yml ├── LICENSE └── README.md /DifyAISearchEngine.yml: -------------------------------------------------------------------------------- 1 | app: 2 | description: web搜索扩展总结内容 3 | icon: 🤖 4 | icon_background: '#FFEAD5' 5 | mode: workflow 6 | name: 发起web搜索并总结 7 | kind: app 8 | version: 0.1.1 9 | workflow: 10 | conversation_variables: [] 11 | environment_variables: [] 12 | features: 13 | file_upload: 14 | image: 15 | enabled: false 16 | number_limits: 3 17 | transfer_methods: 18 | - local_file 19 | - remote_url 20 | opening_statement: '' 21 | retriever_resource: 22 | enabled: true 23 | sensitive_word_avoidance: 24 | enabled: false 25 | speech_to_text: 26 | enabled: false 27 | suggested_questions: [] 28 | suggested_questions_after_answer: 29 | enabled: false 30 | text_to_speech: 31 | enabled: false 32 | language: '' 33 | voice: '' 34 | graph: 35 | edges: 36 | - data: 37 | isInIteration: false 38 | sourceType: start 39 | targetType: llm 40 | id: 1724225358355-source-1724225382322-target 41 | source: '1724225358355' 42 | sourceHandle: source 43 | target: '1724225382322' 44 | targetHandle: target 45 | type: custom 46 | zIndex: 0 47 | - data: 48 | isInIteration: false 49 | sourceType: llm 50 | targetType: end 51 | id: 1724228790371-source-1724227013944-target 52 | source: '1724228790371' 53 | sourceHandle: source 54 | target: '1724227013944' 55 | targetHandle: target 56 | type: custom 57 | zIndex: 0 58 | - data: 59 | isInIteration: false 60 | sourceType: llm 61 | targetType: tool 62 | id: 1724225382322-source-1724228514957-target 63 | source: '1724225382322' 64 | sourceHandle: source 65 | target: '1724228514957' 66 | targetHandle: target 67 | type: custom 68 | zIndex: 0 69 | - data: 70 | isInIteration: false 71 | sourceType: tool 72 | targetType: code 73 | id: 1724228514957-source-1724230114999-target 74 | source: '1724228514957' 75 | sourceHandle: source 76 | target: '1724230114999' 77 | targetHandle: target 78 | type: custom 79 | zIndex: 0 80 | - data: 81 | isInIteration: false 82 | sourceType: code 83 | targetType: llm 84 | id: 1724230114999-source-1724228790371-target 85 | source: '1724230114999' 86 | sourceHandle: source 87 | target: '1724228790371' 88 | targetHandle: target 89 | type: custom 90 | zIndex: 0 91 | nodes: 92 | - data: 93 | desc: '' 94 | selected: false 95 | title: 开始 96 | type: start 97 | variables: 98 | - label: 用户输入要查询的文本 99 | max_length: null 100 | options: [] 101 | required: true 102 | type: text-input 103 | variable: user_input_text 104 | height: 90 105 | id: '1724225358355' 106 | position: 107 | x: 30 108 | y: 258 109 | positionAbsolute: 110 | x: 30 111 | y: 258 112 | selected: false 113 | sourcePosition: right 114 | targetPosition: left 115 | type: custom 116 | width: 244 117 | - data: 118 | context: 119 | enabled: false 120 | variable_selector: [] 121 | desc: '' 122 | model: 123 | completion_params: 124 | temperature: 0.7 125 | mode: chat 126 | name: internlm/internlm2_5-7b-chat 127 | provider: siliconflow 128 | prompt_template: 129 | - id: d51d70e4-0437-47bb-99e3-968b2589e931 130 | role: system 131 | text: '【正文】:{{#1724225358355.user_input_text#}} 132 | 133 | 134 | ## 行为 135 | 136 | - 从【正文】中找到三个相关联的【核心关键词】,用于搜索和拓展更多信息 137 | 138 | - 将【核心关键词】用+号拼接 139 | 140 | - 输出拼接后的【核心关键词】 141 | 142 | 143 | ## 注意事项 144 | 145 | - 输出结果只有【核心关键词】 146 | 147 | - 当【正文】中出现人名时,【核心关键词】中必须包含人名 148 | 149 | 150 | ## 示例 151 | 152 | 【正文】:美国总统胡佛 153 | 154 | 【核心关键词】:美国+胡佛+总统 155 | 156 | ' 157 | selected: false 158 | title: 概括关键词主要内容 159 | type: llm 160 | variables: [] 161 | vision: 162 | enabled: false 163 | height: 98 164 | id: '1724225382322' 165 | position: 166 | x: 334 167 | y: 258 168 | positionAbsolute: 169 | x: 334 170 | y: 258 171 | selected: false 172 | sourcePosition: right 173 | targetPosition: left 174 | type: custom 175 | width: 244 176 | - data: 177 | desc: '' 178 | provider_id: duckduckgo 179 | provider_name: duckduckgo 180 | provider_type: builtin 181 | selected: false 182 | title: 调用duckduckgo搜索 183 | tool_configurations: 184 | max_results: 100 185 | require_summary: 0 186 | tool_label: DuckDuckGo 搜索 187 | tool_name: ddgo_search 188 | tool_parameters: 189 | query: 190 | type: mixed 191 | value: '{{#1724225382322.text#}}' 192 | type: tool 193 | height: 116 194 | id: '1724228514957' 195 | position: 196 | x: 638 197 | y: 258 198 | positionAbsolute: 199 | x: 638 200 | y: 258 201 | selected: false 202 | sourcePosition: right 203 | targetPosition: left 204 | type: custom 205 | width: 244 206 | - data: 207 | desc: '' 208 | outputs: 209 | - value_selector: 210 | - '1724228790371' 211 | - text 212 | variable: final_result 213 | selected: false 214 | title: 结束 215 | type: end 216 | height: 90 217 | id: '1724227013944' 218 | position: 219 | x: 1550 220 | y: 258 221 | positionAbsolute: 222 | x: 1550 223 | y: 258 224 | selected: false 225 | sourcePosition: right 226 | targetPosition: left 227 | type: custom 228 | width: 244 229 | - data: 230 | context: 231 | enabled: false 232 | variable_selector: [] 233 | desc: '' 234 | model: 235 | completion_params: 236 | temperature: 0.7 237 | mode: chat 238 | name: moonshot-v1-128k 239 | provider: moonshot 240 | prompt_template: 241 | - edition_type: basic 242 | id: f625c846-e5cd-42a7-8793-460b12384654 243 | role: system 244 | text: '【数据】:{{#1724230114999.result#}} 245 | 246 | 247 | ## 行为 248 | 249 | - 忽略无效和边缘信息,用300-500字中文总结【数据】里的【核心信息】,并备注参考【链接】来源,一步步思考后以markdown格式输出 250 | 251 | - 输出分为两部分,上半部分为【核心信息】,下半部分为【链接】 252 | 253 | 254 | ## 注意事项 255 | 256 | - 【数据】中有【标题】、【链接】和【内容】,参考链接来源必须包含【标题】和【链接】 257 | 258 | ' 259 | selected: false 260 | title: 总结json搜索结果的信息 261 | type: llm 262 | variables: [] 263 | vision: 264 | enabled: false 265 | height: 98 266 | id: '1724228790371' 267 | position: 268 | x: 1246 269 | y: 258 270 | positionAbsolute: 271 | x: 1246 272 | y: 258 273 | selected: true 274 | sourcePosition: right 275 | targetPosition: left 276 | type: custom 277 | width: 244 278 | - data: 279 | code: "import json\n\ndef extract_json_fields(data):\n extracted_data =\ 280 | \ []\n for item in data:\n extracted_item = {\n 'title':\ 281 | \ item.get('title', ''),\n 'href': item.get('href', ''),\n \ 282 | \ 'body': item.get('body', '')\n }\n extracted_data.append(extracted_item)\n\ 283 | \ \n return extracted_data\n\ndef main(arg1):\n result = extract_json_fields(arg1)\n\ 284 | \ \n output = []\n for item in result:\n output.append(f\"\ 285 | 标题: {item['title']}\")\n output.append(f\"链接: {item['href']}\")\n\ 286 | \ output.append(f\"内容: {item['body']}\")\n output.append('-'\ 287 | \ * 50)\n \n return {'result': '\\n'.join(output)}" 288 | code_language: python3 289 | desc: '' 290 | outputs: 291 | result: 292 | children: null 293 | type: string 294 | selected: false 295 | title: 处理json类型的搜索结果 296 | type: code 297 | variables: 298 | - value_selector: 299 | - '1724228514957' 300 | - json 301 | variable: arg1 302 | height: 54 303 | id: '1724230114999' 304 | position: 305 | x: 942 306 | y: 258 307 | positionAbsolute: 308 | x: 942 309 | y: 258 310 | selected: false 311 | sourcePosition: right 312 | targetPosition: left 313 | type: custom 314 | width: 244 315 | viewport: 316 | x: 0 317 | y: 0 318 | zoom: 0.7 319 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DifyAISearchEngine 2 | 3 | ## 项目概述 4 | 5 | DifyAISearchEngine 是一个基于 Dify 构建的高级搜索工具,结合了人工智能和传统搜索引擎的优势。该工具能够理解并总结用户查询,执行智能搜索,并以结构化格式呈现相关信息。 6 | 7 | ## 主要特性 8 | 9 | - **智能查询处理**: 自动总结和优化用户输入 10 | - **集成搜索**: 利用 DuckDuckGo 搜索引擎获取最新、相关的信息 11 | - **AI 驱动的结果总结**: 将搜索结果压缩为易于理解的摘要 12 | - **结构化输出**: 以 Markdown 格式呈现信息,便于阅读和进一步使用 13 | - **来源引用**: 自动为所提供的信息注明参考来源 14 | 15 | ## 工作流程 16 | 17 | 1. **用户输入处理**: 系统接收并分析用户的查询请求。 18 | 2. **查询总结**: AI 模型总结用户输入,提取关键信息。 19 | 3. **搜索执行**: 使用优化后的查询通过 DuckDuckGo 执行搜索。 20 | 4. **结果处理**: 收集和分析搜索结果。 21 | 5. **内容总结**: AI 对搜索结果进行综合和总结。 22 | 6. **格式化输出**: 将总结内容转换为 Markdown 格式。 23 | 7. **添加引用**: 为总结的信息添加原始来源链接。 24 | 25 | ## 使用方法 26 | 27 | 克隆本项目,或下载DifyAISearchEngine.yml文件,导入Dify即可 28 | 29 | ## 依赖 30 | 31 | - [Dify 平台](https://github.com/langgenius/dify) 32 | 33 | ## 配置 34 | 35 | 导入DifyAISearchEngine.yml文件,配置大语言模型即可 36 | 37 | 38 | ## 许可证 39 | 40 | 本项目采用 Apache License 2.0 许可证。 41 | 42 | 这意味着您可以自由地:使用本软件进行商业用途、修改源代码、分发原始或修改后的版本 43 | 44 | 但要求您:包含原始的版权声明、声明对源代码的重大更改、在分发的软件中包含一份许可证副本 45 | 46 | 完整的许可证文本可以在项目根目录的 LICENSE 文件中找到。 47 | 48 | 49 | ## 致谢 50 | 51 | - [Dify 团队提供的强大平台](https://github.com/langgenius/dify) 52 | - [DuckDuckGo](https://duckduckgo.com) 53 | --------------------------------------------------------------------------------