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, CyteOnto for CyteOnto.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 other to 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'#

primary until the fallback agent is asked to describe labels, then mixed. The type also allows fallback.

embeddingTier: str = 'primary'#

Which models made the label embeddings that were matched, new or cached: primary, fallback, or mixed for both. Embedding the ontology terms does not count.

llm: cyteonto.LlmConfig#

Required. The primary LLM, replaced by fallback_llm, if one was passed, when llmTier becomes mixed.

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]