logger.base_logger
BaseLogger
class BaseLogger(ABC)
start
@abstractmethod
def start() -> str
Open a connection to the logging database, and start recording.
Returns:
session_idstr - a unique id for the logging session
log_chat_completion
@abstractmethod
def log_chat_completion(invocation_id: uuid.UUID, client_id: int,
wrapper_id: int, source: Union[str, Agent],
request: Dict[str, Union[float, str, List[Dict[str,
str]]]],
response: Union[str, ChatCompletion], is_cached: int,
cost: float, start_time: str) -> None
Log a chat completion to database.
In AutoGen, chat completions are somewhat complicated because they are handled by the autogen.oai.OpenAIWrapper class.
One invocation to create can lead to multiple underlying OpenAI calls, depending on the llm_config list used, and
any errors or retries.
Arguments:
invocation_iduuid - A unique identifier for the invocation to the OpenAIWrapper.create method callclient_idint - A unique identifier for the underlying OpenAI client instancewrapper_idint - A unique identifier for the OpenAIWrapper instancesourcestr or Agent - The source/creator of the event as a string name or an Agent instancerequestdict - A dictionary representing the request or call to the OpenAI client endpointresponsestr or ChatCompletion - The response from OpenAIis_cachedint - 1 if the response was a cache hit, 0 otherwisecost(float)- The cost for OpenAI responsestart_timestr - A string representing the moment the request was initiated
log_new_agent
@abstractmethod
def log_new_agent(agent: ConversableAgent, init_args: Dict[str, Any]) -> None
Log the birth of a new agent.
Arguments:
agentConversableAgent - The agent to log.init_argsdict - The arguments passed to the construct the conversable agent
log_event
@abstractmethod
def log_event(source: Union[str, Agent], name: str,
**kwargs: Dict[str, Any]) -> None
Log an event for an agent.
Arguments:
sourcestr or Agent - The source/creator of the event as a string name or an Agent instancenamestr - The name of the eventkwargsdict - The event information to log
log_new_wrapper
@abstractmethod
def log_new_wrapper(
wrapper: OpenAIWrapper,
init_args: Dict[str, Union[LLMConfig, List[LLMConfig]]]) -> None
Log the birth of a new OpenAIWrapper.
Arguments:
wrapperOpenAIWrapper - The wrapper to log.init_argsdict - The arguments passed to the construct the wrapper
log_new_client
@abstractmethod
def log_new_client(client: Union[AzureOpenAI, OpenAI], wrapper: OpenAIWrapper,
init_args: Dict[str, Any]) -> None
Log the birth of a new OpenAIWrapper.
Arguments:
wrapperOpenAI - The OpenAI client to log.init_argsdict - The arguments passed to the construct the client
log_function_use
@abstractmethod
def log_function_use(source: Union[str, Agent], function: F,
args: Dict[str, Any], returns: Any) -> None
Log the use of a registered function (could be a tool)
Arguments:
sourcestr or Agent - The source/creator of the event as a string name or an Agent instancefunctionF - The function informationargsdict - The function args to logreturnsany - The return
stop
@abstractmethod
def stop() -> None
Close the connection to the logging database, and stop logging.
get_connection
@abstractmethod
def get_connection() -> Union[None, sqlite3.Connection]
Return a connection to the logging database.