🌟

【Azure/Prompt Flow】- Prompt FlowでAzure AI Searchをノードから呼び出す方法

に公開

執筆日

2025/7/28

やりたいこと

Azure AI Foundry(=Azure Machine Learning)にある Prompt Flow を使って、Azure AI Search)へクエリを送るベクター検索フローを構築したい。
ただ、Pythonコードベースのノードではライブラリエラーが。

ModuleNotFoundError: No module named 'azure.search.documents'

対処法

+その他のツール>Index LookUp からノード追加することで、以下のようなインデックス検索が可能です:

  • Azure AI Search (ACS)
  • FAISS
  • Pinecone

YAMLファイル

以下はYAMLファイルのIndex Lookupノードの定義例です。
GUIからIndex LookUpを検索すると、勝手にYAMLに追加されます。

nodes:
- name: aisearch
  type: python
  source:
    type: package
    tool: promptflow_vectordb.tool.common_index_lookup.search
  inputs:
    mlindex_content: 
      embeddings:
        api_base: https://<your-aoai-endpoint>.openai.azure.com/
        api_type: azure
        api_version: 2023-07-01-preview
        batch_size: '1'
        connection:
          id: /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.MachineLearningServices/workspaces/<workspace>/connections/<aoai-connection>
        connection_type: workspace_connection
        deployment: <Embeddingモデル名>
        dimension: 1536
        kind: open_ai
        model:  <Embeddingモデル名>
        schema_version: '2'
      index:
        api_version: 2024-05-01-preview
        connection:
          id: /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.MachineLearningServices/workspaces/<workspace>/connections/<cogsearch-connection>
        connection_type: workspace_connection
        endpoint: https://<your-search-service>.search.windows.net/
        engine: azure-sdk
        field_mapping:
          content: content
          embedding: title_vector
          metadata: category
        index: demo
        kind: acs
        semantic_configuration_name: null
    queries: ${inputs.question}
    query_type: <検索方法>
    top_k: <検索結果の件数(TopN)>
  use_variants: false

参考記事

https://learn.microsoft.com/ja-jp/azure/machine-learning/prompt-flow/tools-reference/index-lookup-tool?view=azureml-api-2

ヘッドウォータース

Discussion