prebuilt.journalism_.state¶
State schema for the Journalism AI Assistant.
This module defines the state schema that manages the workflow data for journalism analysis tasks including fact-checking, summarization, tone analysis, quote extraction, and grammar/bias review.
The state extends MessagesState to maintain conversation history while tracking all analysis operations and results.
Example
>>> from journalism_assistant.state import JournalismState
>>> state = JournalismState(
... article_text="Article content here...",
... requested_actions=["summarization", "fact-checking"]
... )
Note
Computed properties use safe access patterns to avoid initialization errors with Pydantic v2.
Classes¶
State schema for journalism analysis workflow. |
Module Contents¶
- class prebuilt.journalism_.state.JournalismState(messages: list[dict[str, Any]] | None = None, **data)¶
Bases:
haive.core.schema.prebuilt.messages.messages_state.MessagesStateState schema for journalism analysis workflow.
Manages all data throughout the journalism assistant workflow, tracking article processing, analysis results, and user interactions.
- article_text¶
Full text of the article to analyze
- article_title¶
Title of the article (if available)
- article_url¶
Source URL of the article (if available)
- article_author¶
Author of the article (if available)
- publication_date¶
When the article was published
- requested_actions¶
Actions requested by the user
- current_action¶
Action currently being processed
- chunks¶
Article text split into manageable chunks
- summary_result¶
Result of summarization
- fact_check_result¶
Result of fact-checking
- tone_analysis_result¶
Result of tone analysis
- quote_extraction_result¶
Result of quote extraction
- grammar_bias_result¶
Result of grammar/bias review
- search_results¶
Web search results for fact-checking
- processing_errors¶
Any errors encountered during processing
- final_report¶
Comprehensive report combining all analyses
- Computed Properties:
total_chunks: Number of text chunks created actions_completed: List of completed actions actions_pending: List of pending actions has_errors: Whether any errors occurred is_complete: Whether all requested actions are complete overall_credibility: Overall credibility score processing_progress: Progress percentage
- add_chunk(chunk: haive.prebuilt.journalism_.models.ArticleChunk) None¶
Add a text chunk to the state.
- Parameters:
chunk – ArticleChunk to add
- add_error(action: str, error: str, details: Dict | None = None) None¶
Record an error that occurred during processing.
- Parameters:
action – Action being performed when error occurred
error – Error message
details – Additional error details
- add_search_result(result: haive.prebuilt.journalism_.models.SearchResult) None¶
Add a search result for fact-checking.
- Parameters:
result – SearchResult to add
- complete_action(action: str) None¶
Mark an action as completed.
- Parameters:
action – Name of the completed action
- create_chunks(chunk_size: int = 100000, overlap: int = 1000) List[haive.prebuilt.journalism_.models.ArticleChunk]¶
Create chunks from the article text.
- Parameters:
chunk_size – Maximum size of each chunk
overlap – Number of characters to overlap between chunks
- Returns:
List of ArticleChunk objects
- generate_final_report() haive.prebuilt.journalism_.models.ComprehensiveReport¶
Generate a comprehensive report from all analysis results.
- Returns:
ComprehensiveReport combining all analyses
- get_chunk_texts() List[str]¶
Get just the text content of all chunks.
- Returns:
List of chunk text strings
- get_processing_summary() Dict[str, Any]¶
Get a summary of the processing status.
- Returns:
Dictionary with processing statistics
- set_current_action(action: str) None¶
Set the current action being processed.
- Parameters:
action – Name of the action
- chunks: List[haive.prebuilt.journalism_.models.ArticleChunk] = None¶
- publication_date: datetime.datetime | None = None¶
- search_results: List[haive.prebuilt.journalism_.models.SearchResult] = None¶