AIにテキスト生成リクエストを送信

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

サポートされているLLMにAIリクエストを送信し、新しいテキストの作成に特化した回答を返します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

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が回答したプロンプト。

object array本文内必須

LLMで処理する項目 (多くの場合はファイル)。この配列に含めることができる要素は1つだけです。

: Box AIは、最大1 MBのテキストレプリゼンテーションを含むドキュメントを処理します。ファイルサイズが1 MBを超えた場合は、テキストレプリゼンテーションの最初の1 MBが処理されます。

string本文内省略可能
"123"

項目のID。

string本文内省略可能
"file"

項目のタイプ。

次の値に固定: file

string本文内省略可能
"This is file content that is relevant to the text gen request."

新規テキストを生成したり既存テキストを編集したりする場合にコンテキストとして使用するコンテンツ。

string本文内必須
"Write an email to a client about the importance of public APIs."

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

レスポンス

application/jsonAIの応答

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

予期しないクライアントエラー。

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

post
AIにテキスト生成リクエストを送信
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X POST "https://api.box.com/2.0/ai/text_gen" \
     -H "content-type: application/json" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -d '{
         "prompt": "Write an email to a client about the importance of public APIs.",
         "items": [
        {
            "id": "12345678",
            "type": "file",
            "content": "More information about public APIs"
        },
    ],
    "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"
        },
        {
            "prompt": "Can you add some more information?",
            "answer": "Public API schemas provide necessary information to integrate with APIs...",
            "created_at": "2013-12-12T11:20:43-08:00"
        }
    ],
  }'
Java
List<BoxAIDialogueEntry> dialogueHistory = new ArrayList<>();
dialogueHistory.add(
        new BoxAIDialogueEntry(
            "Make my email about public APIs sound more professional",
            "Here is the first draft of your professional email about public APIs.",
            BoxDateFormat.parse("2013-05-16T15:26:57-07:00")
        )
    );
BoxAIResponse response = BoxAI.sendAITextGenRequest(
    api,
    "Write an email to a client about the importance of public APIs.",
    Collections.singletonList(new BoxAIItem("123456", BoxAIItem.Type.FILE)),
    dialogueHistory
);
TypeScript Gen
await client.ai.createAiTextGen({
  prompt: 'Parapharse the document.s',
  items: [
    {
      id: fileToAsk.id,
      type: 'file' as AiTextGenItemsTypeField,
      content:
        'The Earth goes around the sun. Sun rises in the East in the morning.',
    } satisfies AiTextGenItemsField,
  ],
  dialogueHistory: [
    {
      prompt: 'What does the earth go around?',
      answer: 'The sun',
      createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
    } satisfies AiTextGenDialogueHistoryField,
    {
      prompt: 'On Earth, where does the sun rise?',
      answer: 'East',
      createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
    } satisfies AiTextGenDialogueHistoryField,
  ],
} satisfies AiTextGen);
Python Gen
client.ai.create_ai_text_gen(
    "Parapharse the document.s",
    [
        CreateAiTextGenItems(
            id=file_to_ask.id,
            type=CreateAiTextGenItemsTypeField.FILE.value,
            content="The Earth goes around the sun. Sun rises in the East in the morning.",
        )
    ],
    dialogue_history=[
        CreateAiTextGenDialogueHistory(
            prompt="What does the earth go around?",
            answer="The sun",
            created_at=date_time_from_string("2021-01-01T00:00:00Z"),
        ),
        CreateAiTextGenDialogueHistory(
            prompt="On Earth, where does the sun rise?",
            answer="East",
            created_at=date_time_from_string("2021-01-01T00:00:00Z"),
        ),
    ],
)
.NET (Beta)
await client.Ai.CreateAiTextGenAsync(requestBody: new AiTextGen(prompt: "Parapharse the document.s", items: Array.AsReadOnly(new [] {new AiTextGenItemsField() { Id = fileToAsk.Id, Type = AiTextGenItemsTypeField.File, Content = "The Earth goes around the sun. Sun rises in the East in the morning." }})) { DialogueHistory = Array.AsReadOnly(new [] {new AiTextGenDialogueHistoryField() { Prompt = "What does the earth go around?", Answer = "The sun", CreatedAt = Utils.DateTimeFromString(dateTime: "2021-01-01T00:00:00Z") },new AiTextGenDialogueHistoryField() { Prompt = "On Earth, where does the sun rise?", Answer = "East", CreatedAt = Utils.DateTimeFromString(dateTime: "2021-01-01T00:00:00Z") }}) });

レスポンスの例

{
  "answer": "Public APIs are important because of key and important reasons.",
  "completion_reason": "done",
  "created_at": "2012-12-12T10:53:43-08:00"
}