Add SURYA_STREAM_MODE streaming (off/on/abort) for chat completions

- _generate_one_stream: streams responses, optional live repeat-loop
  detection (abort) that closes the stream early and flags the partial
  result as repeat=True so the existing retry loop re-runs with higher
  temperature
- _should_retry honors result.repeat; stream_mode threaded through both
  first attempt and retry calls in chat_completions_batch
- GenerationResult.repeat field; SURYA_STREAM_MODE setting (default off)
- diagnostic retry logs (reason=repeat|error|detected, temp)
- docker-compose: SURYA_STREAM_MODE=off, 4090 GPU profile, logs volume
- logger.yaml: TimedRotatingFileHandler for error handler (fixes startup
  crash without maxBytes)
This commit is contained in:
2026-08-06 16:12:56 +03:00
parent 41fc6db9eb
commit 86c579be84
7 changed files with 95 additions and 3 deletions
+5
View File
@@ -73,6 +73,11 @@ class Settings(BaseSettings):
SURYA_INFERENCE_STARTUP_TIMEOUT: float = 600.0
SURYA_INFERENCE_LOGPROBS: bool = True
SURYA_INFERENCE_MAX_RETRIES: int = 1
# "off" = non-streaming chat completions (default, unchanged behaviour)
# "on" = stream the response (same retry semantics, measures streaming overhead)
# "abort" = stream + abort early on token repetition loop, then retry with
# higher temperature (see openai_client._generate_one_stream)
SURYA_STREAM_MODE: str = "off"
# Force layout/table_rec output through a JSON schema via guided decoding.
# Eliminates malformed-JSON failures at small decode-throughput cost.
SURYA_GUIDED_LAYOUT: bool = True