Skip to content

Provider

dopus.core.Provider

Bases: ABC

Abstract base class to manage requests and responses to LLM providers. Core responsibilities: - transforming Convo messages into the format the LLM expects - transforming tools into the correct format for making the API request - extracting data from the response of the API call

Attributes:

Name Type Description
__messages List[Dict[str, Any]]

A list of messages.

__init__

__init__(model: str) -> None

:param model: The model to be used by the provider.

request abstractmethod

request(messages: List[Dict[str, Any]], registry: Any, tools: Optional[List[Any]] = None, system_prompt: str = '') -> Any

Make the completion request to the llm provider

:param messages: List of message dictionaries. :param registry: The registry object. :param tools: Optional list of tools. :param system_prompt: Optional system prompt. :return: The response from the request.

get_tools abstractmethod

get_tools(tools: List[Any], registry: Any) -> List[Any]

Get a list of tools.

:param tools: List of tools. :param registry: The registry object. :return: List of tools.

extract_tool_call_data abstractmethod

extract_tool_call_data(tool_call: Dict[str, Any]) -> Any

Extract data from a tool call.

:param tool_call: The tool call dictionary. :return: Extracted data.

build_log abstractmethod

build_log(response: Any, messages: List[Dict[str, Any]], result: Any, tools: List[Any]) -> Dict[str, Any]

Build a log from a response, messages, result, and tools.

:param response: The response object. :param messages: List of message dictionaries. :param result: The result object. :param tools: List of tools. :return: The log dictionary.

get_tool_calls abstractmethod

get_tool_calls(response: Any) -> List[Dict[str, Any]]

Get tool calls from a response.

:param response: The response object. :return: List of tool call dictionaries.

on_stop

on_stop(convo: Convo, result: Optional[Any] = None) -> None

Handle when the agentic loop stops.

:param convo: The conversation object. :param result: Optional result to be processed.

format_messages

format_messages(messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]

Format a list of messages.

:param messages: List of message dictionaries. :return: List of formatted message dictionaries.