Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,21 @@ def ask_bot(prompt):
|
|
43 |
message = ""
|
44 |
for data in chatbot.ask(prompt):
|
45 |
message = data["message"]
|
46 |
-
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
def chatgpt_clone(inputs, history):
|
49 |
history = history or []
|
|
|
43 |
message = ""
|
44 |
for data in chatbot.ask(prompt):
|
45 |
message = data["message"]
|
46 |
+
return parse_text(message)
|
47 |
+
|
48 |
+
def parse_text(text):
|
49 |
+
lines = text.split("\n")
|
50 |
+
for i,line in enumerate(lines):
|
51 |
+
if "```" in line:
|
52 |
+
items = line.split('`')
|
53 |
+
if items[-1]:
|
54 |
+
lines[i] = f'<pre><code class="{items[-1]}">'
|
55 |
+
else:
|
56 |
+
lines[i] = f'</code></pre>'
|
57 |
+
else:
|
58 |
+
if i>0:
|
59 |
+
lines[i] = '<br/>'+line.replace(" ", " ")
|
60 |
+
return "".join(lines)
|
61 |
|
62 |
def chatgpt_clone(inputs, history):
|
63 |
history = history or []
|