次の方法で共有


Question Answering - Get Answers

ナレッジ ベースを使用して、指定した質問に回答します。

POST {Endpoint}/language/:query-knowledgebases?projectName={projectName}&deploymentName={deploymentName}&api-version=2021-10-01

URI パラメーター

名前 / 必須 説明
Endpoint
path True

string

サポートされている Cognitive Services エンドポイント (例: https://.api.cognitiveservices.azure.com).

api-version
query True

string

クライアント API のバージョン。

deploymentName
query True

string

使用するプロジェクトの特定の配置の名前。

projectName
query True

string

使用するプロジェクトの名前。

要求ヘッダー

名前 必須 説明
Ocp-Apim-Subscription-Key True

string

要求本文

名前 説明
answerSpanRequest

ShortAnswerOptions

回答スパン予測機能を構成するには。

confidenceScoreThreshold

number (double)

minimum: 0
maximum: 1

回答の最小しきい値スコア。値の範囲は 0 から 1 です。

context

KnowledgeBaseAnswerContext

以前の QnA の情報を持つコンテキスト オブジェクト。

filters

QueryFilters

指定されたメタデータ リストとナレッジ ベース ソースに基づいて QnA をフィルター処理します。

includeUnstructuredSources

boolean

(省略可能)非構造化ソースに対するクエリを有効にするフラグ。

qnaId

integer (int32)

ナレッジ ベースからフェッチする正確な QnA ID。このフィールドは質問よりも優先されます。

question

string

ナレッジ ベースに対してクエリを実行するユーザーの質問。

rankerType

RankerKind

使用するランカーの種類。

top

integer (int32)

質問に対して返される回答の最大数。

userId

string

ユーザーの一意識別子。

応答

名前 説明
200 OK

AnswersResult

ナレッジ ベースから回答を取得するための成功した応答。

Other Status Codes

ErrorResponse

エラー応答。

セキュリティ

Ocp-Apim-Subscription-Key

型: apiKey
/: header

Successful query

要求のサンプル

POST {Endpoint}/language/:query-knowledgebases?projectName=proj1&deploymentName=production&api-version=2021-10-01


{
  "question": "how long it takes to charge surface?",
  "top": 3,
  "userId": "sd53lsY=",
  "confidenceScoreThreshold": 0.2,
  "context": {
    "previousQnaId": 9,
    "previousUserQuery": "Where are QnA Maker quickstarts?"
  },
  "rankerType": "Default",
  "filters": {
    "metadataFilter": {
      "metadata": [
        {
          "key": "category",
          "value": "api"
        },
        {
          "key": "editorial",
          "value": "chitchat"
        }
      ],
      "logicalOperation": "AND"
    },
    "sourceFilter": [
      "filename1.pdf",
      "https://www.wikipedia.org/microsoft"
    ],
    "logicalOperation": "AND"
  },
  "answerSpanRequest": {
    "enable": true,
    "confidenceScoreThreshold": 0.2,
    "topAnswersWithSpan": 1
  },
  "includeUnstructuredSources": true
}

応答のサンプル

{
  "answers": [
    {
      "questions": [
        "Power and charging"
      ],
      "answer": "Power and charging**\n\nIt takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you’re using your Surface for power-intensive activities like gaming or video streaming while you’re charging it.\n\nYou can use the USB port on your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB port on your Surface.",
      "confidenceScore": 0.65,
      "id": 20,
      "source": "surface-pro-4-user-guide-EN.pdf",
      "metadata": {
        "category": "api",
        "editorial": "chitchat"
      },
      "dialog": {
        "isContextOnly": false,
        "prompts": [
          {
            "displayOrder": 1,
            "qnaId": 23,
            "displayText": "prompt1"
          },
          {
            "displayOrder": 2,
            "qnaId": 36,
            "displayText": "prompt2"
          }
        ]
      },
      "answerSpan": {
        "text": "two to four hours",
        "confidenceScore": 0.3,
        "offset": 33,
        "length": 50
      }
    },
    {
      "questions": [
        "Charge your Surface Pro 4"
      ],
      "answer": "**Charge your Surface Pro 4**\n\n1.  Connect the two parts of the power cord.\n\n2.  Connect the power cord securely to the charging port.\n\n3.  Plug the power supply into an electrical outlet.",
      "confidenceScore": 0.32,
      "id": 13,
      "source": "surface-pro-4-user-guide-EN.pdf"
    }
  ]
}

定義

名前 説明
AnswersOptions

ナレッジ ベースに対してクエリを実行するパラメーター。

AnswerSpan

QnA の回答スパン オブジェクト。

AnswersResult

質問の回答の一覧を表します。

enable

回答スパン予測を有効または無効にします。

Error

エラー オブジェクト。

ErrorCode

人間が判読できるエラー コード。

ErrorResponse

エラー応答。

InnerErrorCode

人間が判読できるエラー コード。

InnerErrorModel

エラーに関するより具体的な情報を含むオブジェクト。 Microsoft One API のガイドラインに従って - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.

KnowledgeBaseAnswer

ナレッジ ベースの回答を表します。

KnowledgeBaseAnswerContext

以前の QnA の情報を持つコンテキスト オブジェクト。

KnowledgeBaseAnswerDialog

回答に関連付けられているダイアログ。

KnowledgeBaseAnswerPrompt

回答を求めるメッセージを表示します。

LogicalOperationKind

対応する論理操作を使用するには、'OR' または 'AND' に設定します。

MetadataFilter

指定されたメタデータの一覧に関連付けられている QnA を検索します。

MetadataRecord

各メタデータのキー値ペアを提供するオブジェクト。

QueryFilters

ナレッジ ベースをフィルター処理します。

RankerKind

使用するランカーの種類。

ShortAnswerOptions

回答スパン予測機能を構成するには。

AnswersOptions

ナレッジ ベースに対してクエリを実行するパラメーター。

名前 説明
answerSpanRequest

ShortAnswerOptions

回答スパン予測機能を構成するには。

confidenceScoreThreshold

number (double)

minimum: 0
maximum: 1

回答の最小しきい値スコア。値の範囲は 0 から 1 です。

context

KnowledgeBaseAnswerContext

以前の QnA の情報を持つコンテキスト オブジェクト。

filters

QueryFilters

指定されたメタデータ リストとナレッジ ベース ソースに基づいて QnA をフィルター処理します。

includeUnstructuredSources

boolean

(省略可能)非構造化ソースに対するクエリを有効にするフラグ。

qnaId

integer (int32)

ナレッジ ベースからフェッチする正確な QnA ID。このフィールドは質問よりも優先されます。

question

string

ナレッジ ベースに対してクエリを実行するユーザーの質問。

rankerType

RankerKind

使用するランカーの種類。

top

integer (int32)

質問に対して返される回答の最大数。

userId

string

ユーザーの一意識別子。

AnswerSpan

QnA の回答スパン オブジェクト。

名前 説明
confidenceScore

number (double)

minimum: 0
maximum: 1

回答スパンの予測スコア。値の範囲は 0 から 1 です。

length

integer (int32)

回答スパンの長さ。

offset

integer (int32)

回答の開始からの回答スパン オフセット。

text

string

回答スパンの予測テキスト。

AnswersResult

質問の回答の一覧を表します。

名前 説明
answers

KnowledgeBaseAnswer[]

回答結果の一覧を表します。

enable

回答スパン予測を有効または無効にします。

説明
True

Error

エラー オブジェクト。

名前 説明
code

ErrorCode

サーバー定義の一連のエラー コードの 1 つ。

details

Error[]

この報告されたエラーの原因となった特定のエラーに関する詳細の配列。

innererror

InnerErrorModel

エラーに関する現在のオブジェクトよりも具体的な情報を含むオブジェクト。

message

string

エラーの人間が判読できる表現。

target

string

エラーのターゲット。

ErrorCode

人間が判読できるエラー コード。

説明
AzureCognitiveSearchIndexLimitReached
AzureCognitiveSearchIndexNotFound
AzureCognitiveSearchNotFound
AzureCognitiveSearchThrottling
Forbidden
InternalServerError
InvalidArgument
InvalidRequest
NotFound
OperationNotFound
ProjectNotFound
ServiceUnavailable
TooManyRequests
Unauthorized

ErrorResponse

エラー応答。

名前 説明
error

Error

エラー オブジェクト。

InnerErrorCode

人間が判読できるエラー コード。

説明
AzureCognitiveSearchNotFound
AzureCognitiveSearchThrottling
ExtractionFailure
InvalidParameterValue
InvalidRequest
KnowledgeBaseNotFound

InnerErrorModel

エラーに関するより具体的な情報を含むオブジェクト。 Microsoft One API のガイドラインに従って - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.

名前 説明
code

InnerErrorCode

サーバー定義の一連のエラー コードの 1 つ。

details

object

エラーの詳細。

innererror

InnerErrorModel

エラーに関する現在のオブジェクトよりも具体的な情報を含むオブジェクト。

message

string

エラーメッセージ。

target

string

エラーターゲット。

KnowledgeBaseAnswer

ナレッジ ベースの回答を表します。

名前 説明
answer

string

回答テキスト。

answerSpan

AnswerSpan

ユーザーの質問に関する QnA の回答スパン オブジェクト。

confidenceScore

number (double)

minimum: 0
maximum: 1

信頼度スコアに回答します。値の範囲は 0 から 1 です。

dialog

KnowledgeBaseAnswerDialog

回答に関連付けられているダイアログ。

id

integer (int32)

QnA 結果の ID。

metadata

object

回答に関連付けられたメタデータ。質問の回答を分類またはフィルター処理するのに役立ちます。

questions

string[]

回答に関連付けられている質問の一覧。

source

string

QnA 結果のソース。

KnowledgeBaseAnswerContext

以前の QnA の情報を持つコンテキスト オブジェクト。

名前 説明
previousQnaId

integer (int32)

前のターントップ回答の結果 QnA ID。

previousUserQuery

string

前のユーザー クエリ。

KnowledgeBaseAnswerDialog

回答に関連付けられているダイアログ。

名前 説明
isContextOnly

boolean

プロンプトが前の質問にのみ関連するかどうかをマークする。 true の場合は、コンテキストのないクエリの検索結果としてこの QnA を含めないでください。それ以外の場合、false の場合はコンテキストが無視され、この QnA が検索結果に含まれます。

prompts

KnowledgeBaseAnswerPrompt[]

回答に関連付けられているプロンプトの一覧。

KnowledgeBaseAnswerPrompt

回答を求めるメッセージを表示します。

名前 説明
displayOrder

integer (int32)

プロンプトのインデックス - プロンプトの順序付けで使用されます。

displayText

string

maxLength: 200

フォローアップの質問プロンプトを表すテキストが表示されます。

qnaId

integer (int32)

プロンプトに対応する QnA ID。

LogicalOperationKind

対応する論理操作を使用するには、'OR' または 'AND' に設定します。

説明
AND
OR

MetadataFilter

指定されたメタデータの一覧に関連付けられている QnA を検索します。

名前 規定値 説明
logicalOperation

LogicalOperationKind

AND

メタデータ フィルターを結合するために使用される操作。

metadata

MetadataRecord[]

各メタデータのキー値ペアを提供するオブジェクト。

MetadataRecord

各メタデータのキー値ペアを提供するオブジェクト。

名前 説明
key

string

QnA で使用されるメタデータ ディクショナリのメタデータ キー。

value

string

QnA で使用されるメタデータ ディクショナリのメタデータ値。

QueryFilters

ナレッジ ベースをフィルター処理します。

名前 規定値 説明
logicalOperation

LogicalOperationKind

AND

メタデータ フィルターをソース フィルターと結合するために使用される論理操作。

metadataFilter

MetadataFilter

指定されたメタデータの一覧に関連付けられている QnA を検索します。

sourceFilter

string[]

ナレッジ ベース内の特定のソースの一覧に関連付けられている QnA を検索します。

RankerKind

使用するランカーの種類。

説明
Default

既定のランカー。

QuestionOnly

質問のみランカー。

ShortAnswerOptions

回答スパン予測機能を構成するには。

名前 説明
confidenceScoreThreshold

number (double)

minimum: 0
maximum: 1

回答スパンを含めるために必要な最小しきい値スコア。値の範囲は 0 から 1 です。

enable

enable

回答スパン予測を有効または無効にします。

topAnswersWithSpan

integer (int32)

minimum: 1
maximum: 10

スパン予測で考慮される上位の回答の数は、1 から 10 です。