Spaces:
Paused
Paused
add retry
Browse files
app.py
CHANGED
|
@@ -81,8 +81,11 @@ def to_md(content):
|
|
| 81 |
count_backtick = 0
|
| 82 |
output_spans = []
|
| 83 |
for i in range(len(content)):
|
| 84 |
-
if content[i]=="\n"
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
| 86 |
elif content[i]=="`":
|
| 87 |
count_backtick += 1
|
| 88 |
if count_backtick == 3:
|
|
@@ -96,7 +99,7 @@ def to_md(content):
|
|
| 96 |
|
| 97 |
def predict(question, history=[], behavior=[]):
|
| 98 |
if question.startswith(f"{openai.api_key}:"):
|
| 99 |
-
return adminInstruct(question)
|
| 100 |
history = ask(question, history, behavior)
|
| 101 |
response = [(to_md(history[i]),to_md(history[i+1])) for i in range(0,len(history)-1,2)]
|
| 102 |
return "", history, response, None
|
|
@@ -105,13 +108,13 @@ def predict(question, history=[], behavior=[]):
|
|
| 105 |
def retry(question, history=[], behavior=[]):
|
| 106 |
if len(history)<2:
|
| 107 |
return "", history, [], None
|
| 108 |
-
question = history[-
|
| 109 |
history = history[:-2]
|
| 110 |
return predict(question, history, behavior)
|
| 111 |
|
| 112 |
|
| 113 |
-
def adminInstruct(question):
|
| 114 |
-
if "download
|
| 115 |
with open("./all_dialogue.jsonl", "w", encoding="utf-8") as f:
|
| 116 |
for dialogue in all_dialogue:
|
| 117 |
f.write(dialogue + "\n")
|
|
|
|
| 81 |
count_backtick = 0
|
| 82 |
output_spans = []
|
| 83 |
for i in range(len(content)):
|
| 84 |
+
if content[i]=="\n":
|
| 85 |
+
if not is_inside_code_block:
|
| 86 |
+
output_spans.append("<br>")
|
| 87 |
+
else:
|
| 88 |
+
output_spans.append("\n\n")
|
| 89 |
elif content[i]=="`":
|
| 90 |
count_backtick += 1
|
| 91 |
if count_backtick == 3:
|
|
|
|
| 99 |
|
| 100 |
def predict(question, history=[], behavior=[]):
|
| 101 |
if question.startswith(f"{openai.api_key}:"):
|
| 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
|
|
|
|
| 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)
|
| 114 |
|
| 115 |
|
| 116 |
+
def adminInstruct(question, history):
|
| 117 |
+
if "download all dialogue" in question:
|
| 118 |
with open("./all_dialogue.jsonl", "w", encoding="utf-8") as f:
|
| 119 |
for dialogue in all_dialogue:
|
| 120 |
f.write(dialogue + "\n")
|