Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -80,16 +80,7 @@ def generate_html() -> str:
|
|
80 |
html += "</div>"
|
81 |
return html
|
82 |
|
83 |
-
|
84 |
-
if name and message:
|
85 |
-
with open(DATA_FILE, "a") as csvfile:
|
86 |
-
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
87 |
-
writer.writerow(
|
88 |
-
{"name": name, "message": message, "time": str(datetime.now())}
|
89 |
-
)
|
90 |
-
commit_url = repo.push_to_hub()
|
91 |
-
return {"name": name, "message": message, "time": str(datetime.now())}
|
92 |
-
|
93 |
iface = gr.Interface(
|
94 |
persist_memory,
|
95 |
[
|
@@ -133,15 +124,29 @@ generator3 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=HF_TOK
|
|
133 |
#MemoryChange=tbOutput.change(persist_memory,inputs=[tbOutput],outputs=gr.Textbox(label="PersistMemoryOutput"))
|
134 |
SplitterInputBox = gr.inputs.Textbox(lines=5, label="Enter a sentence to get another sentence.")
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
tbMemoryOutput = gr.Textbox(label="Memory Output")
|
147 |
btnSave = gr.Button("Save")
|
|
|
80 |
html += "</div>"
|
81 |
return html
|
82 |
|
83 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
iface = gr.Interface(
|
85 |
persist_memory,
|
86 |
[
|
|
|
124 |
#MemoryChange=tbOutput.change(persist_memory,inputs=[tbOutput],outputs=gr.Textbox(label="PersistMemoryOutput"))
|
125 |
SplitterInputBox = gr.inputs.Textbox(lines=5, label="Enter a sentence to get another sentence.")
|
126 |
|
127 |
+
def persist_memory(name: str, message: str):
|
128 |
+
if name and message:
|
129 |
+
with open(DATA_FILE, "a") as csvfile:
|
130 |
+
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
131 |
+
writer.writerow({"name": name, "message": message, "time": str(datetime.now())})
|
132 |
+
commit_url = repo.push_to_hub()
|
133 |
+
return {"name": name, "message": message, "time": str(datetime.now())}
|
134 |
+
|
135 |
+
with gradio.Blocks() as Memory:
|
136 |
+
|
137 |
+
#parallelModel = gr.Parallel(generator1, generator2, generator3, inputs = SplitterInputBox, examples=examples,
|
138 |
+
# title="Mindfulness Story Generation with Persistent Dataset Memory",
|
139 |
+
# description=f"Mindfulness Story Generation with Persistent Dataset Memory",
|
140 |
+
# article=f"Memory Dataset URL: [{DATASET_REPO_URL}]({DATASET_REPO_URL})" )
|
141 |
+
|
142 |
+
gr.Markdown("Mindfulness Story Generation with Persistent Dataset Memory")
|
143 |
+
with gr.Row():
|
144 |
+
inp = gr.Textbox(placeholder="What text would you like to extend with generation?")
|
145 |
+
out = gr.Textbox()
|
146 |
+
btn = gr.Button("Run")
|
147 |
+
btn.click(fn=persist_memory, inputs=inp, outputs=out)
|
148 |
+
|
149 |
+
Memory.launch()
|
150 |
|
151 |
tbMemoryOutput = gr.Textbox(label="Memory Output")
|
152 |
btnSave = gr.Button("Save")
|