working_memory
WorkingMemory
Bases: BaseModelDict
Represents the volatile memory of a cat, functioning similarly to a dictionary to store temporary custom data.
Attributes:
Name | Type | Description |
---|---|---|
history |
List[HistoryMessage]
|
A list that maintains the conversation history between the Human and the AI. |
user_message_json |
Optional[UserMessage], default=None
|
An optional UserMessage object representing the last user message. |
active_form |
Optional[CatForm], default=None
|
An optional reference to a CatForm currently in use. |
recall_query |
str, default=""
|
A string that stores the last recall query. |
episodic_memories |
List
|
A list for storing episodic memories. |
declarative_memories |
List
|
A list for storing declarative memories. |
procedural_memories |
List
|
A list for storing procedural memories. |
model_interactions |
List[ModelInteraction]
|
A list of interactions with models. |
Source code in cat/memory/working_memory.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
langchainfy_chat_history(latest_n=10)
Convert chat history in working memory to langchain objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
latest_n
|
int
|
How many latest turns to convert. |
10
|
Returns:
Name | Type | Description |
---|---|---|
history |
List[BaseMessage]
|
List of langchain HumanMessage / AIMessage. |
Source code in cat/memory/working_memory.py
stringify_chat_history(latest_n=10)
Serialize chat history. Converts to text the recent conversation turns. Useful for retrocompatibility with old non-chat models, and to easily insert convo into a prompt without using dedicated objects and libraries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
latest_n
|
int
|
How many latest turns to stringify. |
10
|
Returns:
Name | Type | Description |
---|---|---|
history |
str
|
String with recent conversation turns. |
Source code in cat/memory/working_memory.py
update_conversation_history(message, who, why={})
This method is deprecated. Use update_history
instead.
Updates the conversation history with the most recent message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The text content of the message. |
required |
who
|
str
|
The name of the message author. |
required |
why
|
Optional[Dict[str, Any]]
|
Optional explanation for the message. |
None
|
Notes
This method is deprecated and will be removed in future versions. Use update_history
instead.
Source code in cat/memory/working_memory.py
update_history(message)
Adds a message to the history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
ConversationMessage
|
The message, must be of type |
required |