feat: add key-free demo mode replaying recorded fixtures

This commit is contained in:
Justin Visser 2026-08-11 09:14:22 +02:00
parent 0664cc2d27
commit 401a0ddea7
21 changed files with 1040 additions and 31 deletions

View file

@ -118,6 +118,7 @@ class RecommendationPipeline:
query: str,
history: tuple[ConversationTurn, ...],
previous_recommendations: tuple[PreviousRecommendation, ...],
seeded_pool: tuple[Track, ...] | None = None,
) -> AsyncGenerator[PipelineEvent]:
"""Yield ordered events for one recommendation request."""
started_at = time.monotonic()
@ -157,7 +158,9 @@ class RecommendationPipeline:
candidate_count=len(intent.candidates),
)
pool = await self._grounded_pool(session_id, catalog, intent, taste, deadline_at)
pool = await self._grounded_pool(
session_id, catalog, intent, taste, deadline_at, seeded_pool
)
if not pool:
yield PipelineErrorEvent(
code="no_grounded_results",
@ -189,10 +192,13 @@ class RecommendationPipeline:
intent: Intent,
taste: CompressedTasteProfile,
deadline_at: float,
seeded_pool: tuple[Track, ...] | None,
) -> tuple[Track, ...]:
"""Reuse the session's pool on refinement, otherwise ground anew."""
"""Reuse the seeded or session pool on refinement, otherwise ground anew."""
if intent.is_refinement:
cached_pool = self.last_pools.get(session_id)
cached_pool = (
seeded_pool if seeded_pool is not None else self.last_pools.get(session_id)
)
if cached_pool:
return cached_pool
result = await self.grounder.ground(