Box Developerドキュメント
最新バージョン

質問を送信

post
https://api.box.com/2.0
/ai/ask

このエンドポイントはバージョン2024.0です。引き続き使用するために 変更は必要ありません。詳細については、 **Box APIのバージョン管理**を参照してください。

サポートされているLLMにAIリクエストを送信し、提供されたコンテキストを考慮してユーザーの質問に特化した回答を返します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

リクエストの処理に使用されるAIエージェント。

object array本文内省略可能

これまでにLLMに渡されたプロンプトおよび回答の履歴。これにより、レスポンスの生成時にLLMに追加のコンテキストが提供されます。

string本文内省略可能
"Here is the first draft of your professional email about public APIs."

以前にLLMから提供された回答。

string (date-time)本文内省略可能
"2012-12-12T10:53:43-08:00"

プロンプトに対する前回の回答が作成された時点のISO日付形式のタイムスタンプ。

string本文内省略可能
"Make my email about public APIs sound more professional."

以前にクライアントによって提供され、LLMが回答したプロンプト。

boolean本文内省略可能
true

引用情報を返すかどうかを示すフラグ。

object array本文内必須

LLMで処理する項目 (多くの場合はファイル)。

string本文内必須
"123"

ファイルのID。

string本文内必須
"file"

項目の種類。hubs項目は、単一の項目として使用する必要があります。

次の値のいずれか1つ: file,hubs

string本文内省略可能
"This is file content."

項目のコンテンツ (多くの場合はテキストレプリゼンテーション)。

string本文内必須
"multiple_item_qa"

Box AIは、最大1 MBのテキストレプリゼンテーションを含むテキストドキュメント、または最大25ファイルを処理します (いずれか先に到達した方)。ファイルサイズが1 MBを超える場合は、テキストレプリゼンテーションの最初の1 MBが処理されます。Box AIは、解像度が1024 x 1024ピクセルの画像ドキュメントを処理し、最大5つの画像か、複数ページの画像の場合は5ページを処理します。画像数または画像ページ数が5を超える場合は、最初の5つの画像または5ページが処理されます。modeパラメータをsingle_item_qaに設定した場合、items配列に含めることができる要素は1つのみです。現在、Box AIでは、複数モードのリクエストがサポートされていません。画像とテキストの両方が送信された場合、Box AIで処理されるのはテキストのみです。

次の値のいずれか1つ: multiple_item_qa,single_item_qa

string本文内必須
"What is the value provided by public APIs based on this document?"

LLMが回答するようにクライアントが提供するプロンプト。プロンプトの長さは10000文字に制限されています。

レスポンス

application/jsonAIの応答 (Full)

LLMからの回答を含む成功したレスポンス。

none

質問への回答に使用できるコンテンツがありません。これは、リクエストの項目がHubであっても、Hubのコンテンツにインデックスが作成されていない場合に返されます。Hub内のコンテンツにインデックスが作成されるようにするには、Hubを作成する前に、管理コンソールでBox AI for Hubsが有効になっていることを確認してください。

予期しないサーバーエラー。

予期しないエラー。

post
質問を送信
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -L POST "https://api.box.com/2.0/ai/ask" \
     -H "content-type: application/json" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -d '{
         "mode": "single_item_qa",
         "prompt": "What is the value provided by public APIs based on this document?",
         "items": [
            {
            "type": "file",
            "id": "9842787262"
            }
         ],
         "dialogue_history": [
              {
              "prompt": "Make my email about public APIs sound more professional",
              "answer": "Here is the first draft of your professional email about public APIs",
              "created_at": "2013-12-12T10:53:43-08:00"
              }
          ],
          "include_citations": true,
          "ai_agent": {
            "type": "ai_agent_ask",
            "long_text": {
              "model": "azure__openai__gpt_4o_mini",
              "prompt_template": "It is `{current_date}`, and I have $8000 and want to spend a week in the Azores. What should I see?",
            },
            "basic_text": {
              "model": "azure__openai__gpt_4o_mini",
           }
         }
      }'

レスポンスの例

{
  "ai_agent_info": {
    "models": [
      {
        "name": "azure__openai__text_embedding_ada_002",
        "provider": "azure",
        "supported_purpose": "embedding"
      }
    ],
    "processor": "basic_text"
  },
  "answer": "Public APIs are important because of key and important reasons.",
  "citations": [
    {
      "content": "Public APIs are key drivers of innovation and growth.",
      "id": "123",
      "name": "The importance of public APIs.pdf",
      "type": "file"
    }
  ],
  "completion_reason": "done",
  "created_at": "2012-12-12T10:53:43-08:00"
}