feat: orchestrate grounded recommendations

This commit is contained in:
Justin Visser 2026-08-10 13:09:08 +02:00
parent 751391e6a2
commit cead39edbc
8 changed files with 1098 additions and 7 deletions

View file

@ -2,7 +2,7 @@
import json
import re
from collections.abc import AsyncIterator
from collections.abc import AsyncGenerator
from typing import Literal, cast
from anthropic import AsyncAnthropic
@ -124,7 +124,7 @@ class AnthropicRecommender:
history: tuple[ConversationTurn, ...],
selection_count: int,
correction: str | None = None,
) -> AsyncIterator[RerankSelection]:
) -> AsyncGenerator[RerankSelection]:
"""Yield each complete valid selection while the JSON is streaming."""
schema = transform_schema(RerankOutput.model_json_schema())
parser = _RecommendationObjectParser()