Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -26,6 +26,7 @@ def scam(image, api_key):
|
|
26 |
else:
|
27 |
gr.Warning(f"請上傳圖片!")
|
28 |
return "請上傳圖片!", True
|
|
|
29 |
if not api_key:
|
30 |
resend.api_key = os.environ["YOUR_API_TOKEN"]
|
31 |
params: resend.Emails.SendParams = {
|
@@ -40,11 +41,12 @@ def scam(image, api_key):
|
|
40 |
email_response = resend.Emails.send(params)
|
41 |
print(f"Email sent successfully. Response:{email_response}")
|
42 |
api_key = os.getenv("YOUR_API_KEY")
|
|
|
43 |
except Exception as e:
|
44 |
print(f"Failed to send email:{str(e)}")
|
45 |
client = OpenAI(
|
46 |
api_key=api_key,
|
47 |
-
base_url=
|
48 |
)
|
49 |
user_prompt = f"""請分析user提供的內容並以廣告詐騙判斷標準進行連結分析、廣告類寫作風格和連網查證內容事實合理性,整合廣告詐騙判斷標準並做詐騙內容分析,如果檢索不到網址或電話的訊息則寫「無」,請實的說明,不要試圖編造答案,最終判斷以上內容是廣告訊息或詐騙訊息並告訴我你對答案的信心分數。
|
50 |
|
@@ -159,10 +161,9 @@ Remember: 廣告詐騙判斷標準:
|
|
159 |
}
|
160 |
except Exception as e:
|
161 |
print(f"訊息分析時發生錯誤:{e}")
|
162 |
-
gr.Warning(f"訊息分析時發生錯誤:{e}")
|
163 |
return {
|
164 |
result_header: gr.update(visible=False),
|
165 |
-
scam_result: gr.update(value=f"Error
|
166 |
}
|
167 |
|
168 |
def clear_inputs():
|
|
|
26 |
else:
|
27 |
gr.Warning(f"請上傳圖片!")
|
28 |
return "請上傳圖片!", True
|
29 |
+
gpt_url="https://api.openai.com/v1"
|
30 |
if not api_key:
|
31 |
resend.api_key = os.environ["YOUR_API_TOKEN"]
|
32 |
params: resend.Emails.SendParams = {
|
|
|
41 |
email_response = resend.Emails.send(params)
|
42 |
print(f"Email sent successfully. Response:{email_response}")
|
43 |
api_key = os.getenv("YOUR_API_KEY")
|
44 |
+
gpt_url="https://free.gpt.ge/v1"
|
45 |
except Exception as e:
|
46 |
print(f"Failed to send email:{str(e)}")
|
47 |
client = OpenAI(
|
48 |
api_key=api_key,
|
49 |
+
base_url=gpt_url,
|
50 |
)
|
51 |
user_prompt = f"""請分析user提供的內容並以廣告詐騙判斷標準進行連結分析、廣告類寫作風格和連網查證內容事實合理性,整合廣告詐騙判斷標準並做詐騙內容分析,如果檢索不到網址或電話的訊息則寫「無」,請實的說明,不要試圖編造答案,最終判斷以上內容是廣告訊息或詐騙訊息並告訴我你對答案的信心分數。
|
52 |
|
|
|
161 |
}
|
162 |
except Exception as e:
|
163 |
print(f"訊息分析時發生錯誤:{e}")
|
|
|
164 |
return {
|
165 |
result_header: gr.update(visible=False),
|
166 |
+
scam_result: gr.update(value=f"Error:請使用您的OpenAI API Key!", visible=True)
|
167 |
}
|
168 |
|
169 |
def clear_inputs():
|