Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,6 +58,14 @@ client_s = Client(
|
|
58 |
API_URL_S, headers={"Authorization": f"Bearer {HF_TOKEN}"},
|
59 |
)
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
def generate(
|
62 |
prompt,
|
63 |
temperature=0.9,
|
@@ -122,7 +130,7 @@ def generate(
|
|
122 |
#t += 1
|
123 |
previous_token = response.token.text
|
124 |
print("Output = "+str(output))
|
125 |
-
return output.strip()
|
126 |
|
127 |
|
128 |
# chatbot mode
|
|
|
58 |
API_URL_S, headers={"Authorization": f"Bearer {HF_TOKEN}"},
|
59 |
)
|
60 |
|
61 |
+
def wrap_html_code(text):
|
62 |
+
pattern = r"<.*?>"
|
63 |
+
matches = re.findall(pattern, text)
|
64 |
+
if len(matches) > 0:
|
65 |
+
return f"```{text}```"
|
66 |
+
else:
|
67 |
+
return text
|
68 |
+
|
69 |
def generate(
|
70 |
prompt,
|
71 |
temperature=0.9,
|
|
|
130 |
#t += 1
|
131 |
previous_token = response.token.text
|
132 |
print("Output = "+str(output))
|
133 |
+
return wrap_html_code(output.strip())
|
134 |
|
135 |
|
136 |
# chatbot mode
|