kodeagent.kutils.call_llm#
- async kodeagent.kutils.call_llm(model_name: str, litellm_params: dict, messages: list[dict], response_format: type[BaseModel] | None = None, trace_id: str | None = None, max_retries: int = 3, usage_tracker: Any | None = None, component_name: str = 'unknown') str | None[source]#
Call the LLM with the given parameters and response format.
- Parameters:
model_name – The name of the LLM model to use.
litellm_params – Dictionary of parameters to pass to litellm.
messages – List of message dictionaries.
response_format – Optional pydantic model for structured output.
trace_id – Optional trace ID for observability.
max_retries – Maximum number of retries for the LLM call.
usage_tracker – Optional UsageTracker instance to record usage.
component_name – Name of the component making the call (for tracking).
- Returns:
The LLM response as string.
- Raises:
RetryError – If the LLM call fails after maximum retries.
ValueError – If the LLM returns an empty or invalid response body.