box_ai_extract_structured_enhanced_using_fields_tool
Extract structured data from Box files using AI by specifying desired fields, enabling enhanced processing for precise and customizable data outputs.
Instructions
Extract structured data from files in Box using AI with specified fields and enhanced processing. This tool allows users to extract structured data from files by specifying the fields they are interested in, with enhanced processing capabilities. Args: ctx (Context): The context object containing the request and lifespan context. file_ids (List[str]): The IDs of the files to read. fields (List[dict[str, Any]]): The fields to extract from the files. ai_agent_id (Optional[str]): The ID of the AI agent to use for processing. Returns: dict: The extracted structured data in a json string format.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | Yes | ||
| file_ids | Yes |
Implementation Reference
- src/tools/box_tools_ai.py:252-296 (handler)The primary handler function for the box_ai_extract_structured_enhanced_using_fields_tool. It gets the Box client from context and calls the core extraction function from box_ai_agents_toolkit.async def box_ai_extract_structured_enhanced_using_fields_tool( ctx: Context, file_ids: List[str], fields: List[dict[str, Any]], ) -> dict: """ Extract structured data from one or more files using custom fields and return a SINGLE data instance (Enhanced version). This enhanced tool analyzes the provided file(s) and extracts information based on custom field definitions you provide. When multiple files are provided, Box AI combines information from ALL files to create ONE complete data record. Enhanced features: - Uses advanced AI models (e.g., Google Gemini) for improved accuracy - Better handling of complex document layouts and image quality - More robust extraction for handwritten or low-quality scans - Improved understanding of complex field relationships Unlike template-based extraction, this tool allows you to define fields on-the-fly without creating a metadata template in Box first. This is useful for ad-hoc data extraction or when you need fields that don't match any existing template. Use cases: - Single file: Extract custom fields from one document - Multiple files: Combine data from multiple sources into one data instance (e.g., extract patient info from medical records, lab results, and prescription images) NOT for batch processing: If you need to extract data from multiple files as separate instances, call this tool once per file in a loop. Args: ctx (Context): The context object containing the request and lifespan context. file_ids (List[str]): A list of file IDs to extract information from, example: ["1234567890", "0987654321"]. fields (List[dict[str, Any]]): The fields to extract from the files. Returns: dict: The AI response containing the extracted information. """ box_client = get_box_client(ctx) response = box_ai_extract_structured_enhanced_using_fields( box_client, file_ids, fields, ) return response
- src/tool_registry/ai_tools.py:25-25 (registration)Registration of the tool using the MCP decorator in the ai_tools registry module.mcp.tool()(box_ai_extract_structured_enhanced_using_fields_tool)
- src/tool_registry/ai_tools.py:11-11 (registration)Import of the tool handler from src/tools/box_tools_ai.py for registration.box_ai_extract_structured_enhanced_using_fields_tool,