GetMemory

Returns a list of actions (including but not limited to the messages). Currently, it only returns actions that have reference_idn: user_message and agent_message.

NOTE: The GetMemory action will only return memory of the project agent in which this action is executed. For example main conversation of user and AI Agent will be in naf.ConvoAgent and if you use GetMemory in your_project.ExampleAgent.CustomFlow.MySkill then it will only return memory available to your ExampleAgent. To get around that you can subscribe your skill to the event broadcast_analyze_conversation.

GetMemory(
  fromPerson: Literal["User", "Agent", "Both"] = "Both",
  offset: int = 0,
  count: int = 10,
  maxLen: int = 200,
  asEnglishText: bool = False,
  summarize: bool = False,
  fromDate: datetime | None = None,
  toDate: datetime | None = None,
  filterByActorIds: list[UUID] | None = None,
  filterByUserPersonaIds: list[UUID] | None = None,
  sessionId: UUID | None = None
)

Where:

ParameterTypeDefaultDescription
fromPersonLiteral["User", "Agent", "Both"]"Both"Indicates what persona the memory should be sourced from.
offsetint0Offsets where the start of the pulled memory begins. In other words, offset is used when wanting to skip a certain number of the latest dialogue turns.
countint10The number of conversational turns.
maxLenint200The maximum number of characters.
asEnglishTextboolFalseConverts any foreign language text into English. Set "true" to activate.
summarizeboolFalseSummarizes the memory. Set "true" to activate.
fromDatedatetime | NoneNoneFilters start of turns and accepts ISO-8601 format.
toDatedatetime | NoneNoneFilters end of turns and accepts ISO-8601 format.
filterByActorIdslist[UUID] | NoneNoneFilters the memory based on Actor IDs and shows only that memory.
filterByUserPersonaIdslist[UUID] | NoneNoneFilters the memory based on Persona IDs and shows only that memory.
sessionIdUUID | NoneNoneThe session identifier to filter memory by.

If filterByActorIds is set, the context user_persona_id and filterByUserPersonaIds parameters are ignored. If the filterByUserPersonaIds parameter is set, the context user_persona_id parameter is ignored.

Example 1 (Filter by Actor IDs)

This example uses the GetMemory command to get conversations of an Agent and User. Adjust the GetMemory parameters according to your needs.

{% set user_id = GetUser().id | string %}

{% set newo_voice_actors = GetActors(
    personaId=user_id,
    integrationIdn="newo_voice"
) %}

{% set newo_chat_actors = GetActors(
    personaId=user_id,
    integrationIdn="newo_chat"
) %}


{% set actors = newo_voice_actors + newo_chat_actors %}

{{Return(val=GetMemory(filterByActorIds=actors))}}
User: How are you?  
ConvoAgent: I'm fine!  
User: Tell me about yourself.  
ConvoAgent: I'm an AI assistant.

Example 2 (Foreign Language to English)

This example gets the memory and translates any foreign language text into English. This was tested by sending the foreign language (Afrikaans) message, "Hello hoe gaan dit?"

{{Return(val=GetMemory(asEnglishText="True"))}}
User: Hello how are you?

Example 3 (Offset)

If you need to skip a certain number of the most recent dialogue turns from the top, use the offset parameter. For example, offset=2 skips the 2 latest turns and begins returning memory starting from the 3rd most recent turn.

{{Return(val=GetMemory(offset=2, count=10))}}
User: How are you?  
ConvoAgent: I'm fine!