Spaces:
Running
Running
Commit
·
1b98339
1
Parent(s):
36d0e0c
Upload app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,22 @@ from PIL import Image
|
|
| 12 |
import gradio
|
| 13 |
import markdown
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
def get_response(system, context, myKey, raw = False):
|
| 16 |
openai.api_key = myKey
|
| 17 |
response = openai.ChatCompletion.create(
|
|
|
|
| 12 |
import gradio
|
| 13 |
import markdown
|
| 14 |
|
| 15 |
+
def parse_text(text):
|
| 16 |
+
lines = text.split("\n")
|
| 17 |
+
for i,line in enumerate(lines):
|
| 18 |
+
if "```" in line:
|
| 19 |
+
items = line.split('`')
|
| 20 |
+
if items[-1]:
|
| 21 |
+
lines[i] = f'<pre><code class="{items[-1]}">'
|
| 22 |
+
else:
|
| 23 |
+
lines[i] = f'</code></pre>'
|
| 24 |
+
else:
|
| 25 |
+
if i>0:
|
| 26 |
+
line = line.replace("<", "<")
|
| 27 |
+
line = line.replace(">", ">")
|
| 28 |
+
lines[i] = '<br/>'+line.replace(" ", " ")
|
| 29 |
+
return "".join(lines)
|
| 30 |
+
|
| 31 |
def get_response(system, context, myKey, raw = False):
|
| 32 |
openai.api_key = myKey
|
| 33 |
response = openai.ChatCompletion.create(
|