Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import openai
|
|
8 |
import datetime
|
9 |
from datetime import datetime, date, time, timedelta
|
10 |
import os
|
|
|
11 |
|
12 |
listofcategories=["Earnings Announcements", "Automotive", "Retail"]
|
13 |
|
@@ -49,7 +50,10 @@ def getstuff(openapikey,category_selector):
|
|
49 |
)
|
50 |
print(response.response)
|
51 |
if 'dataframe' in querylist[i]:
|
52 |
-
|
|
|
|
|
|
|
53 |
df=pd.DataFrame(df_tmp[df_tmp.columns[0]].tolist())
|
54 |
answerlist.append(df)
|
55 |
else:
|
|
|
8 |
import datetime
|
9 |
from datetime import datetime, date, time, timedelta
|
10 |
import os
|
11 |
+
import regex
|
12 |
|
13 |
listofcategories=["Earnings Announcements", "Automotive", "Retail"]
|
14 |
|
|
|
50 |
)
|
51 |
print(response.response)
|
52 |
if 'dataframe' in querylist[i]:
|
53 |
+
pattern = regex.compile(r'\{(?:[^{}]|(?R))*\}')
|
54 |
+
jsonextract=pattern.findall(response.response)[0]
|
55 |
+
print("json extract\n",jsonextract)
|
56 |
+
df_tmp=pd.read_json(jsonextract)
|
57 |
df=pd.DataFrame(df_tmp[df_tmp.columns[0]].tolist())
|
58 |
answerlist.append(df)
|
59 |
else:
|