Skip to content

Commit f46f1d2

Browse files
authored
expose memory key name (#808)
1 parent 7728a84 commit f46f1d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

langchain/chains/conversation/memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,20 @@ class ConversationEntityMemory(Memory, BaseModel):
230230
llm: BaseLLM
231231
entity_extraction_prompt: BasePromptTemplate = ENTITY_EXTRACTION_PROMPT
232232
entity_summarization_prompt: BasePromptTemplate = ENTITY_SUMMARIZATION_PROMPT
233-
memory_keys: List[str] = ["entities", "history"] #: :meta private:
234233
output_key: Optional[str] = None
235234
input_key: Optional[str] = None
236235
store: Dict[str, Optional[str]] = {}
237236
entity_cache: List[str] = []
238237
k: int = 3
238+
chat_history_key: str = "history"
239239

240240
@property
241241
def memory_variables(self) -> List[str]:
242242
"""Will always return list of memory variables.
243243
244244
:meta private:
245245
"""
246-
return ["entities", "history"]
246+
return ["entities", self.chat_history_key]
247247

248248
def load_memory_variables(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
249249
"""Return history buffer."""
@@ -265,7 +265,7 @@ def load_memory_variables(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
265265
entity_summaries[entity] = self.store.get(entity, "")
266266
self.entity_cache = entities
267267
return {
268-
"history": "\n".join(self.buffer[-self.k :]),
268+
self.chat_history_key: "\n".join(self.buffer[-self.k :]),
269269
"entities": entity_summaries,
270270
}
271271

0 commit comments

Comments
 (0)