Spaces:
Runtime error
Runtime error
Update process.py
Browse files- process.py +12 -6
process.py
CHANGED
@@ -74,17 +74,23 @@ def analyze_post(post):
|
|
74 |
|
75 |
result = agent.send_post(post)
|
76 |
print(result)
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
83 |
return final
|
84 |
|
85 |
|
86 |
|
87 |
def generate_image(final):
|
|
|
|
|
|
|
88 |
# 初始化画布和坐标轴
|
89 |
fig, ax = plt.subplots(figsize=(6, 6))
|
90 |
|
|
|
74 |
|
75 |
result = agent.send_post(post)
|
76 |
print(result)
|
77 |
+
try:
|
78 |
+
data = json.loads(result)
|
79 |
+
final = {"J_P":0 ,"T_F":0, "S_N":0, "E_I": 0 }
|
80 |
+
final['E_I'] = 100 - data["Extrovert-Introvert"]["score"]
|
81 |
+
final['S_N'] = 100 - data["Sensing-Intuition"]["score"]
|
82 |
+
final["T_F"] = 100 - data["Thinking-Feeling"]["score"]
|
83 |
+
final["J_P"] = 100 - data["Judging-Perceiving"]["score"]
|
84 |
+
except:
|
85 |
+
final = {}
|
86 |
return final
|
87 |
|
88 |
|
89 |
|
90 |
def generate_image(final):
|
91 |
+
if final == {}:
|
92 |
+
st.write("I have no idea about it. Please provide more information")
|
93 |
+
return
|
94 |
# 初始化画布和坐标轴
|
95 |
fig, ax = plt.subplots(figsize=(6, 6))
|
96 |
|