foley.agent.refine#
refine_query — one event query → 2–4 paraphrases for multi-query retrieval.
Retrieval quality is sensitive to phrasing (report 05 §2.2): several phrasings of the
same intent raise recall. v1 emits a multi-query list that
search_sounds() runs and RRF-merges (CLAP text-embedding
mean-pool fusion is a later drop-in behind this same seam). refine_query is also the
re-retrieval lever in the verify→refine loop, steered by a failure hint.
Two impls behind the Refiner seam: the deterministic
KeywordRefiner (default + CI fake) and the LLM-backed
AnthropicRefiner (foley[agent]; anthropic imported lazily inside the
method only, so import foley stays dol-only).
Functions
|
Expand |
Classes
|
LLM-backed refiner ( |
Deterministic template-expansion refiner — the default and CI fake. |
- class foley.agent.refine.AnthropicRefiner(*, client=None, model='claude-opus-4-8', max_tokens=500)[source]#
Bases:
objectLLM-backed refiner (
foley[agent]): Claude → a paraphrase list.anthropicimported lazily insiderefine(). Stashes theMessageonself.last_responsefor the GenAI span.
- class foley.agent.refine.KeywordRefiner[source]#
Bases:
objectDeterministic template-expansion refiner — the default and CI fake.
Expands a query into
ndistinct paraphrases via fixed descriptor templates; a verify-failurehintnudges one extra variant. No RNG, noanthropic— same query → identical paraphrase list.
- foley.agent.refine.refine_query(query, *, n=3, hint=None, refiner=None, _span=None)[source]#
Expand
queryinto up tonparaphrases for multi-query retrieval.- Parameters:
query (
str) – The event query to expand.n (
int) – Number of paraphrases.hint (
Optional[str]) – Optional verify-failure reason to steer re-retrieval.refiner (
Optional[Refiner]) – An injectedRefiner(the DI seam); defaults to_default_refiner()._span – Internal — the obs span handle for GenAI recording.
- Return type: