File size: 12,210 Bytes
1561d5f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | """
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) |