-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvision.py
More file actions
41 lines (31 loc) · 1.03 KB
/
vision.py
File metadata and controls
41 lines (31 loc) · 1.03 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
from openai import OpenAI
import os
def detectBadStuff(image_url):
client = OpenAI(api_key=os.environ['openaikey'])
response = client.chat.completions.create(
#temperature = 0.99,
#frequency_penalty = 0.73,
#presence_penalty = 0.91,
model="gpt-4-turbo",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": os.environ['openaiprompt']},
{
"type": "image_url",
"image_url": {
"url": image_url,
},
},
],
}
],
max_tokens=300
)
# Analyze the response to determine if it contains "yes"
print(response.choices[0].message.content)
return response.choices[0].message.content
if __name__ == "__main__":
test = detectBadStuff("https://www.shutterstock.com/shutterstock/videos/1093313969/thumb/10.jpg?ip=x480")
print(test)