サポートされているLLMにAIリクエストを送信し、提供されたコンテキストを考慮してユーザーの質問に特化した回答を返します。
クエリの処理に使用されるAIエージェント。
これまでにLLMに渡されたプロンプトおよび回答の履歴。これにより、レスポンスの生成時にLLMに追加のコンテキストが提供されます。
"Here is the first draft of your professional email about public APIs."
以前にLLMから提供された回答。
"2012-12-12T10:53:43-08:00"
プロンプトに対する前回の回答が作成された時点のISO日付形式のタイムスタンプ。
"Make my email about public APIs sound more professional."
以前にクライアントによって提供され、LLMが回答したプロンプト。
true
引用情報を返すかどうかを示すフラグ。
LLMで処理する項目 (多くの場合はファイル)。
注: Box AIは、最大1 MBのテキストレプリゼンテーションを含むドキュメント、または最大25ファイルを処理します (いずれか早い方)。ファイルサイズが1 MBを超えた場合は、テキストレプリゼンテーションの最初の1 MBが処理されます。mode
パラメータをsingle_item_qa
に設定した場合、items
配列には要素を1つしか含めることができません。
"123"
項目のID。
"file"
項目のタイプ。
次の値に固定: file
"This is file content."
項目のコンテンツ (多くの場合はテキストレプリゼンテーション)。
"multiple_item_qa"
このモードでは、このリクエストの対象となる項目を1つにするか複数にするかを指定します。single_item_qa
を選択すると、items
配列には要素を1つしか含めることができません。multiple_item_qa
を選択すると、最大25項目を指定できます。
次の値のいずれか1つ: multiple_item_qa
,single_item_qa
"What is the value provided by public APIs based on this document?"
LLMが回答するようにクライアントが提供するプロンプト。プロンプトの長さは10000文字に制限されています。
LLMからの回答を含む成功したレスポンス。
予期しないクライアントエラー。
予期しないサーバーエラー。
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_3_5_turbo_16k",
"system_message": "You are a helpful travel assistant specialized in budget travel",
"prompt_template": "It is `{current_date}`, and I have $8000 and want to spend a week in the Azores. What should I see?",
"num_tokens_for_completion": 8400,
"llm_endpoint_params": {
"type": "openai_params",
"temperature": 0.0,
"top_p": 1.0,
"frequency_penalty": 1.5,
"presence_penalty": 1.5,
"stop": "<|im_end|>"
},
"embeddings": {
"model": "openai__text_embedding_ada_002",
"strategy": {
"id": "basic",
"num_tokens_per_chunk": 8400
}
}
},
"basic_text": {
"model": ""azure__openai__gpt_3_5_turbo_16k"",
"system_message": "You are a helpful travel assistant specialized in budget travel",
"prompt_template": "It is `{current_date}`, and I have $8000 and want to spend a week in the Azores. What should I see?",
"num_tokens_for_completion": 8400,
"llm_endpoint_params": {
"type": "openai_params",
"temperature": 0.0,
"top_p": 1.0,
"frequency_penalty": 1.5,
"presence_penalty": 1.5,
"stop": "<|im_end|>"
}
},
"long_text_multi": {
"model": "azure__openai__gpt_3_5_turbo_16k",
"system_message": "You are a helpful travel assistant specialized in budget travel",
"prompt_template": "It is `{current_date}`, and I have $8000 and want to spend a week in the Azores. What should I see?",
"num_tokens_for_completion": 8400,
"llm_endpoint_params": {
"type": "openai_params",
"temperature": 0.0,
"top_p": 1.0,
"frequency_penalty": 1.5,
"presence_penalty": 1.5,
"stop": "<|im_end|>"
},
"embeddings": {
"model": "openai__text_embedding_ada_002",
"strategy": {
"id": "basic",
"num_tokens_per_chunk": 8400
}
}
},
"basic_text_multi": {
"model": ""azure__openai__gpt_3_5_turbo_16k"",
"system_message": "You are a helpful travel assistant specialized in budget travel",
"prompt_template": "It is `{current_date}`, and I have $8000 and want to spend a week in the Azores. What should I see?",
"num_tokens_for_completion": 8400,
"llm_endpoint_params": {
"type": "openai_params",
"temperature": 0.0,
"top_p": 1.0,
"frequency_penalty": 1.5,
"presence_penalty": 1.5,
"stop": "<|im_end|>"
}
}
}'
await client.ai.createAiAsk({
mode: 'multiple_item_qa' as AiAskModeField,
prompt: 'Which direction sun rises?',
items: [
new AiAskItemsField({
id: fileToAsk1.id,
type: 'file' as AiAskItemsTypeField,
content: 'Earth goes around the sun',
}),
new AiAskItemsField({
id: fileToAsk2.id,
type: 'file' as AiAskItemsTypeField,
content: 'Sun rises in the East in the morning',
}),
],
} satisfies AiAsk);
client.ai.create_ai_ask(
CreateAiAskMode.MULTIPLE_ITEM_QA.value,
"Which direction sun rises?",
[
CreateAiAskItems(
id=file_to_ask_1.id,
type=CreateAiAskItemsTypeField.FILE.value,
content="Earth goes around the sun",
),
CreateAiAskItems(
id=file_to_ask_2.id,
type=CreateAiAskItemsTypeField.FILE.value,
content="Sun rises in the East in the morning",
),
],
)
await client.Ai.CreateAiAskAsync(requestBody: new AiAsk(mode: AiAskModeField.MultipleItemQa, prompt: "Which direction sun rises?", items: Array.AsReadOnly(new [] {new AiAskItemsField(id: fileToAsk1.Id, type: AiAskItemsTypeField.File) { Content = "Earth goes around the sun" },new AiAskItemsField(id: fileToAsk2.Id, type: AiAskItemsTypeField.File) { Content = "Sun rises in the East in the morning" }})));
BoxAIResponse response = BoxAI.sendAIRequest(
api,
"What is the content of the file?",
Collections.singletonList("123456", BoxAIItem.Type.FILE),
BoxAI.Mode.SINGLE_ITEM_QA
);
items = [{
"id": "1582915952443",
"type": "file",
"content": "More information about public APIs"
}]
ai_agent = {
'type': 'ai_agent_ask',
'basic_text_multi': {
'model': 'openai__gpt_3_5_turbo'
}
}
answer = client.send_ai_question(
items=items,
prompt="What is this file?",
mode="single_item_qa",
ai_agent=ai_agent
)
print(answer)
BoxAIResponse response = await client.BoxAIManager.SendAIQuestionAsync(
new BoxAIAskRequest
{
Prompt = "What is the name of the file?",
Items = new List<BoxAIAskItem>() { new BoxAIAskItem() { Id = "12345" } },
Mode = AiAskMode.single_item_qa
};
);
client.ai.ask(
{
prompt: 'What is the capital of France?',
items: [
{
type: 'file',
id: '12345'
}
],
mode: 'single_item_qa'
})
.then(response => {
/* response -> {
"answer": "Paris",
"created_at": "2021-10-01T00:00:00Z",
"completion_reason": "done"
} */
});
{
"answer": "Public APIs are important because of key and important reasons.",
"citations": [
{
"content": "Public APIs are key drivers of innovation and growth.",
"id": "123",
"type": "file",
"name": "The importance of public APIs.pdf"
}
],
"completion_reason": "done",
"created_at": "2012-12-12T10:53:43-08:00"
}