diff --git a/README.md b/README.md index ae40291..9a78539 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,13 @@ We hear from so many individuals and companies about eco-friendly solutions or p * How/where to download your program * Any modifications needed to be made to files/folders +* add API_KEY to use openAI APIs + * add `api_secrets.py` and save your openAI API key as a variable + ``` + API_KEY = "YOUR_API_KEY" + ``` + * test with any scripts in `./examples` to check if it works + ### Executing program * How to run the program diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/tldr.py b/examples/tldr.py new file mode 100644 index 0000000..e93c187 --- /dev/null +++ b/examples/tldr.py @@ -0,0 +1,24 @@ +import openai +from api_secrets import API_KEY + +openai.api_key = API_KEY + +prompt = """A neutron star is the collapsed core of a massive supergiant star, +which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] +Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, +and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] +They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.\n\n + +Tl;dr""" + +response = openai.Completion.create( + model="text-davinci-002", + prompt=prompt, + temperature=0.7, + max_tokens=60, + top_p=1.0, + frequency_penalty=0.0, + presence_penalty=0.0 +) + +print(response.choices[0].text) \ No newline at end of file diff --git a/rip/__init__.py b/rip/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rip/main.py b/rip/main.py new file mode 100644 index 0000000..b361cd8 --- /dev/null +++ b/rip/main.py @@ -0,0 +1,31 @@ +import openai +from api_secrets import API_KEY + +openai.api_key = API_KEY +prompt = """A neutron star is the collapsed core of a massive supergiant star, +which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] +Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, +and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] +They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.\n\n + +Tl;dr""" + +text_response = openai.Completion.create( + model="text-davinci-002", + prompt=prompt, + temperature=0.7, + max_tokens=60, + top_p=1.0, + frequency_penalty=0.0, + presence_penalty=0.0 +) +tldr_text = text_response.choices[0].text + +img_response = openai.Image.create( + prompt=tldr_text, + n=1, + size="1024x1024" +) +image_url = img_response.data[0].url + +print(image_url) \ No newline at end of file