Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context.
The AI agent to be used to handle the request.
The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response.
"Here is the first draft of your professional email about public APIs."
The answer previously provided by the LLM.
"2012-12-12T10:53:43-08:00"
The ISO date formatted timestamp of when the previous answer to the prompt was created.
"Make my email about public APIs sound more professional."
The prompt previously provided by the client and answered by the LLM.
true
A flag to indicate whether citations should be returned.
The items to be processed by the LLM, often files.
"123"
The ID of the file.
"file"
The type of the item. A hubs
item must be used as a single item.
Value is one of file
,hubs
"This is file content."
The content of the item, often the text representation.
"multiple_item_qa"
Box AI handles text documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first. If the text file size exceeds 1MB, the first 1MB of text representation will be processed. Box AI handles image documents with a resolution of 1024 x 1024 pixels, with a maximum of 5 images or 5 pages for multi-page images. If the number of image or image pages exceeds 5, the first 5 images or pages will be processed. If you set mode parameter to single_item_qa
, the items array can have one element only. Currently Box AI does not support multi-modal requests. If both images and text are sent Box AI will only process the text.
Value is one of multiple_item_qa
,single_item_qa
"What is the value provided by public APIs based on this document?"
The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters.
A successful response including the answer from the LLM.
No content is available to answer the question. This is returned when the request item is a hub, but content in the hubs is not indexed. To ensure content in the hub is indexed, make sure Box AI for Hubs in the Admin Console was enabled before hub creation.
An unexpected server error.
An unexpected error.
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",
}
}
}'
await client.ai.createAiAsk({
mode: 'single_item_qa' as AiAskModeField,
prompt: 'which direction sun rises',
items: [
{
id: fileToAsk.id,
type: 'file' as AiItemAskTypeField,
content: 'Sun rises in the East',
} satisfies AiItemAsk,
],
} satisfies AiAsk);
client.ai.create_ai_ask(
CreateAiAskMode.SINGLE_ITEM_QA,
"which direction sun rises",
[
AiItemAsk(
id=file_to_ask.id,
type=AiItemAskTypeField.FILE,
content="Sun rises in the East",
)
],
ai_agent=ai_ask_agent_config,
)
await client.Ai.CreateAiAskAsync(requestBody: new AiAsk(mode: AiAskModeField.SingleItemQa, prompt: "which direction sun rises", items: Array.AsReadOnly(new [] {new AiItemAsk(id: fileToAsk.Id, type: AiItemAskTypeField.File) { Content = "Sun rises in the East" }})));
try await client.ai.createAiAsk(requestBody: AiAsk(mode: AiAskModeField.singleItemQa, prompt: "which direction sun rises", items: [AiItemAsk(id: fileToAsk.id, type: AiItemAskTypeField.file, content: "Sun rises in the East")]))
client.getAi().createAiAsk(new AiAsk(AiAskModeField.SINGLE_ITEM_QA, "which direction sun rises", Arrays.asList(new AiItemAsk.AiItemAskBuilder(fileToAsk.getId(), AiItemAskTypeField.FILE).content("Sun rises in the East").build())))
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"
} */
});