coact.llm¶
Provider-agnostic LLM facade — thin, injected, never a hard dependency.
COACT_SPEC §5.5 / §8 / DECISIONS D10. Any LLM use in coact goes through this
facade, and every mechanical path runs with no LLM at all. The facade
resolves an injected llm to a callable(str) -> str from, in order:
an explicit
callable(use as-is);an
awStepConfig(use itsresolve_llm()— reuse aw’s injection);a model-name
str(wrapskill.ai.chatwith that model);None→skill.ai.chatif any provider is configured, elseNone.
When nothing is available, resolve_llm() returns None and callers fall
back to their template path — no provider lock-in, no crash. structured()
adds a best-effort (prompt, schema) -> dict on top (instruct-JSON + parse +
one retry), used only for optional return-contract drafting.
Functions
|
Resolve |
|
Best-effort schema-conforming dict from an LLM, or |
- coact.llm.resolve_llm(llm=None)[source]¶
Resolve
llmto acallable(str) -> str, orNoneif unavailable.>>> resolve_llm(lambda p: 'hi')('x') 'hi' >>> resolve_llm('no-such-thing') is None or callable(resolve_llm('no-such-thing')) True
- coact.llm.structured(prompt, schema, *, llm=None, retries=1)[source]¶
Best-effort schema-conforming dict from an LLM, or
Noneif unavailable.Native structured output is provider-specific; this facade stays portable by instructing JSON-only output that conforms to
schemaand parsing it, retrying once on a parse miss. ReturnsNonewhen no LLM is resolvable — callers fall back to a template (DECISIONS D10).