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=None, **data)¶
Bases:
haive.core.schema.prebuilt.messages.messages_state.MessagesState
State 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
Initialize with optional messages parameter for compatibility.
- class Config¶
Pydantic configuration.
- add_chunk(chunk)¶
Add a text chunk to the state.
- Parameters:
chunk (haive.prebuilt.journalism_.models.ArticleChunk) – ArticleChunk to add
- Return type:
None
- add_error(action, error, details=None)¶
Record an error that occurred during processing.
- add_search_result(result)¶
Add a search result for fact-checking.
- Parameters:
result (haive.prebuilt.journalism_.models.SearchResult) – SearchResult to add
- Return type:
None
- complete_action(action)¶
Mark an action as completed.
- Parameters:
action (str) – Name of the completed action
- Return type:
None
- create_chunks(chunk_size=100000, overlap=1000)¶
Create chunks from the article text.
- generate_final_report()¶
Generate a comprehensive report from all analysis results.
- Returns:
ComprehensiveReport combining all analyses
- Return type:
haive.prebuilt.journalism_.models.ComprehensiveReport
- get_chunk_texts()¶
Get just the text content of all chunks.
- Returns:
List of chunk text strings
- Return type:
List[str]
- get_processing_summary()¶
Get a summary of the processing status.
- Returns:
Dictionary with processing statistics
- Return type:
Dict[str, Any]
- set_current_action(action)¶
Set the current action being processed.
- Parameters:
action (str) – Name of the action
- Return type:
None