AI Workers and Prompts¶
This is where we manage the LLMs that run our prompts. We use Instructor and LiteLLM to
(i) provide a coherent API across vendors; and (ii) to hide configuration and API Keys and
credentials from aidoc user(s).
- class lbn.aidoc.intelligence.Analytics¶
Bases:
BaseModelThe Master Ledger: A structured Pydantic record of all AI drills.
- add_inference(prompt_name: str, inference: Inference)¶
Notarise: Strictly replaces the previous entry for the SAME provider.
- all_providers() List[str]¶
Flatten the nested providers across all active stages and return a unique set.
- fetch_telemetry(prompt_name: str, provider: str) Dict[str, Any]¶
The Forensic Bridge: Looks up the target inference, and uses its native, dynamic .telemetry property to lazy-load the metrics block from MLflow.
- find(prompt_name: str, mode: Mode = 'Mode.MERGED', provider: str | None = None) Any¶
Retrieves the merged high-fidelity Pydantic model instance from the ledger. Consistently maps raw primitives back into the true output schema class.
- inferences(prompt_name: str | None = None, provider: str | None = None) List[Inference]¶
Exhale the raw list of Inference object contracts for a specific stage. If a provider string is passed, filters explicitly for that worker identity.
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- providers(prompt_name: str) List[str]¶
Exhale the hardware addresses (providers) for a specific prompt.
- class lbn.aidoc.intelligence.Inference¶
Bases:
BaseModelThe ‘Contract’: Encapsulates AI conclusion data and local identity tags.
- model_config = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- serialize_inference_contract() Dict[str, Any]¶
The Definitive Serialization Anchor: Safely dumps the nested data field regardless of whether it’s a sub-model or a validated payload primitive.
- property span_id¶
- property telemetry: CompletionUsage | None¶
The Forensic Bridge: Returns our local tracking record, or reaches out across the wire to lazy-load the token schema natively using the Phoenix Client.
- property trace_id¶