SurfSense/surfsense_backend/app/tasks/chat/streaming/flows/shared
CREDO23 e9a98ecafb refactor(chat): add streaming/flows/shared/ base helpers
Six small, single-purpose modules shared by the upcoming new_chat and
resume_chat orchestrators:

* llm_bundle: dispatches negative config_id to the YAML loader and
  non-negative config_id to the DB loader, returning (llm, AgentConfig).
* pre_stream_setup: builds the connector service, resolves the
  Firecrawl API key, and returns the chat checkpointer.
* first_frames: iter_initial_frames + iter_final_frames emit the canonical
  message-start / step-start / idle / finish / done SSE envelope.
* finalize_emit: iter_token_usage_frame emits the per-turn usage frame
  from a TokenAccumulator summary.
* finally_cleanup: close_session_and_clear_ai_responding and run_gc_pass
  centralize the finally-block bookkeeping.
* span: open_chat_request_span / set_agent_mode / close_chat_request_span /
  record_outcome_attrs wrap the OpenTelemetry chat_request span.

Add-only; these are not yet wired into stream_new_chat.py.
2026-05-25 21:49:09 +02:00
..
__init__.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00
finalize_emit.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00
finally_cleanup.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00
first_frames.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00
llm_bundle.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00
pre_stream_setup.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00
span.py refactor(chat): add streaming/flows/shared/ base helpers 2026-05-25 21:49:09 +02:00