次の方法で共有


Question Answering - Get Answers

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

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

URI パラメーター

名前 / 必須 説明
Endpoint
path True

string (uri)

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

api-version
query True

string

minLength: 1

この操作に使用する API バージョン。

deploymentName
query True

string

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

projectName
query True

string

maxLength: 100
pattern: ^(?=[a-zA-Z0-9])[a-zA-Z0-9-]{0,98}[a-zA-Z0-9]$

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

要求本文

名前 説明
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

予期しないエラー応答。

ヘッダー

x-ms-error-code: string

セキュリティ

Ocp-Apim-Subscription-Key

型: apiKey
/: header

OAuth2Auth

型: oauth2
フロー: implicit
Authorization URL (承認 URL): https://login.microsoftonline.com/common/oauth2/authorize

スコープ

名前 説明
https://cognitiveservices.azure.com/.default

Successful query

要求のサンプル

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

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

応答のサンプル

{
  "answers": [
    {
      "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.",
      "answerSpan": {
        "confidenceScore": 0.3,
        "length": 50,
        "offset": 33,
        "text": "two to four hours"
      },
      "confidenceScore": 0.65,
      "dialog": {
        "isContextOnly": false,
        "prompts": [
          {
            "displayOrder": 1,
            "displayText": "prompt1",
            "qnaId": 23
          },
          {
            "displayOrder": 2,
            "displayText": "prompt2",
            "qnaId": 36
          }
        ]
      },
      "id": 20,
      "metadata": {
        "category": "api",
        "editorial": "chitchat"
      },
      "questions": [
        "Power and charging"
      ],
      "source": "surface-pro-4-user-guide-EN.pdf"
    },
    {
      "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,
      "questions": [
        "Charge your Surface Pro 4"
      ],
      "source": "surface-pro-4-user-guide-EN.pdf"
    }
  ]
}

定義

名前 説明
AnswersOptions

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

AnswerSpan

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

AnswersResult

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

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[]

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

Error

要求の処理中にサービスでエラーが発生したときに返されるエラー応答オブジェクト。

名前 説明
code

ErrorCode

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

details

Error[]

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

innererror

InnerErrorModel

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

message

string

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

target

string

エラーのターゲット。

ErrorCode

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

説明
AzureCognitiveSearchIndexLimitReached

Azure Cognitive Search インデックスの制限に達しましたエラー

AzureCognitiveSearchIndexNotFound

Azure Cognitive Search インデックスが見つかりませんエラー

AzureCognitiveSearchNotFound

Azure Cognitive Search が見つかりませんエラー

AzureCognitiveSearchThrottling

Azure Cognitive Search の調整エラー

Conflict

競合エラー

Forbidden

許可されていないアクセス エラー

InternalServerError

内部サーバー エラー

InvalidArgument

無効な引数エラー

InvalidRequest

要求エラーが無効です

NotFound

見つからないエラー

OperationNotFound

操作が見つかりませんエラー

ProjectNotFound

プロジェクトが見つかりませんエラー

QuotaExceeded

クォータ超過エラー

ServiceUnavailable

サービス利用不可エラー

Timeout

タイムアウト エラー

TooManyRequests

要求が多すぎますエラー

Unauthorized

未承認のアクセス エラー

Warning

警告エラー

ErrorResponse

エラー応答。

名前 説明
error

Error

エラー オブジェクト。

InnerErrorCode

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

説明
AzureCognitiveSearchNotFound

Azure Cognitive Search が見つかりませんエラー

AzureCognitiveSearchThrottling

Azure Cognitive Search の調整エラー

EmptyRequest

空の要求エラー

ExtractionFailure

抽出エラー エラー

InvalidCountryHint

無効な国ヒント エラー

InvalidDocument

無効なドキュメント エラー

InvalidDocumentBatch

無効なドキュメント バッチ エラー

InvalidParameterValue

パラメーター値のエラーが無効です

InvalidRequest

要求エラーが無効です

InvalidRequestBodyFormat

要求本文の形式エラーが無効です

KnowledgeBaseNotFound

ナレッジ ベースが見つかりませんエラー

MissingInputDocuments

入力ドキュメントが見つからないエラー

ModelVersionIncorrect

モデル のバージョンが正しくないエラー

UnsupportedLanguageCode

サポートされていない言語コード エラー

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

対応する論理演算を使用するための 'AND' です。

OR

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

MetadataFilter

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

名前 説明
logicalOperation

LogicalOperationKind

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

metadata

MetadataRecord[]

文字列の辞書

MetadataRecord

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

名前 説明
key

string

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

value

string

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

QueryFilters

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

名前 説明
logicalOperation

LogicalOperationKind

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

metadataFilter

MetadataFilter

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

sourceFilter

string[]

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

RankerKind

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

説明
Default

既定のランカー。

QuestionOnly

質問のみランカー。

ShortAnswerOptions

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

名前 説明
confidenceScoreThreshold

number (double)

minimum: 0
maximum: 1

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

enable

boolean

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

topAnswersWithSpan

integer (int32)

minimum: 1
maximum: 10

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