class MultiPageAnalysisResult
A dataclass that encapsulates the complete results of analyzing a multi-page document, including individual page analyses, document summary, combined response, and processing statistics.
/tf/active/vicechatdev/e-ink-llm/multi_page_llm_handler.py
18 - 23
simple
Purpose
This dataclass serves as a structured container for the output of multi-page document analysis operations. It aggregates page-level analysis results, provides a high-level document summary, combines responses into a unified format, and tracks processing metrics. It's designed to be used as the return type for multi-page document processing workflows, making it easy to access different aspects of the analysis results in a type-safe manner.
Source Code
class MultiPageAnalysisResult:
"""Result of multi-page document analysis"""
page_analyses: List[str]
document_summary: DocumentSummary
combined_response: str
processing_stats: Dict[str, Any]
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
page_analyses: A list of strings where each string contains the analysis result for an individual page of the document. The order corresponds to the page order in the original document.
document_summary: A DocumentSummary object that provides a high-level overview and summary of the entire document across all pages.
combined_response: A single string that represents the aggregated or synthesized response combining insights from all page analyses into a cohesive narrative.
processing_stats: A dictionary containing metadata and statistics about the processing operation, such as timing information, token counts, page counts, or other relevant metrics. Keys are string identifiers and values can be of any type.
Return Value
When instantiated, returns a MultiPageAnalysisResult object containing all the analysis results. This is a dataclass, so it automatically provides __init__, __repr__, __eq__, and other standard methods. The object provides direct attribute access to all four fields.
Class Interface
Methods
__init__(page_analyses: List[str], document_summary: DocumentSummary, combined_response: str, processing_stats: Dict[str, Any]) -> None
Purpose: Initializes a new MultiPageAnalysisResult instance with the provided analysis data. Automatically generated by the dataclass decorator.
Parameters:
page_analyses: List of strings containing individual page analysis resultsdocument_summary: DocumentSummary object with high-level document informationcombined_response: Unified string response synthesizing all page analysesprocessing_stats: Dictionary of processing metadata and statistics
Returns: None - initializes the instance
__repr__() -> str
Purpose: Returns a string representation of the MultiPageAnalysisResult instance. Automatically generated by the dataclass decorator.
Returns: String representation showing all field names and values
__eq__(other: object) -> bool
Purpose: Compares two MultiPageAnalysisResult instances for equality based on all fields. Automatically generated by the dataclass decorator.
Parameters:
other: Another object to compare with
Returns: True if all fields are equal, False otherwise
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
page_analyses |
List[str] | List of analysis results for each page in the document, ordered by page number | instance |
document_summary |
DocumentSummary | High-level summary object containing aggregated information about the entire document | instance |
combined_response |
str | Synthesized response that combines insights from all page analyses into a cohesive narrative | instance |
processing_stats |
Dict[str, Any] | Dictionary containing processing metadata such as timing, token counts, and other relevant statistics | instance |
Dependencies
dataclassestyping
Required Imports
from dataclasses import dataclass
from typing import List, Dict, Any
from multi_page_processor import DocumentSummary
Usage Example
from dataclasses import dataclass
from typing import List, Dict, Any
from multi_page_processor import DocumentSummary, MultiPageAnalysisResult
# Create a document summary
summary = DocumentSummary(
total_pages=3,
main_topics=['AI', 'Machine Learning'],
key_findings='Document discusses AI applications'
)
# Create analysis result
result = MultiPageAnalysisResult(
page_analyses=[
'Page 1: Introduction to AI concepts',
'Page 2: Machine learning algorithms',
'Page 3: Practical applications'
],
document_summary=summary,
combined_response='This document provides a comprehensive overview of AI and ML with practical examples.',
processing_stats={
'total_tokens': 1500,
'processing_time_seconds': 12.5,
'pages_processed': 3,
'model_used': 'gpt-4'
}
)
# Access results
print(result.page_analyses[0])
print(result.document_summary.total_pages)
print(result.combined_response)
print(result.processing_stats['total_tokens'])
Best Practices
- This is an immutable dataclass by default - consider using frozen=True in the decorator if immutability is desired
- Always ensure page_analyses list order matches the actual page order in the document
- Use consistent keys in processing_stats dictionary across different analysis runs for easier comparison
- The combined_response should synthesize information from all pages, not just concatenate page_analyses
- Validate that the length of page_analyses matches the total_pages in document_summary if that field exists
- Consider adding validation in __post_init__ if you need to enforce constraints on the data
- This class is designed to be instantiated once per document analysis and should not be modified after creation
- Use type hints when working with this class to leverage IDE autocomplete and type checking
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class PageAnalysis 81.5% similar
-
class DocumentSummary 75.7% similar
-
class AnalysisResult 72.1% similar
-
class AnalysisResult_v1 71.6% similar
-
class AnnotationResult 71.6% similar