Spaces:
Runtime error
Runtime error
update example rendering method
Browse files
app.py
CHANGED
@@ -19,10 +19,10 @@ from openai import OpenAI
|
|
19 |
import base64
|
20 |
|
21 |
|
22 |
-
client = OpenAI(
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
|
27 |
|
28 |
@dataclass
|
@@ -749,7 +749,7 @@ def get_random_problem():
|
|
749 |
def update_example_problem():
|
750 |
problem_example_text = get_random_problem()
|
751 |
problem_example_text_display = (
|
752 |
-
problem_example_text[:100]
|
753 |
)
|
754 |
return problem_example_text_display, problem_example_text
|
755 |
|
@@ -787,12 +787,10 @@ with gr.Blocks(css=css, title="Math Olympiad Solver") as demo:
|
|
787 |
)
|
788 |
copy_btn = gr.Button("Copy", elem_classes="probelm-example-copy")
|
789 |
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
elem_classes="probelm-example-content",
|
795 |
-
)
|
796 |
|
797 |
with gr.Row(elem_classes="probelm-input-container"):
|
798 |
inp = gr.Textbox(placeholder="Problem", label="Problem input", lines=5, visible=True)
|
@@ -831,11 +829,15 @@ with gr.Blocks(css=css, title="Math Olympiad Solver") as demo:
|
|
831 |
|
832 |
def solve_problem_wrapper(inp_text, temperature):
|
833 |
global running_success
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
|
|
|
|
|
|
|
|
839 |
|
840 |
def mount_run_btn(btn):
|
841 |
btn.click(fn=solve_problem_wrapper, inputs=[inp, temperature], outputs=out)
|
|
|
19 |
import base64
|
20 |
|
21 |
|
22 |
+
# client = OpenAI(
|
23 |
+
# base_url=os.environ.get("SERVER_URL"),
|
24 |
+
# api_key=os.environ.get("HF_TOKEN"),
|
25 |
+
# )
|
26 |
|
27 |
|
28 |
@dataclass
|
|
|
749 |
def update_example_problem():
|
750 |
problem_example_text = get_random_problem()
|
751 |
problem_example_text_display = (
|
752 |
+
problem_example_text[:100] if len(problem_example_text) > 100 else problem_example_text
|
753 |
)
|
754 |
return problem_example_text_display, problem_example_text
|
755 |
|
|
|
787 |
)
|
788 |
copy_btn = gr.Button("Copy", elem_classes="probelm-example-copy")
|
789 |
|
790 |
+
problem_example = gr.HTML(
|
791 |
+
problem_example_text_display,
|
792 |
+
elem_classes="probelm-example-content",
|
793 |
+
)
|
|
|
|
|
794 |
|
795 |
with gr.Row(elem_classes="probelm-input-container"):
|
796 |
inp = gr.Textbox(placeholder="Problem", label="Problem input", lines=5, visible=True)
|
|
|
829 |
|
830 |
def solve_problem_wrapper(inp_text, temperature):
|
831 |
global running_success
|
832 |
+
try:
|
833 |
+
for token, stop in solve_problem(inp_text, temperature):
|
834 |
+
yield token
|
835 |
+
|
836 |
+
if stop:
|
837 |
+
running_success = True
|
838 |
+
except Exception as e:
|
839 |
+
running_success = True
|
840 |
+
raise e
|
841 |
|
842 |
def mount_run_btn(btn):
|
843 |
btn.click(fn=solve_problem_wrapper, inputs=[inp, temperature], outputs=out)
|