provrun.backends.litellm

One model call through LiteLLM, with the inputs in the message.

A text input goes into the user message as text. A PDF or an image goes in as a content block, as a base64 data URI. A folder is refused, and so is a tool: an agent that reads folders or calls tools needs the PydanticAI backend.

The answer is written to /output/response.txt, so every backend leaves its output in the same place.

LiteLLM’s OpenTelemetry loggers (“otel”, and others built on it, such as “logfire”, “arize” and “langfuse_otel”) make no span of their own when a span is active. They write their attributes, prompts included, and an OK status onto the active span, which is provrun’s step, often after that span ended. So before each call, provrun sets USE_OTEL_LITELLM_REQUEST_SPAN=true, and those loggers make their own span. The setting does nothing when no such logger is on. It stays set for the rest of the process, because LiteLLM’s loggers run after the call returns. A value that someone set already is kept, with a warning if it is not “true”.

class LiteLLMBackend

source

LiteLLMBackend(completion: Any = None)

One model call through litellm.acompletion, with the inputs in the message.

It needs provrun[litellm].

Parameter Type Default Description
completion Any None An async function like litellm.acompletion to call instead, for tests; None is LiteLLM’s

LiteLLMBackend.execute

source

async LiteLLMBackend.execute(ctx: RunContext, agent: AgentSpec, run: RunSpec) -> RunResult

Call the model once with the inputs in the message, and write the reply to response.txt.

The call is streamed if the spec asks. Raises ValueError for a tool, a model setting not in SETTINGS, or a folder input.

Parameter Type Default Description
ctx RunContext required The run; its recorder takes prompt_rendered and model_called
agent AgentSpec required The agent to run
run RunSpec required The staged inputs, each a file, and the output folder
returns RunResult The reply’s text and its token counts