Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
28b893e
1
Parent(s):
2b63412
handle apperror
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_client import Client
|
|
|
|
| 3 |
import frontmatter
|
| 4 |
import os
|
| 5 |
import spaces
|
|
@@ -32,10 +33,15 @@ examples = [
|
|
| 32 |
# "input": "```\n_BOOL8 __fastcall sub_409B9A(_QWORD *a1, _QWORD *a2)\n{\nreturn *a1 < *a2 || *a1 == *a2 && a1[1] < a2[1];\n}\n```\nWhat are the variable name and type for the following memory accesses:a1, a1[1], a2, a2[1]?\n",
|
| 33 |
# "output": "a1: a, os_reltime* -> sec, os_time_t\na1[1]: a, os_reltime* -> usec, os_time_t\na2: b, os_reltime* -> sec, os_time_t\na2[1]: b, os_reltime* -> usec, os_time_t",
|
| 34 |
def field_prompt(code):
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
print(f"field helper result: {field_helper_result}")
|
| 40 |
|
| 41 |
fields = sorted([e['expr'] for e in field_helper_result[0] if e['expr'] != ''])
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_client import Client
|
| 3 |
+
from gradio_client.exceptions import AppError
|
| 4 |
import frontmatter
|
| 5 |
import os
|
| 6 |
import spaces
|
|
|
|
| 33 |
# "input": "```\n_BOOL8 __fastcall sub_409B9A(_QWORD *a1, _QWORD *a2)\n{\nreturn *a1 < *a2 || *a1 == *a2 && a1[1] < a2[1];\n}\n```\nWhat are the variable name and type for the following memory accesses:a1, a1[1], a2, a2[1]?\n",
|
| 34 |
# "output": "a1: a, os_reltime* -> sec, os_time_t\na1[1]: a, os_reltime* -> usec, os_time_t\na2: b, os_reltime* -> sec, os_time_t\na2[1]: b, os_reltime* -> usec, os_time_t",
|
| 35 |
def field_prompt(code):
|
| 36 |
+
try:
|
| 37 |
+
field_helper_result = gradio_client.predict(
|
| 38 |
+
decompiled_code=code,
|
| 39 |
+
api_name="/predict",
|
| 40 |
+
)
|
| 41 |
+
except AppError as e:
|
| 42 |
+
print(f"AppError: {e}")
|
| 43 |
+
return None, [], None
|
| 44 |
+
|
| 45 |
print(f"field helper result: {field_helper_result}")
|
| 46 |
|
| 47 |
fields = sorted([e['expr'] for e in field_helper_result[0] if e['expr'] != ''])
|