Teachability

Teachability(
    verbosity: int | None = 0,
    reset_db: bool | None = False,
    path_to_db_dir: str | None = './tmp/teachable_agent_db',
    recall_threshold: float | None = 1.5,
    max_num_retrievals: int | None = 10,
    llm_config: dict[str, Any] | bool | None = None
)

Teachability uses a vector database to give an agent the ability to remember user teachings, where the user is any caller (human or not) sending messages to the teachable agent.
Teachability is designed to be composable with other agent capabilities.
To make any conversable agent teachable, instantiate both the agent and the Teachability class, then pass the agent to teachability.add_to_agent(agent).
Note that teachable agents in a group chat must be given unique path_to_db_dir values.
When adding Teachability to an agent, the following are modified:
- The agent’s system message is appended with a note about the agent’s new ability.
- A hook is added to the agent’s process_last_received_message hookable method, and the hook potentially modifies the last of the received messages to include earlier teachings related to the message.
Added teachings do not propagate into the stored message history.
If new user teachings are detected, they are added to new memos in the vector database.

Parameters:
NameDescription
verbosityType: int | None

Default: 0
reset_dbType: bool | None

Default: False
path_to_db_dirType: str | None

Default: ’./tmp/teachable_agent_db’
recall_thresholdThe maximum distance for retrieved memos, where 0.0 is exact match.

Default 1.5. Larger values allow more (but less relevant) memos to be recalled.br/>max_num_retrievals (Optional, int): The maximum number of memos to retrieve from the DB.

Default 10.br/>llm_config (dict or False): llm inference configuration passed to TextAnalyzerAgent.br/> If None, TextAnalyzerAgent uses llm_config from the teachable agent.

Type: float | None

Default: 1.5
max_num_retrievalsType: int | None

Default: 10
llm_configType: dict[str, typing.Any] | bool | None

Default: None

Instance Methods

add_to_agent

add_to_agent(self, agent: ConversableAgent) -> 

Adds teachability to the given agent.

Parameters:
NameDescription
agentType: ConversableAgent

prepopulate_db

prepopulate_db(self) -> 

Adds a few arbitrary memos to the DB.


process_last_received_message

process_last_received_message(self, text: dict[str, Any] | str) -> 

Appends any relevant memos to the message text, and stores any apparent teachings in new memos.
Uses TextAnalyzerAgent to make decisions about memo storage and retrieval.

Parameters:
NameDescription
textType: dict[str, typing.Any] | str