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 のバージョン。 |
deployment
|
query | True |
string |
使用するプロジェクトの特定の配置の名前。 |
project
|
query | True |
string |
使用するプロジェクトの名前。 |
要求ヘッダー
名前 | 必須 | 型 | 説明 |
---|---|---|---|
Ocp-Apim-Subscription-Key | True |
string |
要求本文
名前 | 型 | 説明 |
---|---|---|
answerSpanRequest |
回答スパン予測機能を構成するには。 |
|
confidenceScoreThreshold |
number (double) minimum: 0maximum: 1 |
回答の最小しきい値スコア。値の範囲は 0 から 1 です。 |
context |
以前の QnA の情報を持つコンテキスト オブジェクト。 |
|
filters |
指定されたメタデータ リストとナレッジ ベース ソースに基づいて QnA をフィルター処理します。 |
|
includeUnstructuredSources |
boolean |
(省略可能)非構造化ソースに対するクエリを有効にするフラグ。 |
qnaId |
integer (int32) |
ナレッジ ベースからフェッチする正確な QnA ID。このフィールドは質問よりも優先されます。 |
question |
string |
ナレッジ ベースに対してクエリを実行するユーザーの質問。 |
rankerType |
使用するランカーの種類。 |
|
top |
integer (int32) |
質問に対して返される回答の最大数。 |
userId |
string |
ユーザーの一意識別子。 |
応答
名前 | 型 | 説明 |
---|---|---|
200 OK |
ナレッジ ベースから回答を取得するための成功した応答。 |
|
Other Status Codes |
エラー応答。 |
セキュリティ
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"
}
]
}
定義
名前 | 説明 |
---|---|
Answers |
ナレッジ ベースに対してクエリを実行するパラメーター。 |
Answer |
QnA の回答スパン オブジェクト。 |
Answers |
質問の回答の一覧を表します。 |
enable |
回答スパン予測を有効または無効にします。 |
Error |
エラー オブジェクト。 |
Error |
人間が判読できるエラー コード。 |
Error |
エラー応答。 |
Inner |
人間が判読できるエラー コード。 |
Inner |
エラーに関するより具体的な情報を含むオブジェクト。 Microsoft One API のガイドラインに従って - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
Knowledge |
ナレッジ ベースの回答を表します。 |
Knowledge |
以前の QnA の情報を持つコンテキスト オブジェクト。 |
Knowledge |
回答に関連付けられているダイアログ。 |
Knowledge |
回答を求めるメッセージを表示します。 |
Logical |
対応する論理操作を使用するには、'OR' または 'AND' に設定します。 |
Metadata |
指定されたメタデータの一覧に関連付けられている QnA を検索します。 |
Metadata |
各メタデータのキー値ペアを提供するオブジェクト。 |
Query |
ナレッジ ベースをフィルター処理します。 |
Ranker |
使用するランカーの種類。 |
Short |
回答スパン予測機能を構成するには。 |
AnswersOptions
ナレッジ ベースに対してクエリを実行するパラメーター。
名前 | 型 | 説明 |
---|---|---|
answerSpanRequest |
回答スパン予測機能を構成するには。 |
|
confidenceScoreThreshold |
number (double) minimum: 0maximum: 1 |
回答の最小しきい値スコア。値の範囲は 0 から 1 です。 |
context |
以前の QnA の情報を持つコンテキスト オブジェクト。 |
|
filters |
指定されたメタデータ リストとナレッジ ベース ソースに基づいて QnA をフィルター処理します。 |
|
includeUnstructuredSources |
boolean |
(省略可能)非構造化ソースに対するクエリを有効にするフラグ。 |
qnaId |
integer (int32) |
ナレッジ ベースからフェッチする正確な QnA ID。このフィールドは質問よりも優先されます。 |
question |
string |
ナレッジ ベースに対してクエリを実行するユーザーの質問。 |
rankerType |
使用するランカーの種類。 |
|
top |
integer (int32) |
質問に対して返される回答の最大数。 |
userId |
string |
ユーザーの一意識別子。 |
AnswerSpan
QnA の回答スパン オブジェクト。
名前 | 型 | 説明 |
---|---|---|
confidenceScore |
number (double) minimum: 0maximum: 1 |
回答スパンの予測スコア。値の範囲は 0 から 1 です。 |
length |
integer (int32) |
回答スパンの長さ。 |
offset |
integer (int32) |
回答の開始からの回答スパン オフセット。 |
text |
string |
回答スパンの予測テキスト。 |
AnswersResult
質問の回答の一覧を表します。
名前 | 型 | 説明 |
---|---|---|
answers |
回答結果の一覧を表します。 |
enable
回答スパン予測を有効または無効にします。
値 | 説明 |
---|---|
True |
Error
エラー オブジェクト。
名前 | 型 | 説明 |
---|---|---|
code |
サーバー定義の一連のエラー コードの 1 つ。 |
|
details |
Error[] |
この報告されたエラーの原因となった特定のエラーに関する詳細の配列。 |
innererror |
エラーに関する現在のオブジェクトよりも具体的な情報を含むオブジェクト。 |
|
message |
string |
エラーの人間が判読できる表現。 |
target |
string |
エラーのターゲット。 |
ErrorCode
人間が判読できるエラー コード。
値 | 説明 |
---|---|
AzureCognitiveSearchIndexLimitReached | |
AzureCognitiveSearchIndexNotFound | |
AzureCognitiveSearchNotFound | |
AzureCognitiveSearchThrottling | |
Forbidden | |
InternalServerError | |
InvalidArgument | |
InvalidRequest | |
NotFound | |
OperationNotFound | |
ProjectNotFound | |
ServiceUnavailable | |
TooManyRequests | |
Unauthorized |
ErrorResponse
エラー応答。
名前 | 型 | 説明 |
---|---|---|
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 |
サーバー定義の一連のエラー コードの 1 つ。 |
|
details |
object |
エラーの詳細。 |
innererror |
エラーに関する現在のオブジェクトよりも具体的な情報を含むオブジェクト。 |
|
message |
string |
エラーメッセージ。 |
target |
string |
エラーターゲット。 |
KnowledgeBaseAnswer
ナレッジ ベースの回答を表します。
名前 | 型 | 説明 |
---|---|---|
answer |
string |
回答テキスト。 |
answerSpan |
ユーザーの質問に関する QnA の回答スパン オブジェクト。 |
|
confidenceScore |
number (double) minimum: 0maximum: 1 |
信頼度スコアに回答します。値の範囲は 0 から 1 です。 |
dialog |
回答に関連付けられているダイアログ。 |
|
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
回答を求めるメッセージを表示します。
名前 | 型 | 説明 |
---|---|---|
displayOrder |
integer (int32) |
プロンプトのインデックス - プロンプトの順序付けで使用されます。 |
displayText |
string maxLength: 200 |
フォローアップの質問プロンプトを表すテキストが表示されます。 |
qnaId |
integer (int32) |
プロンプトに対応する QnA ID。 |
LogicalOperationKind
対応する論理操作を使用するには、'OR' または 'AND' に設定します。
値 | 説明 |
---|---|
AND | |
OR |
MetadataFilter
指定されたメタデータの一覧に関連付けられている QnA を検索します。
名前 | 型 | 規定値 | 説明 |
---|---|---|---|
logicalOperation | AND |
メタデータ フィルターを結合するために使用される操作。 |
|
metadata |
各メタデータのキー値ペアを提供するオブジェクト。 |
MetadataRecord
各メタデータのキー値ペアを提供するオブジェクト。
名前 | 型 | 説明 |
---|---|---|
key |
string |
QnA で使用されるメタデータ ディクショナリのメタデータ キー。 |
value |
string |
QnA で使用されるメタデータ ディクショナリのメタデータ値。 |
QueryFilters
ナレッジ ベースをフィルター処理します。
名前 | 型 | 規定値 | 説明 |
---|---|---|---|
logicalOperation | AND |
メタデータ フィルターをソース フィルターと結合するために使用される論理操作。 |
|
metadataFilter |
指定されたメタデータの一覧に関連付けられている QnA を検索します。 |
||
sourceFilter |
string[] |
ナレッジ ベース内の特定のソースの一覧に関連付けられている QnA を検索します。 |
RankerKind
使用するランカーの種類。
値 | 説明 |
---|---|
Default |
既定のランカー。 |
QuestionOnly |
質問のみランカー。 |
ShortAnswerOptions
回答スパン予測機能を構成するには。
名前 | 型 | 説明 |
---|---|---|
confidenceScoreThreshold |
number (double) minimum: 0maximum: 1 |
回答スパンを含めるために必要な最小しきい値スコア。値の範囲は 0 から 1 です。 |
enable |
回答スパン予測を有効または無効にします。 |
|
topAnswersWithSpan |
integer (int32) minimum: 1maximum: 10 |
スパン予測で考慮される上位の回答の数は、1 から 10 です。 |