Sends an AI request to supported LLMs and returns an answer specifically focused on the user’s question given the provided context.
This operation is performed by calling function createAiAsk.
See the endpoint docs at API Reference.
await client.ai.createAiAsk({
mode: 'single_item_qa' as AiAskModeField,
prompt: 'Which direction does the Sun rise?',
items: [
{
id: fileToAsk.id,
type: 'file' as AiItemAskTypeField,
content: 'The Sun rises in the east',
} satisfies AiItemAsk,
],
aiAgent: aiAskAgentBasicTextConfig,
} satisfies AiAsk);
AiAsk
CreateAiAskOptionalsInputThis function returns a value of type undefined | AiResponseFull.
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.
Sends an AI request to supported Large Language Models (LLMs) and returns generated text based on the provided prompt.
This operation is performed by calling function createAiTextGen.
See the endpoint docs at API Reference.
await client.ai.createAiTextGen({
prompt: 'Paraphrase the documents',
items: [
new AiTextGenItemsField({
id: fileToAsk.id,
type: 'file' as AiTextGenItemsTypeField,
content:
'The Earth goes around the Sun. The Sun rises in the east in the morning.',
}),
],
dialogueHistory: [
{
prompt: 'What does the earth go around?',
answer: 'The Sun',
createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
} satisfies AiDialogueHistory,
{
prompt: 'On Earth, where does the Sun rise?',
answer: 'east',
createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
} satisfies AiDialogueHistory,
],
} satisfies AiTextGen);
AiTextGen
CreateAiTextGenOptionalsInputThis function returns a value of type AiResponse.
A successful response including the answer from the LLM.
Get the AI agent default config.
This operation is performed by calling function getAiAgentDefaultConfig.
See the endpoint docs at API Reference.
await client.ai.getAiAgentDefaultConfig({
mode: 'ask' as GetAiAgentDefaultConfigQueryParamsModeField,
language: 'en-US',
} satisfies GetAiAgentDefaultConfigQueryParams);
GetAiAgentDefaultConfigQueryParams
GetAiAgentDefaultConfigOptionalsInputThis function returns a value of type AiAgent.
A successful response including the default agent configuration. This response can be one of the following four objects:
Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs. In this request, both the prompt and the output can be freeform. Metadata template setup before sending the request is not required.
This operation is performed by calling function createAiExtract.
See the endpoint docs at API Reference.
await client.ai.createAiExtract({
prompt: 'firstName, lastName, location, yearOfBirth, company',
items: [new AiItemBase({ id: file.id })],
aiAgent: aiExtractAgentBasicTextConfig,
} satisfies AiExtract);
AiExtract
CreateAiExtractOptionalsInputThis function returns a value of type AiResponse.
A response including the answer from the LLM.
Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
To define the extraction structure, provide either a metadata template or a list of fields. To learn more about creating templates, see Creating metadata templates in the Admin Console or use the metadata template API.
This endpoint also supports Enhanced Extract Agent.
For information about supported file formats and languages, see the Extract metadata from file (structured) API guide.
This operation is performed by calling function createAiExtractStructured.
See the endpoint docs at API Reference.
await client.ai.createAiExtractStructured({
fields: [
{
key: 'firstName',
displayName: 'First name',
description: 'Person first name',
prompt: 'What is the your first name?',
type: 'string',
} satisfies AiExtractStructuredFieldsField,
{
key: 'lastName',
displayName: 'Last name',
description: 'Person last name',
prompt: 'What is the your last name?',
type: 'string',
} satisfies AiExtractStructuredFieldsField,
{
key: 'dateOfBirth',
displayName: 'Birth date',
description: 'Person date of birth',
prompt: 'What is the date of your birth?',
type: 'date',
} satisfies AiExtractStructuredFieldsField,
{
key: 'age',
displayName: 'Age',
description: 'Person age',
prompt: 'How old are you?',
type: 'float',
} satisfies AiExtractStructuredFieldsField,
{
key: 'hobby',
displayName: 'Hobby',
description: 'Person hobby',
prompt: 'What is your hobby?',
type: 'multiSelect',
options: [
{ key: 'guitar' } satisfies AiExtractStructuredFieldsOptionsField,
{ key: 'books' } satisfies AiExtractStructuredFieldsOptionsField,
],
} satisfies AiExtractStructuredFieldsField,
],
items: [new AiItemBase({ id: file.id })],
aiAgent: aiExtractStructuredAgentBasicTextConfig,
} satisfies AiExtractStructured);
AiExtractStructured
CreateAiExtractStructuredOptionalsInputThis function returns a value of type AiExtractStructuredResponse.
A successful response including the answer from the LLM.