""" Streaming Configuration for Research Paper Generator with Yield Support and AStream This file contains all the streaming settings that can be modified at runtime. Adjust these values to control the streaming behavior, yield processing, and AStream functionality. """ # ============================================================================= # STREAMING SPEED CONFIGURATION # ============================================================================= # Delay between tokens (in seconds) # - 0.0 = Instant (no delay) # - 0.01 = Fast (10ms delay) # - 0.05 = Medium (50ms delay) - default # - 0.1 = Slow (100ms delay) # - 0.2 = Very Slow (200ms delay) STREAM_DELAY = 0.05 # ============================================================================= # YIELD GENERATOR CONFIGURATION # ============================================================================= # Chunk sizes for different processing steps YIELD_CHUNK_SIZES = { "topic_analyzer": 50, # Small chunks for topic analysis "research_retriever": 100, # Medium chunks for research notes "outline_builder": 75, # Medium chunks for outline "outline_revision": 75, # Medium chunks for outline revision "draft_writer": 150, # Larger chunks for draft writing "bibliography_generator": 100 # Medium chunks for bibliography } # Token chunk size for LLM streaming TOKEN_CHUNK_SIZE = 50 # Progress update frequency (number of chunks between progress updates) PROGRESS_UPDATE_FREQUENCY = 5 # Enable yield-based processing ENABLE_YIELD_PROCESSING = True # ============================================================================= # ASTREAM CONFIGURATION # ============================================================================= # Enable AStream processing ENABLE_ASTREAM_PROCESSING = True # AStream chunk sizes for different processing steps ASTREAM_CHUNK_SIZES = { "topic_analyzer": 25, # Smaller chunks for faster AStream "research_retriever": 50, # Medium chunks for research notes "outline_builder": 40, # Medium chunks for outline "outline_revision": 40, # Medium chunks for outline revision "draft_writer": 75, # Larger chunks for draft writing "bibliography_generator": 50 # Medium chunks for bibliography } # AStream processing delay (seconds) ASTREAM_DELAY = 0.01 # AStream buffer size for token accumulation ASTREAM_BUFFER_SIZE = 100 # Enable AStream real-time processing ASTREAM_REALTIME = True # AStream event frequency (show events every N tokens) ASTREAM_EVENT_FREQUENCY = 10 # ============================================================================= # STEP-SPECIFIC STREAMING CONFIGURATION # ============================================================================= # Enable/disable streaming for different workflow steps STREAMING_CONFIG = { "enabled": True, # Set to False to disable all streaming # Individual step controls "show_topic_analysis": False, # Usually too short to stream "show_research_retrieval": False, # Usually too short to stream "show_outline_building": True, # Show outline generation "show_outline_revision": True, # Show outline revision "show_draft_writing": True, # Show draft generation "show_bibliography": False, # Usually too short to stream # Advanced settings "show_progress_bars": True, # Show progress indicators "show_word_counts": True, # Show word counts for completed steps "show_previews": True, # Show result previews "show_chunks": True, # Show chunk processing "show_yield_events": True, # Show yield generator events "show_astream": True, # NEW: Show AStream events "show_astream_tokens": False, # NEW: Show individual AStream tokens "show_astream_chunks": True, # NEW: Show AStream chunks } # ============================================================================= # PRESET CONFIGURATIONS # ============================================================================= # Fast streaming preset (minimal delays) FAST_STREAMING = { "stream_delay": 0.01, "show_topic_analysis": False, "show_research_retrieval": False, "show_outline_building": True, "show_outline_revision": True, "show_draft_writing": True, "show_bibliography": False, "show_chunks": True, "show_yield_events": True, "show_astream": True, "show_astream_tokens": False, "show_astream_chunks": True, } # Slow streaming preset (for demonstration) SLOW_STREAMING = { "stream_delay": 0.1, "show_topic_analysis": True, "show_research_retrieval": True, "show_outline_building": True, "show_outline_revision": True, "show_draft_writing": True, "show_bibliography": True, "show_chunks": True, "show_yield_events": True, "show_astream": True, "show_astream_tokens": True, "show_astream_chunks": True, } # No streaming preset (for batch processing) NO_STREAMING = { "enabled": False, "stream_delay": 0.0, "show_chunks": False, "show_yield_events": False, "show_astream": False, "show_astream_tokens": False, "show_astream_chunks": False, } # Yield-focused preset (emphasizes chunk processing) YIELD_STREAMING = { "stream_delay": 0.02, "show_topic_analysis": True, "show_research_retrieval": True, "show_outline_building": True, "show_outline_revision": True, "show_draft_writing": True, "show_bibliography": True, "show_chunks": True, "show_yield_events": True, "show_astream": True, "show_astream_tokens": False, "show_astream_chunks": True, "chunk_sizes": { "topic_analyzer": 25, "research_retriever": 50, "outline_builder": 40, "outline_revision": 40, "draft_writer": 75, "bibliography_generator": 50 } } # NEW: AStream-focused preset (emphasizes async streaming) ASTREAM_STREAMING = { "stream_delay": 0.005, "show_topic_analysis": True, "show_research_retrieval": True, "show_outline_building": True, "show_outline_revision": True, "show_draft_writing": True, "show_bibliography": True, "show_chunks": True, "show_yield_events": True, "show_astream": True, "show_astream_tokens": True, "show_astream_chunks": True, "astream_delay": 0.005, "astream_realtime": True, "astream_event_frequency": 5, "chunk_sizes": { "topic_analyzer": 15, "research_retriever": 30, "outline_builder": 25, "outline_revision": 25, "draft_writer": 50, "bibliography_generator": 30 } } # ============================================================================= # HELPER FUNCTIONS # ============================================================================= def get_streaming_config(preset=None): """ Get streaming configuration with optional preset Args: preset (str): 'fast', 'slow', 'none', 'yield', 'astream', or None for default Returns: dict: Streaming configuration """ if preset == "fast": return {**STREAMING_CONFIG, **FAST_STREAMING} elif preset == "slow": return {**STREAMING_CONFIG, **SLOW_STREAMING} elif preset == "none": return {**STREAMING_CONFIG, **NO_STREAMING} elif preset == "yield": return {**STREAMING_CONFIG, **YIELD_STREAMING} elif preset == "astream": return {**STREAMING_CONFIG, **ASTREAM_STREAMING} else: return {**STREAMING_CONFIG, "stream_delay": STREAM_DELAY} def get_chunk_size(step_name: str, preset: str = None) -> int: """ Get chunk size for a specific step Args: step_name: Name of the processing step preset: Optional preset name Returns: int: Chunk size for the step """ if preset == "yield": return YIELD_STREAMING.get("chunk_sizes", {}).get(step_name, 50) elif preset == "astream": return ASTREAM_STREAMING.get("chunk_sizes", {}).get(step_name, 30) else: return YIELD_CHUNK_SIZES.get(step_name, 100) def get_astream_chunk_size(step_name: str, preset: str = None) -> int: """ Get AStream chunk size for a specific step Args: step_name: Name of the processing step preset: Optional preset name Returns: int: AStream chunk size for the step """ if preset == "astream": return ASTREAM_STREAMING.get("chunk_sizes", {}).get(step_name, 30) else: return ASTREAM_CHUNK_SIZES.get(step_name, 50) def is_yield_enabled(preset: str = None) -> bool: """ Check if yield processing is enabled Args: preset: Optional preset name Returns: bool: True if yield processing is enabled """ if preset == "none": return False return ENABLE_YIELD_PROCESSING def is_astream_enabled(preset: str = None) -> bool: """ Check if AStream processing is enabled Args: preset: Optional preset name Returns: bool: True if AStream processing is enabled """ if preset == "none": return False return ENABLE_ASTREAM_PROCESSING def get_astream_config(preset: str = None) -> dict: """ Get AStream-specific configuration Args: preset: Optional preset name Returns: dict: AStream configuration """ base_config = { "enabled": ENABLE_ASTREAM_PROCESSING, "delay": ASTREAM_DELAY, "buffer_size": ASTREAM_BUFFER_SIZE, "realtime": ASTREAM_REALTIME, "event_frequency": ASTREAM_EVENT_FREQUENCY } if preset == "astream": return {**base_config, **ASTREAM_STREAMING} else: return base_config def print_streaming_help(): """Print help information about streaming configuration""" print("\n" + "="*60) print("STREAMING CONFIGURATION HELP") print("="*60) print("To modify streaming behavior, edit streaming_config.py:") print() print("1. Change STREAM_DELAY for speed control:") print(" - 0.0 = Instant") print(" - 0.05 = Medium (default)") print(" - 0.1 = Slow") print() print("2. Enable/disable steps in STREAMING_CONFIG:") print(" - show_topic_analysis: True/False") print(" - show_outline_building: True/False") print(" - show_draft_writing: True/False") print(" - show_chunks: True/False") print(" - show_yield_events: True/False") print(" - show_astream: True/False") print(" - show_astream_tokens: True/False") print(" - show_astream_chunks: True/False") print() print("3. Configure yield processing:") print(" - YIELD_CHUNK_SIZES: Control chunk sizes per step") print(" - ENABLE_YIELD_PROCESSING: Enable/disable yield generators") print(" - TOKEN_CHUNK_SIZE: Control token chunking") print() print("4. Configure AStream processing:") print(" - ENABLE_ASTREAM_PROCESSING: Enable/disable AStream") print(" - ASTREAM_CHUNK_SIZES: Control AStream chunk sizes") print(" - ASTREAM_DELAY: Control AStream processing delay") print(" - ASTREAM_REALTIME: Enable real-time AStream processing") print() print("5. Use presets in main.py:") print(" - streaming_config = get_streaming_config('fast')") print(" - streaming_config = get_streaming_config('slow')") print(" - streaming_config = get_streaming_config('none')") print(" - streaming_config = get_streaming_config('yield')") print(" - streaming_config = get_streaming_config('astream')") print() print("6. Yield Generator Features:") print(" - Progressive text processing") print(" - Memory-efficient streaming") print(" - Real-time chunk updates") print(" - Configurable chunk sizes") print() print("7. AStream Features:") print(" - Async streaming with better performance") print(" - Real-time token processing") print(" - Configurable async delays") print(" - Buffer-based token accumulation") print("="*60)