Spaces:
Build error
Build error
XThomasBU
commited on
Commit
·
f21709c
1
Parent(s):
e165ea5
updates
Browse files
code/modules/chat/langchain/utils.py
CHANGED
|
@@ -184,7 +184,9 @@ class CustomRunnableWithHistory(RunnableWithMessageHistory):
|
|
| 184 |
)
|
| 185 |
return buffer
|
| 186 |
|
| 187 |
-
def
|
|
|
|
|
|
|
| 188 |
"""
|
| 189 |
Get the last k conversations from the message history.
|
| 190 |
|
|
@@ -200,11 +202,14 @@ class CustomRunnableWithHistory(RunnableWithMessageHistory):
|
|
| 200 |
print("\n\n\n")
|
| 201 |
print("Hist: ", hist)
|
| 202 |
print("\n\n\n")
|
| 203 |
-
messages = hist.
|
| 204 |
|
| 205 |
if not self.history_messages_key:
|
| 206 |
# return all messages
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
# return last k conversations
|
| 210 |
if config["configurable"]["memory_window"] == 0: # if k is 0, return empty list
|
|
|
|
| 184 |
)
|
| 185 |
return buffer
|
| 186 |
|
| 187 |
+
async def _aenter_history(
|
| 188 |
+
self, input: Any, config: RunnableConfig
|
| 189 |
+
) -> List[BaseMessage]:
|
| 190 |
"""
|
| 191 |
Get the last k conversations from the message history.
|
| 192 |
|
|
|
|
| 202 |
print("\n\n\n")
|
| 203 |
print("Hist: ", hist)
|
| 204 |
print("\n\n\n")
|
| 205 |
+
messages = (await hist.aget_messages()).copy()
|
| 206 |
|
| 207 |
if not self.history_messages_key:
|
| 208 |
# return all messages
|
| 209 |
+
input_val = (
|
| 210 |
+
input if not self.input_messages_key else input[self.input_messages_key]
|
| 211 |
+
)
|
| 212 |
+
messages += self._get_input_messages(input_val)
|
| 213 |
|
| 214 |
# return last k conversations
|
| 215 |
if config["configurable"]["memory_window"] == 0: # if k is 0, return empty list
|