Skip to content

Commit 4663284

Browse files
authored
Add guide for Enhanced Extract Agent (#809)
* Add guide for Enhanced Extract Agent * Correct lint issues * Correct formatting
1 parent 2a839d7 commit 4663284

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

content/guides/box-ai/ai-tutorials/extract-metadata-structured.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,69 @@ The response lists the fields included in the metadata template and their values
175175
}
176176
```
177177
178+
### Enhanced Extract Agent
179+
180+
To start using the agent, you need:
181+
182+
- A Box Platform App with enabled `Manage AI` scope.
183+
- The app installed and enabled in your Box instance.
184+
- A file to test with.
185+
186+
Calling an Enhanced Extract Agent works like calling the AI API - set the `type` to `AI Agent ID`, then string to the Enhanced Extract AI agent.
187+
188+
To extract data using the Enhanced Extract Agent you need:
189+
190+
- Inline field definitions created with `agentCreateAiExtractStructuredMetadataTemplate` if your fields change frequently,
191+
- or a metadata template that contains the data about the fields you wish to extract, if your extracted fields stay the same.
192+
193+
See the full sample Python script that demonstrates how to call the Enhanced Extract Agent on a file using the Box AI SDK:
194+
195+
```Python
196+
from box_sdk_gen import (
197+
AiAgentReference,
198+
AiAgentReferenceTypeField,
199+
AiItemBase,
200+
AiItemBaseTypeField,
201+
BoxClient,
202+
BoxCCGAuth,
203+
CCGConfig,
204+
CreateAiExtractStructuredMetadataTemplate
205+
)
206+
207+
# Create your client credentials grant config from the developer console
208+
ccg_config = CCGConfig(
209+
client_id="my_box_client_id", # replace with your client id
210+
client_secret="my_box_client_secret", # replace with your client secret
211+
user_id="my_box_user_id", # replace with the box user id that has access
212+
# to the file you are referencing
213+
)
214+
auth = BoxCCGAuth(config=ccg_config)
215+
client = BoxClient(auth=auth)
216+
# Create the agent config referencing the enhanced extract agent
217+
enhanced_extract_agent_config = AiAgentReference(
218+
id="enhanced_extract_agent",
219+
type=AiAgentReferenceTypeField.AI_AGENT_ID
220+
)
221+
# Use the Box SDK to call the extract_structured endpoint
222+
box_ai_response = client.ai.create_ai_extract_structured(
223+
# Create the items array containing the file information to extract from
224+
items=[
225+
AiItemBase(
226+
id="my_box_file_id", # replace with the file id
227+
type=AiItemBaseTypeField.FILE
228+
)
229+
],
230+
# Reference the Box Metadata template
231+
metadata_template=CreateAiExtractStructuredMetadataTemplate(
232+
template_key="InvoicePO",
233+
scope="enterprise"
234+
),
235+
# Attach the agent config you created earlier
236+
ai_agent=enhanced_extract_agent_config,
237+
)
238+
print(f"box_ai_response: {box_ai_response.answer}")
239+
```
240+
178241
[prereq]: g://box-ai/ai-tutorials/prerequisites
179242
[agent]: e://get_ai_agent_default
180243
[model-param]: r://ai_agent_text_gen#param_basic_gen_model

content/guides/box-ai/index.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,19 @@ For details, see [Box AI for Notes][boxainotes].
7474

7575
The [`POST /2.0/ai/extract`][extract] and [`POST /2.0/ai/extract_structured`][extract-structured] endpoints allow you to extract data from the provided input and return them in a form of key-value pairs.
7676

77-
* Use the `extract_structured` endpoint to extract data according to a pre-defined structure obtained from the metadata template, or a set of fields.
77+
* Use the `extract_structured` endpoint to extract data according to a pre-defined structure obtained from the metadata template, or a set of fields. Use it for shorter documents
78+
* Use the Enhanced Extract Agent for long, complex documents
7879
* Use the `extract` endpoint to extract data from a file using a prompt that can include a stringified version of formats such as JSON or XML, or even plain text.
7980

81+
#### Enhanced Extract Agent
82+
83+
The Enhanced Extract Agent is designed to extract key-value pairs from complex documents. It converts the unstructured content into metadata for easier discovery and search.
84+
85+
You can [use the agent][eea-tutorial] through the Box AI API and turn unstructured data into structured output to use in production databases, third party systems, or analytics.
86+
87+
The Enhanced Extract Agent uses Gemini 2.5 Pro to provide a chain-of-thought reasoning and returns both the extracted values and a reasoning behind
88+
its answer.
89+
8090
### Configuration overrides
8191

8292
You can use the `ai_agent` parameter available in the Box AI API requests to override the default agent configuration and introduce your own custom settings.
@@ -125,4 +135,5 @@ better results for this language.
125135
[uar]: https://support.box.com/hc/en-us/articles/4415012490387-User-Activity-Report
126136
[agent-default]: g://box-ai/ai-agents/get-agent-default-config
127137
[extract]: e://post_ai_extract
128-
[extract-structured]: e://post_ai_extract_structured
138+
[extract-structured]: e://post_ai_extract_structured
139+
[eea-tutorial]: g://box-ai/ai-tutorials/extract-metadata-structured#

0 commit comments

Comments
 (0)