Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,11 +58,16 @@ def getstuff(openapikey,category_selector):
|
|
58 |
)
|
59 |
print(response.response)
|
60 |
if 'dataframe' in querylist[i]:
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
66 |
answerlist.append(df)
|
67 |
else:
|
68 |
answerlist.append(response.response)
|
@@ -80,7 +85,7 @@ with gr.Blocks() as demo:
|
|
80 |
with gr.Column():
|
81 |
textboxopenapi = gr.Textbox(placeholder="Enter OpenAPI Key...", lines=1,label='OpenAPI Key')
|
82 |
category_selector=gr.Dropdown(
|
83 |
-
listofcategories, label="Options", info="Select the snapshot you want..."
|
84 |
)
|
85 |
with gr.Column():
|
86 |
btn = gr.Button("Generate \nSnapshot")
|
|
|
58 |
)
|
59 |
print(response.response)
|
60 |
if 'dataframe' in querylist[i]:
|
61 |
+
try:
|
62 |
+
pattern = regex.compile(r'\{(?:[^{}]|(?R))*\}')
|
63 |
+
jsonextract=pattern.findall(response.response)[0]
|
64 |
+
#print("json extract\n",jsonextract)
|
65 |
+
df_tmp=pd.read_json(jsonextract)
|
66 |
+
df=pd.DataFrame(df_tmp[df_tmp.columns[0]].tolist())
|
67 |
+
except:
|
68 |
+
df=pd.DataFrame()
|
69 |
+
df['message']=['Data insufficient to decipher']
|
70 |
+
df['action']=['try again in a few hours']
|
71 |
answerlist.append(df)
|
72 |
else:
|
73 |
answerlist.append(response.response)
|
|
|
85 |
with gr.Column():
|
86 |
textboxopenapi = gr.Textbox(placeholder="Enter OpenAPI Key...", lines=1,label='OpenAPI Key')
|
87 |
category_selector=gr.Dropdown(
|
88 |
+
listofcategories, label="Sector Options", info="Select the snapshot you want..."
|
89 |
)
|
90 |
with gr.Column():
|
91 |
btn = gr.Button("Generate \nSnapshot")
|