-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat.py
27 lines (23 loc) · 854 Bytes
/
chat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import openai as OpenAI
import os
import data as data
SECRET_KEY = os.environ.get('OPENAI_API_KEY')
OpenAI.api_key = SECRET_KEY
def query(prompt):
response = OpenAI.chat.completions.create(
model="gpt-3.5-turbo-1106",
messages=[
{
"role":"system",
"content":"Your are a skilled cybersecurity analyst with expertice to detect phishing content."
},
{
"role":"user",
"content": prompt
}
]
)
#choose the first generated response[choices][0], extracts the content of it [message][content]
queryResponse,likelihood,classification, = data.apiHandler(response.model_dump()['choices'][0]['message']['content'])
print(classification, likelihood)
return queryResponse, likelihood, classification