foley.agent.decompose#
decompose_context — narrative passage → a sparse, salience-ranked event list.
The moat of the SELECT stage (report 05 §2): turning prose into a *tastefully sparse,
correctly-diegetic* SoundEvent list is the hard, defensible part —
not the CLAP encoder. Two impls sit behind the Decomposer
seam:
KeywordDecomposer— the deterministic default and the hermetic CI fake: a built-in cue lexicon, zero dependencies, same passage → identical list.AnthropicDecomposer— the LLM-backed impl behind thefoley[agent]extra;anthropicis imported lazily inside.decomposeonly, soimport foleystays dol-only.
decompose_context() is the pure tool wrapper (Python-API == agent == future-MCP
surface): it resolves the default decomposer, calls it, and records the GenAI span on
the real path.
Functions
|
Decompose a passage into |
Classes
|
LLM-backed decomposer ( |
Deterministic cue-lexicon decomposer — the zero-dependency default and CI fake. |
- class foley.agent.decompose.AnthropicDecomposer(*, client=None, model='claude-opus-4-8', max_tokens=2000)[source]#
Bases:
objectLLM-backed decomposer (
foley[agent]): Claude → a structured event list.anthropicis imported lazily insidedecompose()soimport foleystays dol-only. Stashes the returnedMessageonself.last_responsesodecompose_context()can record the GenAI span (token usage / model / stop_reason). Model, thinking, and structured-output shape follow theclaude-apiconventions (claude-opus-4-8, adaptive thinking — neverbudget_tokens).
- class foley.agent.decompose.KeywordDecomposer[source]#
Bases:
objectDeterministic cue-lexicon decomposer — the zero-dependency default and CI fake.
Scans the passage against
_CUE_LEXICON, emits oneSoundEventper matched cue in first-appearance order (so salience descends with reading order), dedupes by canonical query, and truncates tomax_events(the sparse density budget). No RNG, no network, noanthropic— same passage → identical list.
- foley.agent.decompose.decompose_context(context, *, max_events=6, seconds=None, decomposer=None, _span=None)[source]#
Decompose a passage into
<= max_eventssparseSoundEvents.The pure SELECT tool (Python-API == agent == future-MCP surface): resolves the default decomposer when
decomposerisNone, calls it, and records the GenAI span on the real path (the fake’slast_responseisNone→ no-op).- Parameters:
context (
str) – The narrative passage.max_events (
int) – The sparse density cap.seconds (
Optional[float]) – Optional passage duration (density-window hint; forwarded, else ignored).decomposer (
Optional[Decomposer]) – An injectedDecomposer(the DI seam); defaults to_default_decomposer()._span – Internal — the obs span handle
find()opens for GenAI recording.
- Return type: