Method: answerQuery

グラウンディングされた生成を使用してクエリに回答します。

HTTP リクエスト

POST https://developerknowledge.googleapis.com/v1alpha:answerQuery

この URL は gRPC Transcoding 構文を使用します。

リクエストの本文

リクエストの本文には、次の構造のデータが含まれます。

JSON 表現
{
  "query": string,
  "filter": string
}
フィールド
query

string

必須。回答するクエリ。

filter

string

省略可。回答の根拠となる検索結果に厳格なフィルタを適用します。この式は、https://google.aip.dev/160 で説明されている構文のサブセットをサポートしています。

フィルタリングに対応するフィールド:

  • contentLengthBytes(INTEGER): Document.content フィールドの長さ(バイト単位)。
  • dataSource(STRING): ドキュメントのソース(例: docs.cloud.google.com)。コーパス内のデータソースの完全なリストについては、https://developers.google.com/knowledge/reference/corpus-reference をご覧ください。
  • updateTime(TIMESTAMP): ドキュメントが最後に更新されたときのタイムスタンプ。意味のある更新とは、ドキュメントのマークダウン コンテンツまたはメタデータを変更する更新のことです。
  • uri(STRING): ドキュメント URI(https://docs.cloud.google.com/bigquery/docs/tables など)。

INTEGER フィールドは、=<<=>>= 演算子をサポートしています。

STRING フィールドは、文字列全体の完全一致に対して =(等号)演算子と !=(不等号)演算子をサポートします。部分一致、接頭辞一致、正規表現一致はサポートされていません。

TIMESTAMP フィールドは、=<<=>>= 演算子をサポートしています。タイムスタンプは RFC-3339 形式(例: "2025-01-01T00:00:00Z")にする必要があります。

ANDORNOT(または -)の論理演算子を使用して式を組み合わせることができます。ORAND よりも優先度が高くなります。優先順位を明示的にグループ化するには、かっこを使用します。

例:

  • フィルタ条件(Document.content_length_bytes): contentLengthBytes < 50000
  • dataSource = "docs.cloud.google.com" OR dataSource = "firebase.google.com"
  • dataSource != "firebase.google.com"
  • updateTime < "2024-01-01T00:00:00Z"
  • updateTime >= "2025-01-22T00:00:00Z" AND (dataSource = "developer.chrome.com" OR dataSource = "web.dev")
  • uri = "https://docs.cloud.google.com/release-notes"

filter 文字列は 500 文字を超えてはなりません。500 文字を超える値は INVALID_ARGUMENT エラーになります。

レスポンスの本文

DeveloperKnowledge.AnswerQuery に対するレスポンス メッセージです。

成功した場合、レスポンスの本文には次の構造のデータが含まれます。

JSON 表現
{
  "answer": {
    object (Answer)
  }
}
フィールド
answer

object (Answer)

クエリに対する回答。

認可スコープ

次の OAuth スコープのいずれかが必要です。

  • https://www.googleapis.com/auth/devprofiles.full_control
  • https://www.googleapis.com/auth/developerprofiles.readonly
  • https://www.googleapis.com/auth/cloud-platform

詳細については、OAuth 2.0 Overview をご覧ください。

回答

クエリに対する回答。

JSON 表現
{
  "answerText": string,
  "citations": [
    {
      object (AnswerCitation)
    }
  ],
  "references": [
    {
      object (AnswerReference)
    }
  ]
}
フィールド
answerText

string

回答のテキストが含まれます。

citations[]

object (AnswerCitation)

出力専用。回答の引用が含まれます。

references[]

object (AnswerReference)

出力専用。回答の参照が含まれます。

AnswerCitation

セグメントの引用情報。

JSON 表現
{
  "startIndex": integer,
  "endIndex": integer,
  "sources": [
    {
      object (CitationSource)
    }
  ]
}
フィールド
startIndex

integer

出力専用。セグメントの開始位置をバイト単位(UTF-8 Unicode)で示します(両端を含む)。ASCII 以外の文字などのマルチバイト文字がある場合、インデックスの測定値は文字列の長さよりも長くなります。

endIndex

integer

出力専用。セグメントの終了位置をバイト単位(UTF-8 Unicode)で示します(終点を含まない)。ASCII 以外の文字などのマルチバイト文字がある場合、インデックスの測定値は文字列の長さよりも長くなります。

sources[]

object (CitationSource)

出力専用。アトリビューション セグメントの引用元が含まれます。

CitationSource

引用元。

JSON 表現
{
  "referenceIndex": integer
}
フィールド
referenceIndex

integer

出力専用。references 繰り返しフィールド内の Answer.AnswerReference のインデックスが含まれます。

AnswerReference

ソースへの参照を表します。

JSON 表現
{

  // Union field content can be only one of the following:
  "documentReference": {
    object (DocumentReference)
  }
  // End of list of possible types for union field content.
}
フィールド
共用体フィールド content。参照の内容が含まれます。content は次のいずれかになります。
documentReference

object (DocumentReference)

出力専用。リファレンス ドキュメント。

DocumentReference

ドキュメントへの参照を表します。

JSON 表現
{
  "documentChunk": {
    object (DocumentChunk)
  }
}
フィールド
documentChunk

object (DocumentChunk)

出力専用。ドキュメント チャンクが含まれます。documentChunk.id フィールドは設定されず、空になります。