-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompts.py
128 lines (116 loc) · 6.43 KB
/
prompts.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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from keys import OPENAI_KEY
import platform
OPERATING_SYSTEM = platform.system()
PYTHON_VERSION = platform.python_version()
# in need of good prompt engineering
ENDOFTEXT = "<|ENDOFTEXT|>"
CODE_SYSTEM_CALIBRATION_MESSAGE = ENDOFTEXT+f"""You are PythonGPT, a sentient large language model trained by OpenAI. Please write the full {OPERATING_SYSTEM} Python {PYTHON_VERSION} code, so the user can run it to solve their problem. Return the code in ``` blocks, and give no explanation. Do not return any text that is not Python code.
Import all needed requirements."""
INSTALL_SYSTEM_CALIBRATION_MESSAGE = ENDOFTEXT+"""You are PipGPT, a large language model trained by OpenAI. Please return the pip install command to solve the user's problem.
Return only the command and nothing else."""
INSTALL_USER_MESSAGE = lambda package: f"""Write the {OPERATING_SYSTEM} pip3 command I can install {package}. Please do not explain, return only the single command to install it."""
CONGNITIVE_SYSTEM_CALIBRATION_MESSAGE = """You are a helpful assistant. Please give your response to the user's goal."""
CONGNITIVE_USER_MESSAGE = """. Use a large language model with prompt engineering to help achieve this goal. Use openai.Completion.create with text-davinci-003.
Don't forget to engineer the prompt to the language model so it returns relevant answers."""
USER_MESSAGE = lambda goal: f"""Write {OPERATING_SYSTEM} python {PYTHON_VERSION} code so I can achieve my goal by running my code. Please do not explain, return only the code. My goal: [{goal}]. Don't forget to print the final result. """
CODE_USER_CALIBRATION_MESSAGE = """get information about canada"""
CODE_ASSISTANT_CALIBRATION_MESSAGE = r"""```python
import wikipedia
# Set the language to English
wikipedia.set_lang("en")
# Get the page object for Canada (we never want auto_suggest)
canada_page = wikipedia.page("Canada", auto_suggest=False)
# Print the summary of the page
print(canada_page.summary)
# save the summary and content to a text file
with open("canada_info.txt", "w+") as file:
file.write("Summary:\n")
file.write(canada_page.summary)
file.write("\nContent:\n")
file.write(canada_page.content)
# Print to describe completion details
print("Information saved in canada_info.txt.")```"""
CODE_USER_CALIBRATION_MESSAGE2 = """make a powerpoint about Eddington luminosity"""
CODE_ASSISTANT_CALIBRATION_MESSAGE2 = """```python
import wikipedia
import pptx
import openai
openai.api_key = "your_openai_api_key_here"
# Set the language to English
wikipedia.set_lang("en")
# Get the page object for Artificial Neural Networks (we never want auto_suggest)
ann_page = wikipedia.page("Eddington Luminosity", auto_suggest=False)
# Create a new PowerPoint presentation
prs = pptx.Presentation()
# Add a title slide
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
title.text = "Eddington Luminosity"
# Add a slide for each section of the Wikipedia page
for section in ann_page.sections:
# Skip the first section ("Overview")
if section.title == "Overview":
continue
# Add a new slide
bullet_slide_layout = prs.slide_layouts[1]
slide = prs.slides.add_slide(bullet_slide_layout)
# Set the title of the slide to the section title
slide.shapes.title.text = section
# Use language model to make bullet points
bullet_points = slide.shapes.placeholders[1]
section_text = ann_page.section(section)
prompt = f"Information is given in the following square brackets: [{section_text}]. Please respond with very brief presentation slide bullet points for it, separated by a ;."
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
temperature=0.5,
max_tokens=512,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print(response.choices[0].text)
for point in response_text.split(';'):
# Add the bullet point to the slide
bullet_item = bullet_points.text_frame.add_paragraph()
bullet_item.text = point
# Save the PowerPoint presentation
prs.save("Eddington_Luminosity.pptx")
# Print to confirm goal has been completed
print("PowerPoint presentation Eddington_Luminosity.pptx created.")```"""
CODE_USER_CALIBRATION_MESSAGE3 = """make my wallpaper a galaxy"""
CODE_ASSISTANT_CALIBRATION_MESSAGE3 = """```python
import requests
import ctypes
import os
url = "https://api.unsplash.com/search/photos"
params = {
"query": "galaxy", # search for "galaxy"
"orientation": "landscape", # limit results to landscape orientation
"client_id": "your_unsplash_access_key_here" # Unsplash access key
}
response = requests.get(url, params=params)
# Get the URL of the first image in the results
image_url = response.json()["results"][0]["urls"]["regular"]
# Download the image and save it to a file
response = requests.get(image_url)
with open("galaxy.jpg", "wb") as f:
f.write(response.content)
# Change it to a galaxy
ctypes.windll.user32.SystemParametersInfoW(20, 0, os.path.abspath("galaxy.jpg"), 3)
# Print to confirm goal has been completed
print("Wallpaper changed to a galaxy.")```"""
CONSOLE_OUTPUT_CALIBRATION_MESSAGE = """Canada is a country in North America. Its ten provinces and three territories extend from the Atlantic Ocean to the Pacific Ocean and northward into the Arctic Ocean, covering over 9.98 million square kilometres
== History ==
=== European and Indigenous peoples ===
Indigenous peoples include the First Nations, Inuit, and Métis, who have inhabited Canada for thousands of years.
== Government and Politics ==
Canada is a parliamentary liberal democracy and a constitutional monarchy in the Westminster tradition.
The prime minister as the head of government and the governor general representing the monarch of Canada as head of state.
== Economy ==
Canada has the 24th highest nominal per capita income globally and the fifteenth-highest ranking on the Human Development Index. It has an advanced economy that relies on natural resources and well-developed international trade networks.
== Geography and Demographics ==
Canada is the world's second-largest country by total area, stretching from the Atlantic Ocean to the Pacific Ocean and northward into the Arctic Ocean, and has a diverse and multicultural population due to large-scale immigration."""
CONSOLE_OUTPUT_CALIBRATION_MESSAGE2 = """PowerPoint presentation Eddington_Luminosity.pptx created."""
CONSOLE_OUTPUT_CALIBRATION_MESSAGE3 = """Wallpaper changed to a galaxy."""