pynydus.llm.client¶
Instructor-based LLM client factory and completions. Spec §9.3.
Provides a vendor-agnostic interface for LLM calls with structured
Pydantic output. Each LLMTierConfig specifies its provider, model, and
API key: no defaults, no fallbacks.
Required dependency:
instructor >= 1.0
Module Contents¶
Functions¶
Create an Instructor client for the given tier config. |
|
Run a structured LLM completion and return a validated Pydantic model. |
Data¶
API¶
- pynydus.llm.client.T¶
‘TypeVar(…)’
- pynydus.llm.client.create_client(tier: pynydus.llm.models.LLMTierConfig) instructor.Instructor¶
Create an Instructor client for the given tier config.
Uses
instructor.from_providerwhich supports Anthropic, OpenAI, Mistral, Cohere, Google, and other vendors via a"provider/model"string.Args: tier: Provider, model, and API key (all required).
Returns: Configured Instructor client.
- pynydus.llm.client._logger¶
‘getLogger(…)’
- pynydus.llm.client.create_completion(tier: pynydus.llm.models.LLMTierConfig, messages: list[dict[str, str]], response_model: type[pynydus.llm.client.T], *, max_retries: int = 3, log: list[dict] | None = None) pynydus.llm.client.T | None¶
Run a structured LLM completion and return a validated Pydantic model.
Returns
None(instead of raising) when the LLM is unavailable so the pipeline can fall back to deterministic-only mode.Args: tier: LLM tier config to use for this call. messages: Chat messages as
[{"role": ..., "content": ...}, ...]. response_model: PydanticBaseModelsubclass. Instructor validates output against this schema (with retries on validation failure). max_retries: Max retries when validation fails. log: If set, appends an{"type": "llm_call", ...}entry with timing, provider, model, and optional token usage.Returns: A validated instance of response_model, or
Noneon failure.