forked from tylerprogramming/ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new teachable agents code to make it easier to understand
- Loading branch information
1 parent
446d86c
commit 541da52
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
|
||
|
||
|