fix: key users by account_id and tolerate candidate count variance
This commit is contained in:
parent
1a0712144e
commit
ce652d3114
3 changed files with 23 additions and 4 deletions
|
|
@ -50,7 +50,7 @@ class IntentOutput(BaseModel):
|
|||
familiarity: Familiarity
|
||||
is_refinement: bool
|
||||
intent_summary: str = Field(min_length=1, max_length=300, pattern=r"^[^\r\n]+$")
|
||||
candidates: list[CandidateOutput] = Field(min_length=30, max_length=40)
|
||||
candidates: list[CandidateOutput] = Field(min_length=10, max_length=50)
|
||||
|
||||
|
||||
class RerankSelectionOutput(BaseModel):
|
||||
|
|
@ -112,8 +112,6 @@ class AnthropicRecommender:
|
|||
if parsed is None:
|
||||
raise RecommenderOutputError("Intent response contained no structured output")
|
||||
validated = IntentOutput.model_validate(parsed.model_dump())
|
||||
if len(validated.candidates) != candidate_count:
|
||||
raise RecommenderOutputError("Intent response returned the wrong candidate count")
|
||||
return _to_intent(validated)
|
||||
|
||||
async def stream_rerank(
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ def parse_saved_track_page(payload: object) -> list[Track]:
|
|||
def parse_current_user(payload: object) -> CurrentUser:
|
||||
"""Map a Spotify current-user response into stable identity fields."""
|
||||
root = _as_mapping(payload)
|
||||
account_id = _required_string(root, "id") or _required_string(root, "account_id")
|
||||
account_id = _required_string(root, "account_id") or _required_string(root, "id")
|
||||
display_name = _required_string(root, "display_name")
|
||||
if account_id is None or display_name is None:
|
||||
raise ValueError("Spotify returned an invalid current-user response")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue