Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 3.53 KB

File metadata and controls

48 lines (37 loc) · 3.53 KB

Comedian Assistant Experience

This example is based on the comedian example

The code in main.py sets up a conversation between two agents: a comedian agent and a user proxy agent.

Let's break down the code step by step:

  1. Importing Modules:

    • The code begins by importing the necessary modules: AssistantAgent, UserProxyAgent, and Teachability from the autogen.agentchat.contrib.capabilities package.
    • It also imports the os module.
  2. Configuration:

    • The code defines a list called config_list which contains a dictionary with configuration details for the agents.
    • The dictionary includes information such as the model, API key, API type, base URL, and API version. These values are retrieved from environment variables using the os.environ.get() function.
  3. Creating the Comedian Agent:

    • The code creates an instance of the AssistantAgent class called comedian.
    • The AssistantAgent constructor takes several parameters:
      • name: The name of the agent, which is set to "comedian".
      • system_message: A system message that describes the agent's role, which is set to "You are a professional comedian. You can tell jokes and entertain people."
      • description: A description of the agent, which is set to "This agent is a great comedian telling interesting and funny jokes."
      • llm_config: A configuration dictionary that includes the config_listcreated earlier.
  4. Teachability:

    • The code creates an instance of the Teachability class called teachability.
    • The Teachability constructor takes several parameters:
      • reset_db: A boolean value indicating whether to reset the agent's database, which is set to False.
      • path_to_db_dir: The path to the directory where the agent's experience will be stored, which is set to "./comedian_assistant_experience".
      • llm_config: A configuration dictionary that includes the config_list created earlier.
  5. Adding Teachability to the Comedian Agent:

    • The code adds the teachability instance to the comedian agent using the add_to_agent() method of the Teachability class.
    • This allows the comedian agent to learn from user interactions and improve its responses over time.
  6. Creating the User Proxy Agent:

    • The code creates an instance of the UserProxyAgent class called user_proxy
    • The UserProxyAgent constructor takes several parameters:
      • name: The name of the agent, which is set to "user_proxy".
      • code_execution_config: A configuration dictionary for code execution, which includes the working directory and whether to use Docker. In this case, the working directory is set to "coding" and Docker is not used.
  7. Initiating the Chat:

    • The code initiates a chat between the comedian agent and the user_proxy agent using the initiate_chat() method of the UserProxyAgent class.
    • The initiate_chat() method takes two parameters:
      • The first parameter is the agent to initiate the chat with, which is the comedian agent in this case.
      • The second parameter is the message to start the conversation, which is set to "Tell me a joke about cats and ninjas."

Overall, this code sets up a conversation between a comedian agent and a user proxy agent, allowing the user to interact with the comedian agent and receive jokes or entertainment. The Teachability capability is also added to the comedian agent, enabling it to learn from user interactions and improve its responses.