GPTAssistantAgent

GPTAssistantAgent(
    name='GPT Assistant',
    instructions: str | None = None,
    llm_config: dict | bool | None = None,
    assistant_config: dict | None = None,
    overwrite_instructions: bool = False,
    overwrite_tools: bool = False,
    **kwargs
)

An experimental AutoGen agent class that leverages the OpenAI Assistant API for conversational capabilities. This agent is unique in its reliance on the OpenAI Assistant for state management, differing from other agents like ConversableAgent.

Parameters:
NameDescription
name='GPT Assistant'
instructionsinstructions for the OpenAI assistant configuration.

When instructions is not None, the system message of the agent will be set to the provided instructions and used in the assistant run, irrespective of the overwrite_instructions flag.

But when instructions is None, and the assistant does not exist, the system message will be set to AssistantAgent.DEFAULT_SYSTEM_MESSAGE.

If the assistant exists, the system message will be set to the existing assistant instructions.

Type: str | None

Default: None
llm_configllm inference configuration.

- model: Model to use for the assistant (gpt-4-1106-preview, gpt-3.5-turbo-1106).

assistant_config - assistant_id: ID of the assistant to use.

If None, a new assistant will be created.

- check_every_ms: check thread run status interval - tools: Give Assistants access to OpenAI-hosted tools like Code Interpreter and Knowledge Retrieval, or build your own tools using Function calling.

ref https://platform.openai.com/docs/assistants/tools - file_ids: (Deprecated) files used by retrieval in run.

It is Deprecated, use tool_resources instead.

https://platform.openai.com/docs/assistants/migration/what-has-changed.

- tool_resources: A set of resources that are used by the assistant’s tools.

The resources are specific to the type of tool.

Type: dict | bool | None

Default: None
assistant_configType: dict | None

Default: None
overwrite_instructionswhether to overwrite the instructions of an existing assistant.

This parameter is in effect only when assistant_id is specified in llm_config.

Type: bool

Default: False
overwrite_toolswhether to overwrite the tools of an existing assistant.

This parameter is in effect only when assistant_id is specified in llm_config.

Type: bool

Default: False
**kwargs

Class Attributes

DEFAULT_MODEL_NAME



Instance Attributes

assistant_id


Return the assistant id

oai_threads


Return the threads of the agent.

openai_assistant



openai_client



Instance Methods

clear_history

clear_history(self, agent: autogen.agentchat.agent.Agent | None = None) -> 

Clear the chat history of the agent.

Parameters:
NameDescription
agentthe agent with whom the chat history to clear.

If None, clear the chat history with all agents.

Type: autogen.agentchat.agent.Agent | None

Default: None

delete_assistant

delete_assistant(self) -> 

Delete the assistant from OAI assistant API


find_matching_assistant

find_matching_assistant(
    self,
    candidate_assistants,
    instructions,
    tools
) -> 

Find the matching assistant from a list of candidate assistants. Filter out candidates with the same name but different instructions, and function names.

Parameters:
NameDescription
candidate_assistants
instructions
tools

get_assistant_instructions

get_assistant_instructions(self) -> 

Return the assistant instructions from OAI assistant API


pretty_print_thread

pretty_print_thread(self, thread) -> 

Pretty print the thread.

Parameters:
NameDescription
thread

reset

reset(self) -> 

Resets the agent, clearing any existing conversation thread and unread message indices.