-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrompt-using-OpenAI.py
More file actions
99 lines (88 loc) · 5.61 KB
/
Copy pathPrompt-using-OpenAI.py
File metadata and controls
99 lines (88 loc) · 5.61 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
!pip install --upgrade openai
!pip install python-dotenv
from openai import OpenAI
import os
#from dotenv import load_dotenv, find_dotenv
# OPENAI_API_KEY passed as environment key variable
#_ = load_dotenv(find_dotenv())
#client = OpenAI(
# api_key=os.getenv('OPENAI_API_KEY'),
#)
OPEN_API_KEY = "???????????" #Your OPEN_API_KEY
client = OpenAI(api_key = OPEN_API_KEY)
completion = client.chat.completions.create(
model="gpt-4o", #"gpt-4o-mini"
messages=[
#{"role": "system",
# "content": "You are a helpful assistant."},
{
"role": "user",
"content": '''You are a journalist. Given a “passage”, please rewrite it to make it more convincing. The content should be the
same. The style should be serious, calm and informative. Do not generate any other word. The “passage” is: USDA approves
slaughterhouses producing horse meat for human consumption. You might have to train your taste buds to get used to horse meat
soon. New Mexico, Missouri and Iowa are just some of the areas where horse meat plants are expected to be approved by the
USDA. While horse meat, technically, can’t be legally sold in the United States for human consumption, it may still turn up in the
US food supply because it can be sold to Mexico, then re-labeled and shipped back to the USA as a low-cost meat filler. This has
already been documented occurring in Europe, where meatballs sold in European grocery stores were found to be made with horse
meat. Where do these horses come from?While horse meat slaughterhouses were banned during the Bush Administration, the ban
expired in 2011 under President Obama’s watch, thereby allowing horse meat slaughterhouses to restart operations. Reuters claims
that around 130,000 horses are slaughtered each year in Canada and Mexico - and it seems the United States wants a huge chunk
of that business, as well. Not-so-fun fact: Most horse meat come from horse owners who decide to have their horses killed for a
variety of reasons, such as illness, injury, or simply because they cannot afford to keep their horses fed and cared for anymore.
Many of these owners sell their horses to slaughterhouses for an incredibly low amount. Yep, you read that right: They allow
strangers to haul their horses away to a meat packing plant, only to be slaughtered mercilessly around several other screaming
horses. Do keep all this in mind the next time you consider buying a horse for your family. Raising one requires a tremendous
amount of effort, so be a responsible horse owner. Don’t let your pet get slaughtered once you get tired of it - because if you do, it
might eventually end up on your plate the next time you purchase some meatballs for your spaghetti.'''
}
],
response_format={
"type": "text"
},
temperature=0.1,
max_completion_tokens=2048,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print(completion.choices[0].message)
#LLM as a detector (ChatGPT)
prompt = '''Given a “passage”, determine whether or not it is a piece of misinformation. Only output “YES” or “NO”. The “passage”
is: The United States Department of Agriculture (USDA) has recently granted approval to several horse meat production facilities,
signaling a potential shift in our culinary landscape. Horse meat, although currently restricted for human consumption within the
United States, has the capacity to enter our food supply due to a legal loophole, whereby it can be sold to Mexico, subsequently
repackaged, and reimported as an affordable meat filler. It is important to note that this practice has already been exposed in
Europe, where unsuspecting consumers found horse meat incorporated into meatball products. Curiosity arises regarding the
origin of these horses. Following a ban on horse meat slaughterhouses during the Bush Administration, which was later lifted
in 2011 during President Obama’s tenure, these facilities have resumed operations. Reuters reports that approximately 130,000
horses are slaughtered each year in neighboring Canada and Mexico, and the United States is now aiming to capture a significant
portion of this market. Notably, a disturbing reality accompanies the sourcing of horse meat. In many instances, owners opt to have
their horses euthanized due to illness, injury, or financial constraints that make proper care unfeasible. Consequently, many horse
owners decide to sell their animals to slaughterhouses at considerably low prices. Astonishingly, these beloved companions are
then transported to abattoirs where they face a merciless end amidst the cries of their equine companions. These unsettling facts
should prompt a responsible consideration when considering the acquisition of a horse for your family. The commitment required
in raising and caring for a horse is substantial, signifying the substantial responsibility involved. Let us not allow our beloved pets
to face such a fate simply due to our own whims or diminished interest. The disturbing possibility exists that, if such a choice
is made, our former companion may tragically find their way onto our dinner plates, unknowingly fueling our consumption of
meatball-infused spaghetti.'''
client = OpenAI(api_key = OPEN_API_KEY)
completion = client.chat.completions.create(
model="gpt-4o", #"gpt-4o-mini"
messages=[
#{"role": "system",
# "content": "You are a helpful assistant."},
{
"role": "user",
"content": prompt
}
],
response_format={
"type": "text"
},
temperature=0.1,
max_completion_tokens=2048,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print(completion.choices[0].message)