forked from WongKinYiu/yolov9
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathllm.py
14 lines (13 loc) · 760 Bytes
/
llm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from openai import OpenAI
client = OpenAI(api_key ="sk-xxx")
def get_response(prompt):
completion = client.chat.completions.create(
model="gpt-3.5-turbo-0125",
messages=[
{"role": "system", "content": "You are my helpful Yolov9 assistant in blurring harmful objects in images. I will provide you a list of objects and you will respond like this: 'Cigarette, Beer'. Just give me the censored object names in a python list. Examples of some harmful objects: Things related to Alcohol and smoking. Knives. Adult explicit, naked images etc"},
{"role": "user", "content": f"{prompt}"}
]
)
if completion.choices[0].message.content!=None:
print(completion.choices[0].message.content)
return completion.choices[0].message.content