beta v0.99 fix bug...
Browse files把萬一是 openAI key 有問題,將問題輸出到結果視窗!
app.py
CHANGED
@@ -378,13 +378,18 @@ def get_advice(API_KEY, model="gpt-3.5-turbo-16k"):
|
|
378 |
# {"role": "user", "content": f'我的人格特質以紫微斗數星象來推論是“{gw_main_star}”. 請替我依照這些人格特質,並根據 16 Personality Factors 人格分析工具,一條一條的幫我分析?'},]
|
379 |
# {"role": "user", "content": f'我的人格特質以紫微斗數星象來推論是“{gw_main_star}”. 請替我依照這些人格特質,並根據 OCEAN 五大人格分析系統,一條一條的幫我分析?'},]
|
380 |
{"role": "user", "content": f'此用戶是{pssex}性,依據生辰推測的人格特質是“{gw_main_star}“。\n\n請給他一些待人處事的建議?'},]
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
|
|
|
|
|
|
|
|
|
|
388 |
returndata = '紫微斗數全書上面說:\n\n' + msum + '\n\n' + response.choices[0].message.content
|
389 |
if API_KEY:
|
390 |
ming_feedback.info = 'YES'
|
|
|
378 |
# {"role": "user", "content": f'我的人格特質以紫微斗數星象來推論是“{gw_main_star}”. 請替我依照這些人格特質,並根據 16 Personality Factors 人格分析工具,一條一條的幫我分析?'},]
|
379 |
# {"role": "user", "content": f'我的人格特質以紫微斗數星象來推論是“{gw_main_star}”. 請替我依照這些人格特質,並根據 OCEAN 五大人格分析系統,一條一條的幫我分析?'},]
|
380 |
{"role": "user", "content": f'此用戶是{pssex}性,依據生辰推測的人格特質是“{gw_main_star}“。\n\n請給他一些待人處事的建議?'},]
|
381 |
+
try:
|
382 |
+
response = openai.chat.completions.create(
|
383 |
+
model=model,
|
384 |
+
max_tokens=4096,
|
385 |
+
messages=messages,
|
386 |
+
temperature=0.1, # this is the degree of randomness of the model's output
|
387 |
+
)
|
388 |
+
except openai.APIError as e:
|
389 |
+
# Handle the error
|
390 |
+
print("An error occurred:", e)
|
391 |
+
return e
|
392 |
+
|
393 |
returndata = '紫微斗數全書上面說:\n\n' + msum + '\n\n' + response.choices[0].message.content
|
394 |
if API_KEY:
|
395 |
ming_feedback.info = 'YES'
|