ChatBot

class ChatBot()

Agent class represents an LLM chat agent.


__init__

def __init__(endpoint: Optional[str] = None,
             model: Optional[str] = None,
             provider: Optional[str] = None,
             api_key: Optional[str] = None) -> None

Initializes the ChatBot object.

Arguments:

  • endpoint - Endpoint name in OpenAI API format: <uploaded_by>/<model_name>@<provider_name> Defaults to None.

  • model - Name of the model. If None, endpoint must be provided.

  • provider - Name of the provider. If None, endpoint must be provided.

  • api_key - API key for accessing the Unify API. If None, it attempts to retrieve the API key from the environment variable UNIFY_KEY. Defaults to None.

Raises:

  • UnifyError - If the API key is missing.

client

@property
def client() -> Unify

Get the client object.

Returns:

The client.


set_client

def set_client(value: Unify) -> None

Set the client.

Arguments:

  • value - The unify client.

model

@property
def model() -> str

Get the model name.

Returns:

The model name.


set_model

def set_model(value: str) -> None

Set the model name.

Arguments:

  • value - The model name.

provider

@property
def provider() -> Optional[str]

Get the provider name.

Returns:

The provider name.


set_provider

def set_provider(value: str) -> None

Set the provider name.

Arguments:

  • value - The provider name.

endpoint

@property
def endpoint() -> str

Get the endpoint name.

Returns:

The endpoint name.


set_endpoint

def set_endpoint(value: str) -> None

Set the endpoint name.

Arguments:

  • value - The endpoint name.

clear_chat_history

def clear_chat_history() -> None

Clears the chat history.


run

def run(show_credits: bool = False, show_provider: bool = False) -> None

Starts the chat interaction loop.

Arguments:

  • show_credits - Whether to show credit consumption. Defaults to False.
  • show_provider - Whether to show the provider used. Defaults to False.