跳到正文
Dify Blog·· 1 天前AI 評分37

Dify 如何透過自訂工具整合 Azure AI Search

Dify work with Microsoft AI Search

AI 導讀

Dify 的自訂工具可透過 REST API 接入 Azure AI Search,文章示範建立索引、設定工具 schema 和 API 金鑰,並在 Dify 工作流程中測試搜尋及查看 LLM 階段結果。Dify 是用於開發大語言模型應用程式的開源平台。

正文

How to

Dify’s custom tool makes it easy to add Azure’s fast, AI-driven search via REST API.

Xinyu WeiXinyu WeiSenior Technical Specialist, Microsoft

Written onJan 22, 2025

Share

Dify is an open-source platform for developing large language model (LLM) applications. It combines the concepts of Backend as a Service (BaaS) and LLMOps, enabling developers to quickly build production-grade generative AI applications.

Dify offers various types of tools, including first-party and custom tools. These tools can extend the capabilities of LLMs, such as web search, scientific calculations, image generation, and more. On Dify, you can create more powerful AI applications, like intelligent assistant-type applications, which can complete complex tasks through task reasoning, step decomposition, and tool invocation.

Dify works with AI Search Demo

Till now, Dify could not integrate with Microsoft directly via default Dify web portal. Let me show how to achieve it.

Please log in to YouTube to watch the tutorial.

Dify works with AI Search Configuration steps

Configure on AI search:

Create index, make sure you could get the result from AI search index:

Run Dify on VM via docker:

bash

root@a100vm:~# docker ps |grep -i dify5d6c32a94313   langgenius/dify-api:0.8.3          "/bin/bash /entrypoi…"   3 months ago   Up 3 minutes             5001/tcp                                                                   docker-worker-1264e477883ee   langgenius/dify-api:0.8.3          "/bin/bash /entrypoi…"   3 months ago   Up 3 minutes             5001/tcp                                                                   docker-api-12eb90cd5280a   langgenius/dify-sandbox:0.2.9      "/main"                  3 months ago   Up 3 minutes (healthy)                                                                              docker-sandbox-1708937964fbb   langgenius/dify-web:0.8.3          "/bin/sh ./entrypoin…"   3 months ago   Up 3 minutes             3000/tcp                                                                   docker-web-1

Create customer tool in Dify portal,set schema:

Schema details:

json

{  "openapi": "3.0.0",  "info": {    "title": "Azure Cognitive Search Integration",    "version": "1.0.0"  },  "servers": [    {      "url": "https://ai-search-eastus-xinyuwei.search.windows.net"    }  ],  "paths": {    "/indexes/wukong-doc1/docs": {      "get": {        "operationId": "getSearchResults",        "parameters": [          {            "name": "api-version",            "in": "query",            "required": true,            "schema": {              "type": "string",              "example": "2024-11-01-preview"            }          },          {            "name": "search",            "in": "query",            "required": true,            "schema": {              "type": "string"            }          }        ],        "responses": {          "200": {            "description": "Successful response",            "content": {              "application/json": {                "schema": {                  "type": "object",                  "properties": {                    "@odata.context": { "type": "string" },                    "value": {                      "type": "array",                      "items": {                        "type": "object",                        "properties": {                          "@search.score": { "type": "number" },                          "chunk_id": { "type": "string" },                          "parent_id": { "type": "string" },                          "title": { "type": "string" },                          "chunk": { "type": "string" },                          "text_vector": { "type": "SingleCollection" },                        }                      }                    }                  }                }              }            }          }        }      }    }  }}

Set AI Search AI key:

Do search test:

Input words:

Create a workflow on Dify:

 Check AI search stage:

Check LLM stage:

Run workflow:

Get workflow result:

Related articles

來源:Dify Blog · dify.ai