Chat#

class unify.chat.ChatBot(endpoint=None, model=None, provider=None, api_key=None)#

Bases: object

Agent class represents an LLM chat agent.

__init__(endpoint=None, model=None, provider=None, api_key=None)#

Initializes the ChatBot object.

Args:
endpoint (str, optional): Endpoint name in OpenAI API format:

<uploaded_by>/<model_name>@<provider_name> Defaults to None.

model (str, optional): Name of the model. If None, endpoint must be provided.

provider (str, optional): Name of the provider. If None, endpoint must be provided.

api_key (str, optional): 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.

clear_chat_history()#

Clears the chat history.

Return type:

None

property client: Unify#

DAR201.

Returns:

str: The model name.

Type:

Get the client object. # noqa

property endpoint: str#

DAR201.

Returns:

str: The endpoint name.

Type:

Get the endpoint name. # noqa

property model: str#

DAR201.

Returns:

str: The model name.

Type:

Get the model name. # noqa

property provider: str | None#

DAR201.

Returns:

str: The provider name.

Type:

Get the provider name. # noqa

run(show_credits=False, show_provider=False)#

Starts the chat interaction loop.

Return type:

None

Args:

show_credits (bool, optional): Whether to show credit consumption. Defaults to False. show_provider (bool, optional): Whether to show the provider used. Defaults to False.

set_client(value)#

Set the model name. # noqa: DAR101.

Return type:

None

Args:

value: The unify client.

set_endpoint(value)#

Set the model name. # noqa: DAR101.

Return type:

None

Args:

value (str): The endpoint name.

set_model(value)#

Set the model name. # noqa: DAR101.

Return type:

None

Args:

value (str): The model name.

set_provider(value)#

Set the provider name. # noqa: DAR101.

Return type:

None

Args:

value (str): The provider name.