Skip to content

Commit

Permalink
added new teachable agents code to make it easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerprogramming committed Jun 2, 2024
1 parent 446d86c commit 541da52
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions autogen_teaching/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENAI_API_KEY=sk-proj-1111
TOKENIZERS_PARALLELISM=false
MODEL=gpt-3.5-turbo
63 changes: 63 additions & 0 deletions autogen_teaching/teachable_agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import autogen
from dotenv import load_dotenv
from autogen import ConversableAgent, UserProxyAgent
from autogen.agentchat.contrib.capabilities.teachability import Teachability

load_dotenv()

config_list = autogen.config_list_from_dotenv(
dotenv_file_path="."
)

teachable_agent = ConversableAgent(
name="teachable_agent", # The name is flexible, but should not contain spaces to work in group chat.
llm_config={"config_list": config_list, "timeout": 120, "cache_seed": None}, # Disable caching.
)

# Instantiate the Teachability capability. Its parameters are all optional.
teachability = Teachability(
verbosity=0, # 0 for basic info, 1 to add memory operations, 2 for analyzer messages, 3 for memo lists.
reset_db=False,
path_to_db_dir="./tmp/notebook/teachability_db",
recall_threshold=1.5, # Higher numbers allow more (but less relevant) memos to be recalled.
)

# Now add the Teachability capability to the agent.
teachability.add_to_agent(teachable_agent)

# Instantiate a UserProxyAgent to represent the user. But in this notebook, all user input will be simulated.
user = UserProxyAgent(
name="user",
human_input_mode="ALWAYS",
is_termination_msg=lambda x: True if "TERMINATE" in x.get("content") else False,
max_consecutive_auto_reply=0,
code_execution_config={
"use_docker": False
},
)

task = """
Here is some information about me:
1. My favorite programming language is Java
2. My hobbies include AI, Drinking, and Futbol
3. My birthday is March 3rd
"""

task_tweet = """
Create an engaging tweet about Java
"""

task_check = """
What day is my birthday?
"""


user.initiate_chat(
teachable_agent,
message=task_tweet,
clear_history=False
)



0 comments on commit 541da52

Please sign in to comment.