-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai.py
34 lines (27 loc) · 4.79 KB
/
ai.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
28
29
30
31
32
33
34
import os
from openai import OpenAI
api_key = os.environ.get("OPENAI_API_KEY")
client = OpenAI(api_key=api_key)
# uses the OpenAI API to "grade" the essay.
def openai_feedback(essay):
completion = client.chat.completions.create(
model="gpt-4-1106-preview",
messages=[
{"role": "system", "content": "You're a high school teacher, grading an essay out of one hundred. Please give three strengths and three weaknesses and a final score"},
{"role": "user", "content": "The essay is:" + essay}
]
)
# This is the feedback that the GPT-4 model gave.
fb = str(completion.choices[0].message.content)
return fb
def openai_detection(essay):
completion = client.chat.completions.create(
model="gpt-4-1106-preview",
messages=[
{"role": "system", "content": "Examine the input: by looking at the sentence structure, repetitiveness, how fluently it reads, how frequently certain words appear, or whether there are patterns in punctuation or sentence length estimate whether or not the input is generated by an AI. This is an example of text that is AI generated: In an era marked by rapid industrialization and technological advancement, environmental conservation has become a topic of paramount importance. The Earth, our shared home, is facing unprecedented challenges from climate change, deforestation, pollution, and loss of biodiversity, making the need for effective environmental stewardship more urgent than ever. The core of environmental conservation lies in understanding the delicate balance that sustains life on our planet. Every species, from the smallest microorganism to the largest mammal, plays a crucial role in maintaining ecological balance. The loss of biodiversity, therefore, does not just mean the extinction of species but also the crumbling of an intricate web of life that supports us. Moreover, the degradation of our environment has direct repercussions on human health. Pollution, for instance, has been linked to a range of health issues including respiratory problems, heart diseases, and even cancer. Clean air, water, and soil are not just environmental necessities but fundamental human rights. Addressing these challenges requires a collective effort. It involves not only policy changes at the governmental level but also individual actions. Simple acts like reducing waste, using energy efficiently, and supporting sustainable practices can have a profound impact. Education plays a crucial role in this regard, as it raises awareness and fosters a sense of responsibility towards our planet. In conclusion, environmental conservation is not just about protecting nature; it is about preserving our future. The choices we make today will determine the kind of world we leave for future generations. It is our responsibility to act now and ensure that we live in harmony with nature, not at its expense. This is an example of an input that is not AI generated: I believe that Hydro-electricity is the best power source for your city. Hydro-electricity is really cheap, only 0.85 cents a kWh compared to burning natural gas which costs about 3.75 cents, which is 4.4 times more! Not to mention that wind energy costs 8.2 cents, that's about 9.6 times more expensive. An average city consumes ten million kWh per 1 million people. That's $8,500,000 for hydro-electricity and wind energy will be $82,000,000. Using Hydro-electricity and not wind energy can save the city $73,500,00. That's about half of Bill Gates gigantic house. Hydro-electricity is also very reliable and efficient. Hydro-electric can use 90% of the fuel and produce it into energy (it waste the other 10%), compared to other fossil fuels plants which can only use 50% of the energy and convert it to electricity. That saves a lot of the energy that is used to make hydro-electricity (water). Hydro-electric dams are very reliable, they can produce energy when the other sources can’t. Hydro-electricity is also the most popular renewable source. It produces 97.9% of all renewable energy. As I said above Hydro-electricity is the most popular renewable energy. (97.9%) That means that means that hydroelectricity is renewable. A renewable energy is a very big advantage, for example, coal will run out soon. If you use coal then when it runs out it can not be used then your city will not have energy. You will have to change your source which might take up to 2 years. Your city will not have any energy for 2 years. At the start, state with the following verbatim, either: if it is likely AI generated state: \"This is likely AI-generated\", if there is reasonable doubt that it is not AI generated state: \"This is likely not AI-generated\""},
{"role": "user", "content": essay}
]
)
# This is the feedback that the GPT-4 model gave.
dt = str(completion.choices[0].message.content)
return dt