-
Notifications
You must be signed in to change notification settings - Fork 3
Context Injection
David-Andrew Samson edited this page May 15, 2023
·
9 revisions
While interacting with the LLM react agent, it is possible to inject context messages into the chat history. Context messages are very flexible and can be used in a number of different ways:
- providing the agent with information about the current state of a tool
- (etc/todo)
Context can be created by calling one of the add_context methods on the agent
agent = ReActAgent(...)
# add permanent context
id = agent.add_context("some context message")
# add timed context
id = agent.add_timed_context("some message that will be deleted after 1 step")
id = agent.add_timed_context("some message that will be deleted after n steps", n)Timed context messages are automatically deleted from the chat after the specified number of steps (default of 1), or you can manually delete them before the time expires
Context can be removed via the remove_context function given the message's id
agent.delete_context(id)