Spaces:
Runtime error
Runtime error
Update latex syntax
Browse files
app.py
CHANGED
@@ -538,7 +538,7 @@ def generate(message, temperature):
|
|
538 |
model="tgi",
|
539 |
messages=message,
|
540 |
stream=True,
|
541 |
-
max_tokens=
|
542 |
stop=["```output\n"],
|
543 |
temperature=temperature,
|
544 |
)
|
@@ -550,14 +550,17 @@ def generate(message, temperature):
|
|
550 |
for chunk in response.iter_bytes():
|
551 |
chunk = chunk.decode("utf-8")
|
552 |
chune_json = json.loads(chunk.replace("data:", ""))
|
|
|
|
|
|
|
|
|
553 |
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
yield content, False
|
561 |
|
562 |
|
563 |
def get_majority_text(data):
|
@@ -717,7 +720,7 @@ with gr.Blocks(css=".top-margin { margin-top: 20px; }") as demo:
|
|
717 |
with gr.Accordion("Advanced Options", open=False):
|
718 |
temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.1, step=0.1, label="Temperature")
|
719 |
with gr.Row():
|
720 |
-
out = gr.Markdown(elem_classes=["top-margin"])
|
721 |
|
722 |
btn = gr.Button("Run")
|
723 |
|
|
|
538 |
model="tgi",
|
539 |
messages=message,
|
540 |
stream=True,
|
541 |
+
max_tokens=768,
|
542 |
stop=["```output\n"],
|
543 |
temperature=temperature,
|
544 |
)
|
|
|
550 |
for chunk in response.iter_bytes():
|
551 |
chunk = chunk.decode("utf-8")
|
552 |
chune_json = json.loads(chunk.replace("data:", ""))
|
553 |
+
try:
|
554 |
+
if "error" in chune_json and chune_json["error"]:
|
555 |
+
yield chune_json["error"], True
|
556 |
+
break
|
557 |
|
558 |
+
content = chune_json["choices"][0]["delta"]["content"]
|
559 |
+
if content is not None:
|
560 |
+
yield content, False
|
561 |
+
except Exception as e:
|
562 |
+
print(f"func: generate error occurred\njson:{chune_json}\nerror:{e}")
|
563 |
+
yield "", True
|
|
|
564 |
|
565 |
|
566 |
def get_majority_text(data):
|
|
|
720 |
with gr.Accordion("Advanced Options", open=False):
|
721 |
temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.1, step=0.1, label="Temperature")
|
722 |
with gr.Row():
|
723 |
+
out = gr.Markdown(elem_classes=["top-margin"], latex_delimiters=[{"left": "[", "right": "]", "display": True}])
|
724 |
|
725 |
btn = gr.Button("Run")
|
726 |
|