跳到正文
实时
Dify Blog·· 2025-01-2265

Dify 通过 REST API 集成微软 Azure AI 搜索

Dify work with Microsoft AI Search

要点速览

Dify 平台通过自定义工具支持 Azure AI 搜索,开发者需在 Azure 创建索引并获取 API 密钥,然后在 Dify 控制台配置工具并设置 schema,最终通过工作流调用实现 AI 驱动的搜索功能。

正文

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