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¶

JournalismState

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.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

class Config¶

Pydantic configuration.

use_enum_values = True¶
validate_assignment = True¶
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

property actions_completed: List[str]¶

List of completed actions.

property actions_pending: List[str]¶

List of pending actions.

article_author: str | None = None¶
article_text: str = None¶
article_title: str | None = None¶
article_url: str | None = None¶
chunks: List[haive.prebuilt.journalism_.models.ArticleChunk] = None¶
current_action: str | None = None¶
fact_check_result: haive.prebuilt.journalism_.models.FactCheckResult | None = None¶
final_report: haive.prebuilt.journalism_.models.ComprehensiveReport | None = None¶
grammar_bias_result: haive.prebuilt.journalism_.models.GrammarBiasReview | None = None¶
property has_errors: bool¶

Whether any errors occurred during processing.

property is_complete: bool¶

Whether all requested actions are complete.

property overall_credibility: float | None¶

Overall credibility score from fact-checking.

processing_errors: List[Dict[str, Any]] = None¶
property processing_progress: float¶

Processing progress as a percentage.

publication_date: datetime.datetime | None = None¶
quote_extraction_result: haive.prebuilt.journalism_.models.QuoteExtractionResult | None = None¶
requested_actions: List[str] = None¶
search_results: List[haive.prebuilt.journalism_.models.SearchResult] = None¶
summary_result: haive.prebuilt.journalism_.models.ArticleSummary | None = None¶
tone_analysis_result: haive.prebuilt.journalism_.models.ToneAnalysis | None = None¶
property total_chunks: int¶

Total number of text chunks created.