Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -41,9 +41,9 @@ if UseMemory:
|
|
41 |
def store_message(name: str, message: str):
|
42 |
if name and message:
|
43 |
with open(DATA_FILE, "a") as csvfile:
|
44 |
-
writer = csv.DictWriter(csvfile, fieldnames=["
|
45 |
writer.writerow(
|
46 |
-
{"
|
47 |
)
|
48 |
# uncomment line below to begin saving. If creating your own copy you will need to add a access token called "HF_TOKEN" to your profile, then create a secret for your repo with the access code naming it "HF_TOKEN" For the CSV as well you can copy the header and first few lines to your own then update the paths above which should work to save to your own repository for datasets.
|
49 |
commit_url = repo.push_to_hub()
|
@@ -62,12 +62,6 @@ def take_last_tokens(inputs, note_history, history):
|
|
62 |
history = history[1:]
|
63 |
return inputs, note_history, history
|
64 |
|
65 |
-
def add_note_to_history(note, note_history):
|
66 |
-
"""Add a note to the historical information"""
|
67 |
-
note_history.append(note)
|
68 |
-
note_history = '</s> <s>'.join(note_history)
|
69 |
-
return [note_history]
|
70 |
-
|
71 |
|
72 |
title = "💬ChatBack🧠💾"
|
73 |
description = """Chatbot With persistent memory dataset allowing multiagent system AI to access a shared dataset as memory pool with stored interactions.
|
@@ -88,13 +82,9 @@ def chat(message, history):
|
|
88 |
history_useful = add_note_to_history(response, history_useful)
|
89 |
list_history = history_useful[0].split('</s> <s>')
|
90 |
history.append((list_history[-2], list_history[-1]))
|
91 |
-
|
92 |
-
# AGI semantic and episodic memory here we come....
|
93 |
|
94 |
store_message(message, response) # Save to dataset -- uncomment with code above, create a dataset to store and add your HF_TOKEN from profile to this repo to use.
|
95 |
|
96 |
-
# ....
|
97 |
-
|
98 |
return history, history
|
99 |
|
100 |
|
|
|
41 |
def store_message(name: str, message: str):
|
42 |
if name and message:
|
43 |
with open(DATA_FILE, "a") as csvfile:
|
44 |
+
writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
|
45 |
writer.writerow(
|
46 |
+
{"time": str(datetime.now(), "message": message.strip(), "name": name.strip(), )}
|
47 |
)
|
48 |
# uncomment line below to begin saving. If creating your own copy you will need to add a access token called "HF_TOKEN" to your profile, then create a secret for your repo with the access code naming it "HF_TOKEN" For the CSV as well you can copy the header and first few lines to your own then update the paths above which should work to save to your own repository for datasets.
|
49 |
commit_url = repo.push_to_hub()
|
|
|
62 |
history = history[1:]
|
63 |
return inputs, note_history, history
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
title = "💬ChatBack🧠💾"
|
67 |
description = """Chatbot With persistent memory dataset allowing multiagent system AI to access a shared dataset as memory pool with stored interactions.
|
|
|
82 |
history_useful = add_note_to_history(response, history_useful)
|
83 |
list_history = history_useful[0].split('</s> <s>')
|
84 |
history.append((list_history[-2], list_history[-1]))
|
|
|
|
|
85 |
|
86 |
store_message(message, response) # Save to dataset -- uncomment with code above, create a dataset to store and add your HF_TOKEN from profile to this repo to use.
|
87 |
|
|
|
|
|
88 |
return history, history
|
89 |
|
90 |
|