Spaces:
Paused
Paused
add retry
Browse files
app.py
CHANGED
@@ -102,12 +102,12 @@ def predict(question, history=[], behavior=[]):
|
|
102 |
return adminInstruct(question, history)
|
103 |
history = ask(question, history, behavior)
|
104 |
response = [(to_md(history[i]),to_md(history[i+1])) for i in range(0,len(history)-1,2)]
|
105 |
-
return "", history, response, None
|
106 |
|
107 |
|
108 |
def retry(question, history=[], behavior=[]):
|
109 |
if len(history)<2:
|
110 |
-
return "", history, [], None
|
111 |
question = history[-2]
|
112 |
history = history[:-2]
|
113 |
return predict(question, history, behavior)
|
@@ -115,12 +115,13 @@ def retry(question, history=[], behavior=[]):
|
|
115 |
|
116 |
def adminInstruct(question, history):
|
117 |
if "download all dialogue" in question:
|
118 |
-
|
|
|
119 |
for dialogue in all_dialogue:
|
120 |
f.write(dialogue + "\n")
|
121 |
response = [(to_md(history[i]),to_md(history[i+1])) for i in range(0,len(history)-1,2)]
|
122 |
-
return "", history, response, gr.File.update(value=
|
123 |
-
return "", history, response, None
|
124 |
|
125 |
|
126 |
with gr.Blocks() as demo:
|
|
|
102 |
return adminInstruct(question, history)
|
103 |
history = ask(question, history, behavior)
|
104 |
response = [(to_md(history[i]),to_md(history[i+1])) for i in range(0,len(history)-1,2)]
|
105 |
+
return "", history, response, gr.File.update(value=None, visible=False)
|
106 |
|
107 |
|
108 |
def retry(question, history=[], behavior=[]):
|
109 |
if len(history)<2:
|
110 |
+
return "", history, [], gr.File.update(value=None, visible=False)
|
111 |
question = history[-2]
|
112 |
history = history[:-2]
|
113 |
return predict(question, history, behavior)
|
|
|
115 |
|
116 |
def adminInstruct(question, history):
|
117 |
if "download all dialogue" in question:
|
118 |
+
filename = f"./all_dialogue_{len(all_dialogue)}.jsonl"
|
119 |
+
with open(filename, "w", encoding="utf-8") as f:
|
120 |
for dialogue in all_dialogue:
|
121 |
f.write(dialogue + "\n")
|
122 |
response = [(to_md(history[i]),to_md(history[i+1])) for i in range(0,len(history)-1,2)]
|
123 |
+
return "", history, response, gr.File.update(value=filename, visible=True)
|
124 |
+
return "", history, response, gr.File.update(value=None, visible=False)
|
125 |
|
126 |
|
127 |
with gr.Blocks() as demo:
|