sherpa_ai.memory package#
Submodules#
sherpa_ai.memory.belief module#
- class sherpa_ai.memory.belief.Belief[source]#
Bases:
object
- The belief of the agent. it contains
events: the events observed by the agent, synchronized with the shared memory
internal_events: the internal events generated by the agent through its reasoning process (actions)
- property action_description#
- get(key, default=None)[source]#
Get value from the dict, the key can be a dot separated string if the value is nested
- get_action(action_name) BaseAction [source]#
- get_actions() List[BaseAction] [source]#
- get_context(token_counter: Callable[[str], int])[source]#
Get the context of the agent
- Parameters:
token_counter – Token counter
max_tokens – Maximum number of tokens
- Returns:
Context of the agent
- Return type:
str
- get_histories_excluding_types(exclude_types: list[EventType], token_counter: Callable[[str], int] | None = None, max_tokens=4000)[source]#
Get the internal history of the agent without events of excluded_type
- Parameters:
token_counter – Token counter
max_tokens – Maximum number of tokens
exclude_types – List of events to be excluded
- Returns:
Internal history of the agent with event content separated by newlines. History is truncated if the number of tokens exceeds max_tokens.
- Return type:
str
- get_internal_history(token_counter: Callable[[str], int])[source]#
Get the internal history of the agent
- Parameters:
token_counter – Token counter
- Returns:
Internal history of the agent with event content separated by newlines. History is truncated if the number of tokens exceeds max_tokens.
- Return type:
str
- set(key, value)[source]#
Set value in the dict, the key can be a dot separated string if the value is nested
- set_actions(actions: List[BaseAction])[source]#
Module contents#
- class sherpa_ai.memory.Belief[source]#
Bases:
object
- The belief of the agent. it contains
events: the events observed by the agent, synchronized with the shared memory
internal_events: the internal events generated by the agent through its reasoning process (actions)
- property action_description#
- get(key, default=None)[source]#
Get value from the dict, the key can be a dot separated string if the value is nested
- get_action(action_name) BaseAction [source]#
- get_actions() List[BaseAction] [source]#
- get_context(token_counter: Callable[[str], int])[source]#
Get the context of the agent
- Parameters:
token_counter – Token counter
max_tokens – Maximum number of tokens
- Returns:
Context of the agent
- Return type:
str
- get_histories_excluding_types(exclude_types: list[EventType], token_counter: Callable[[str], int] | None = None, max_tokens=4000)[source]#
Get the internal history of the agent without events of excluded_type
- Parameters:
token_counter – Token counter
max_tokens – Maximum number of tokens
exclude_types – List of events to be excluded
- Returns:
Internal history of the agent with event content separated by newlines. History is truncated if the number of tokens exceeds max_tokens.
- Return type:
str
- get_internal_history(token_counter: Callable[[str], int])[source]#
Get the internal history of the agent
- Parameters:
token_counter – Token counter
- Returns:
Internal history of the agent with event content separated by newlines. History is truncated if the number of tokens exceeds max_tokens.
- Return type:
str
- set(key, value)[source]#
Set value in the dict, the key can be a dot separated string if the value is nested
- set_actions(actions: List[BaseAction])[source]#
Bases:
object