Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -160,7 +160,9 @@ async def __remove_temp(request):
|
|
160 |
return PlainTextResponse("", 200)
|
161 |
|
162 |
async def __convert_text(input, type_out="plain", type_in="html"):
|
163 |
-
|
|
|
|
|
164 |
# Create a subprocess
|
165 |
process = await asyncio.create_subprocess_exec(
|
166 |
# command to execute
|
@@ -626,6 +628,9 @@ async def llm_generate_text(request):
|
|
626 |
timeout=None)
|
627 |
|
628 |
try:
|
|
|
|
|
|
|
629 |
repl = _r.json()['choices'][0]['message']['content']
|
630 |
# input, type_out="plain", type_in="html"
|
631 |
repl = await __convert_text(repl, "html-raw_html", "markdown")
|
|
|
160 |
return PlainTextResponse("", 200)
|
161 |
|
162 |
async def __convert_text(input, type_out="plain", type_in="html"):
|
163 |
+
if (not input):
|
164 |
+
app_logger.info("__convert_text: nothing to convert!")
|
165 |
+
return ""
|
166 |
# Create a subprocess
|
167 |
process = await asyncio.create_subprocess_exec(
|
168 |
# command to execute
|
|
|
628 |
timeout=None)
|
629 |
|
630 |
try:
|
631 |
+
if _r.status_code != 200:
|
632 |
+
raise HTTPException(status_code=429, detail=str(_r.json()))
|
633 |
+
|
634 |
repl = _r.json()['choices'][0]['message']['content']
|
635 |
# input, type_out="plain", type_in="html"
|
636 |
repl = await __convert_text(repl, "html-raw_html", "markdown")
|