Usage records#
CyteOnto.usage is an AgentUsage that adds up the requests and tokens of the
successful LLM calls of the instance, to describe and to split labels, including those of
from_config(). Failed attempts are not counted. CyteOnto.model_pair_usage is a
ModelPairUsage that records whether the primary or the fallback models were used.
print(cyto.usage.requests, cyto.usage.totalTokens)
print(cyto.model_pair_usage.to_status_dict())
model_pair_usage.embedding is the full embedding configuration, including its
apiKey, so print or log to_status_dict(), which holds only the names.
Models and providers explains when the fallback models
are used.
- class cyteonto.AgentUsage(*, agentName='', modelName='', requests=0, inputTokens=0, outputTokens=0, totalTokens=0, toolUsage=<factory>)#
Tally of LLM calls made through a given agent.
- agentName: str = ''#
Name of the agent,
CyteOntoforCyteOnto.usage.
- modelName: str = ''#
The model id.
- requests: int = 0#
Number of model requests, including the requests that follow tool calls.
- inputTokens: int = 0#
Number of input tokens.
- outputTokens: int = 0#
Number of output tokens.
- totalTokens: int = 0#
Number of input and output tokens.
- toolUsage: dict[str, int] = {}#
Number of calls of each tool, such as
get_pubmed_abstracts.
- record(model_name, run_usage, tool_counts=None)#
Add the usage of one pydantic-ai run and its tool calls.
- Return type:
None
- merge(other)#
Add the counts of
otherto this tally.- Return type:
None
- class cyteonto.ModelPairUsage(*, llmTier='primary', embeddingTier='primary', llm, embedding)#
Which model pair tiers were used during a run.
- llmTier: str = 'primary'#
primaryuntil the fallback agent is asked to describe labels, thenmixed. The type also allowsfallback.
- embeddingTier: str = 'primary'#
Which models made the label embeddings that were matched, new or cached:
primary,fallback, ormixedfor both. Embedding the ontology terms does not count.
- llm: cyteonto.LlmConfig#
Required. The primary LLM, replaced by
fallback_llm, if one was passed, whenllmTierbecomesmixed.
- embedding: cyteonto.EmbdConfig#
Required. The primary embedding configuration, replaced by the fallback configuration once labels are matched with its embeddings.
- to_status_dict()#
Return the tiers and the provider and model names as strings.
- Return type:
dict[str,str]