Skip to main content
LLM provider factories + the LangGraph checkpoint/store registries. The chat-model, embedding, and classifier factories cache per (provider, kwargs) and import their langchain provider package lazily inside the build; the registry accessors return the running event loop’s singletons that pool checkpoint/store connection resources. Importing this package pulls langchain_core / langgraph — that is the opt-in boundary (the tai42_kit top level stays vendor-free).

MonitoringCallbackHandler

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler
Records one bound run’s LangChain runs through writer under trace_context. grouping_nodes names the framework nodes (langgraph_node) that hold steps rather than being one; their chain records carry StepRole.GROUPING. chain_payloads selects how chain runs record their input/output (see the module docstring). Attributes

Members

on_chain_start

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_chain_start
Open the chain run’s span and record its input payload. Parameters

on_chain_end

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_chain_end
Record the chain run’s output payload and end its span. Parameters

on_chain_error

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_chain_error
End the chain run’s span: an interrupt as interrupted, any other error at ERROR. Parameters

on_chat_model_start

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_chat_model_start
Open the model run’s span with its input messages in full. Parameters

on_llm_start

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_llm_start
Open the completion run’s span with each prompt as one user message. Parameters

on_llm_end

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_llm_end
Record the generated messages in full, the usage and the generated message’s full record. Parameters

on_llm_error

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_llm_error
End the model run’s span at ERROR. Parameters

on_tool_start

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_tool_start
Open the tool run’s span with its arguments in full. Parameters

on_tool_end

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_tool_end
Record the tool’s result in full and end its span. Parameters

on_tool_error

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_tool_error
End the tool run’s span at ERROR. Parameters

on_retriever_start

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_retriever_start
Open the retriever run’s span (a tool record) with its query. Parameters

on_retriever_end

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_retriever_end
Record the retrieved documents and end the span. Parameters

on_retriever_error

tai42_kit.llm.monitoring_callbacks.MonitoringCallbackHandler.on_retriever_error
End the retriever run’s span at ERROR. Parameters

ToolNameTooLongError

tai42_kit.llm.models.ToolNameTooLongError
A tool name is longer than a bound tool name may be.

bind_run_trace

tai42_kit.llm.run_trace.bind_run_trace
config copied by value, with the monitoring callbacks for context appended after the caller’s own. The copy is a fresh top-level mapping, a fresh configurable and a fresh callbacks list, so one base config can feed many parallel invocations without colliding. A MonitoringCallbackHandler bound to context is appended only when context is not None and the active writer records (is_recording()). grouping_nodes names the framework nodes that hold steps rather than being one. chain_payloads='references' (default) — each chain run records a manifest that references the record where each value first appeared, by identity; 'producer' — the producer records chain-run inputs/outputs itself. A run declared through declared_chain_payload records the producer’s build result in either mode. Model and tool runs are recorded in full either way. Parameters

check_tool_name

tai42_kit.llm.models.check_tool_name
Refuse a tool name longer than TOOL_NAME_MAX_LEN. The bound is the strictest among the providers a bound tool is sent to; a longer name is refused, never truncated (a truncated name would name a different tool). Parameters

checkpoint_registry

tai42_kit.llm.checkpoint.checkpoint_registry.checkpoint_registry
Return the CheckpointRegistry for the running event loop. One registry per loop and client epoch: the next call after the epoch advances, or after close_all(), builds a fresh registry.

declared_chain_payload

tai42_kit.llm.monitoring_callbacks.declared_chain_payload
Record build(inputs) / build(outputs) as the payloads of LangChain run run_id started in the block. The producer passes config["run_id"] = run_id to the run it starts (LangChain names exactly that one run with it). build is called while the run’s span is current, so it may read writer.current_span_id(). Parameters

get_classifier

tai42_kit.llm.classifier.get_classifier
Build (or return the cached) classifier runnable for provider with the given kwargs. Parameters

get_classifier_async

tai42_kit.llm.classifier.get_classifier_async
Build (or return the cached) classifier runnable for provider, off the event loop. Parameters

get_embedding

tai42_kit.llm.embedding.get_embedding
Build (or return the cached) Embeddings client for provider with the given kwargs. Parameters

get_embedding_async

tai42_kit.llm.embedding.get_embedding_async
Build (or return the cached) Embeddings client for provider, off the event loop. Parameters

get_llm

tai42_kit.llm.models.get_llm
Build (or return the cached) chat model for provider with the given kwargs. A set reasoning_effort is validated against the built model’s declared capability after construction: the generic effort lever reaches the provider constructor as a kwarg, and a level the model does not declare is refused loudly here (see _validate_reasoning_effort) rather than failing opaquely on the wire. Parameters

get_llm_async

tai42_kit.llm.models.get_llm_async
Build the chat model for provider in a worker thread, off the event loop. Parameters

store_registry

tai42_kit.llm.store.store_registry.store_registry
Return the StoreRegistry for the running event loop. One registry per loop and client epoch: the next call after the epoch advances, or after close_all(), builds a fresh registry.

system_prompt_cache_mark

tai42_kit.llm.models.system_prompt_cache_mark
The content-block kwargs that mark provider’s system prompt for caching, or None. A provider that takes an explicit system-prompt cache breakpoint returns the system_content_kwargs that carry it (the block build_system_message merges onto the system message); a provider that caches its prefixes with no mark, or does not cache, returns None. The match mirrors _build_llm’s so a provider name never leaves this module and an unknown provider is refused loudly rather than silently un-marked. Parameters Classifier model factory and its provider-agnostic contract. A classifier judges JSON-compatible state against typed questions and returns typed answers — JSON in, JSON out. Three question kinds cover the common judgments: a binary noul (the probability that the answer is yes), a categorical choice (one label from a fixed set, with a probability for every label), and an ordinal score (an expected value over an ordered rubric). A request pairs the state with a named mapping of questions; the response carries one answer per question, token usage, and the provider’s request id. These pydantic models ARE the platform’s classifier contract. get_classifier and get_classifier_async build a cached, provider-keyed runnable that accepts a ClassifyRequest and returns a ClassifyResponse; each provider adapts this contract to its own wire shape behind the factory. The models take no vendor import, so the contract can be read and constructed without any provider package installed. Every set a request declares is enforced by the factory’s runnable on every call, whatever the provider: one answer per question name, of the question’s kind; a choice label from the keys of its criteria; a score over its levels. A response outside any of them raises ClassifierAnswerError, so a caller never receives an answer it did not declare.

QuestionContent

tai42_kit.llm.classifier.QuestionContent
Instruction text or structured content the classifier judges against: free text, a JSON object, or a JSON array.

NoulCriteria

tai42_kit.llm.classifier.NoulCriteria
Optional descriptions of what the yes and no outcomes of a noul question mean. Attributes

NoulQuestion

tai42_kit.llm.classifier.NoulQuestion
Binary question: judge the state and return the probability that the answer is yes. Attributes

ChoiceQuestion

tai42_kit.llm.classifier.ChoiceQuestion
Categorical question: pick one label from criteria, keyed by label to its description. Attributes

ScoreQuestion

tai42_kit.llm.classifier.ScoreQuestion
Ordinal question: rate the state against criteria, an ordered rubric of two or more levels. Attributes

ClassifyQuestion

tai42_kit.llm.classifier.ClassifyQuestion
A question of one of the three kinds, discriminated on type.

ClassifyRequest

tai42_kit.llm.classifier.ClassifyRequest
The state to judge together with the named questions to answer about it. Attributes

NoulAnswer

tai42_kit.llm.classifier.NoulAnswer
The probability, from 0 to 1, that a noul question’s answer is yes. Attributes

ChoiceAnswer

tai42_kit.llm.classifier.ChoiceAnswer
The selected label of a choice question, its per-label probabilities, and a confidence. Attributes

ScoreAnswer

tai42_kit.llm.classifier.ScoreAnswer
The expected value of a score question, the level legend and distribution, and a confidence. Attributes

ClassifyAnswer

tai42_kit.llm.classifier.ClassifyAnswer
An answer of one of the three kinds, discriminated on type.

ClassifierAnswerError

tai42_kit.llm.classifier.ClassifierAnswerError
The provider’s response falls outside a set its request declares. A request declares its question names and each question’s kind; a choice question declares its labels (the keys of its criteria) and a score question its levels (0 to len(criteria) - 1). A response that answers other questions, answers one with another kind, picks a label outside the labels, scores outside the levels, or keys its probabilities or legend by anything but exactly those labels or levels breaks the classifier contract. The request was valid, so the failure is the provider’s, and the message names the question, what the provider gave, and what was declared.

ClassifyUsage

tai42_kit.llm.classifier.ClassifyUsage
Token usage reported for a classification request; either count may be unreported. Attributes

ClassifyResponse

tai42_kit.llm.classifier.ClassifyResponse
One answer per requested question, plus the model, token usage, and provider request id. Attributes