vivekdabhi80
commited on
Commit
•
efb560d
1
Parent(s):
53cbba5
Upload 6 files
Browse files- tutorial_1.py +241 -0
- tutorial_2.py +126 -0
- tutorial_3.py +129 -0
- tutorial_4.py +193 -0
- tutorial_5.py +142 -0
- tutorial_6.py +90 -0
tutorial_1.py
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
|
4 |
+
from dotenv import load_dotenv, find_dotenv
|
5 |
+
_ = load_dotenv(find_dotenv())
|
6 |
+
|
7 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
8 |
+
|
9 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
10 |
+
messages = [{"role": "user", "content": prompt}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages=messages,
|
14 |
+
temperature=0, # this is the degree of randomness of the model's output
|
15 |
+
)
|
16 |
+
return response.choices[0].message["content"]
|
17 |
+
|
18 |
+
# text = f"""
|
19 |
+
# You should express what you want a model to do by \
|
20 |
+
# providing instructions that are as clear and \
|
21 |
+
# specific as you can possibly make them. \
|
22 |
+
# This will guide the model towards the desired output, \
|
23 |
+
# and reduce the chances of receiving irrelevant \
|
24 |
+
# or incorrect responses. Don't confuse writing a \
|
25 |
+
# clear prompt with writing a short prompt. \
|
26 |
+
# In many cases, longer prompts provide more clarity \
|
27 |
+
# and context for the model, which can lead to \
|
28 |
+
# more detailed and relevant outputs.
|
29 |
+
# """
|
30 |
+
# prompt = f"""
|
31 |
+
# Summarize the text delimited by triple backticks \
|
32 |
+
# into a single sentence.
|
33 |
+
# ```{text}```
|
34 |
+
# """
|
35 |
+
# response = get_completion(prompt)
|
36 |
+
|
37 |
+
# print(response)
|
38 |
+
|
39 |
+
|
40 |
+
# prompt = f"""
|
41 |
+
# Generate a list of three made-up book titles along \
|
42 |
+
# with their authors and genres.
|
43 |
+
# Provide them in JSON format with the following keys:
|
44 |
+
# book_id, title, author, genre.
|
45 |
+
# """
|
46 |
+
# response = get_completion(prompt)
|
47 |
+
# print(response)
|
48 |
+
|
49 |
+
|
50 |
+
# text_1 = f"""
|
51 |
+
# Making a cup of tea is easy! First, you need to get some \
|
52 |
+
# water boiling. While that's happening, \
|
53 |
+
# grab a cup and put a tea bag in it. Once the water is \
|
54 |
+
# hot enough, just pour it over the tea bag. \
|
55 |
+
# Let it sit for a bit so the tea can steep. After a \
|
56 |
+
# few minutes, take out the tea bag. If you \
|
57 |
+
# like, you can add some sugar or milk to taste. \
|
58 |
+
# And that's it! You've got yourself a delicious \
|
59 |
+
# cup of tea to enjoy.
|
60 |
+
# """
|
61 |
+
# prompt = f"""
|
62 |
+
# You will be provided with text delimited by triple quotes.
|
63 |
+
# If it contains a sequence of instructions, \
|
64 |
+
# re-write those instructions in the following format:
|
65 |
+
|
66 |
+
# Step 1 - ...
|
67 |
+
# Step 2 - …
|
68 |
+
# …
|
69 |
+
# Step N - …
|
70 |
+
|
71 |
+
# If the text does not contain a sequence of instructions, \
|
72 |
+
# then simply write \"No steps provided.\"
|
73 |
+
|
74 |
+
# \"\"\"{text_1}\"\"\"
|
75 |
+
# """
|
76 |
+
# response = get_completion(prompt)
|
77 |
+
# print("Completion for Text 1:")
|
78 |
+
# print(response)
|
79 |
+
|
80 |
+
# prompt = f"""
|
81 |
+
# Your task is to answer in a consistent style.
|
82 |
+
|
83 |
+
# <child>: Teach me about patience.
|
84 |
+
|
85 |
+
# <grandparent>: The river that carves the deepest \
|
86 |
+
# valley flows from a modest spring; the \
|
87 |
+
# grandest symphony originates from a single note; \
|
88 |
+
# the most intricate tapestry begins with a solitary thread.
|
89 |
+
|
90 |
+
# <child>: Teach me about resilience.
|
91 |
+
# """
|
92 |
+
# response = get_completion(prompt)
|
93 |
+
# print(response)
|
94 |
+
|
95 |
+
|
96 |
+
# text = f"""
|
97 |
+
# In a charming village, siblings Jack and Jill set out on \
|
98 |
+
# a quest to fetch water from a hilltop \
|
99 |
+
# well. As they climbed, singing joyfully, misfortune \
|
100 |
+
# struck—Jack tripped on a stone and tumbled \
|
101 |
+
# down the hill, with Jill following suit. \
|
102 |
+
# Though slightly battered, the pair returned home to \
|
103 |
+
# comforting embraces. Despite the mishap, \
|
104 |
+
# their adventurous spirits remained undimmed, and they \
|
105 |
+
# continued exploring with delight.
|
106 |
+
# """
|
107 |
+
# # example 1
|
108 |
+
# prompt_1 = f"""
|
109 |
+
# Perform the following actions:
|
110 |
+
# 1 - Summarize the following text delimited by triple \
|
111 |
+
# backticks with 1 sentence.
|
112 |
+
# 2 - Translate the summary into French.
|
113 |
+
# 3 - List each name in the French summary.
|
114 |
+
# 4 - Output a json object that contains the following \
|
115 |
+
# keys: french_summary, num_names.
|
116 |
+
|
117 |
+
# Separate your answers with line breaks.
|
118 |
+
|
119 |
+
# Text:
|
120 |
+
# ```{text}```
|
121 |
+
# """
|
122 |
+
# response = get_completion(prompt_1)
|
123 |
+
# print("Completion for prompt 1:")
|
124 |
+
# print(response)
|
125 |
+
|
126 |
+
|
127 |
+
# prompt_2 = f"""
|
128 |
+
# Your task is to perform the following actions:
|
129 |
+
# 1 - Summarize the following text delimited by
|
130 |
+
# <> with 1 sentence.
|
131 |
+
# 2 - Translate the summary into French.
|
132 |
+
# 3 - List each name in the French summary.
|
133 |
+
# 4 - Output a json object that contains the
|
134 |
+
# following keys: french_summary, num_names.
|
135 |
+
|
136 |
+
# Use the following format:
|
137 |
+
# Text: <text to summarize>
|
138 |
+
# Summary: <summary>
|
139 |
+
# Translation: <summary translation>
|
140 |
+
# Names: <list of names in summary>
|
141 |
+
# Output JSON: <json with summary and num_names>
|
142 |
+
|
143 |
+
# Text: <{text}>
|
144 |
+
# """
|
145 |
+
# response = get_completion(prompt_2)
|
146 |
+
# print("\nCompletion for prompt 2:")
|
147 |
+
# print(response)
|
148 |
+
|
149 |
+
|
150 |
+
# prompt = f"""
|
151 |
+
# Determine if the student's solution is correct or not.
|
152 |
+
|
153 |
+
# Question:
|
154 |
+
# I'm building a solar power installation and I need \
|
155 |
+
# help working out the financials.
|
156 |
+
# - Land costs $100 / square foot
|
157 |
+
# - I can buy solar panels for $250 / square foot
|
158 |
+
# - I negotiated a contract for maintenance that will cost \
|
159 |
+
# me a flat $100k per year, and an additional $10 / square \
|
160 |
+
# foot
|
161 |
+
# What is the total cost for the first year of operations
|
162 |
+
# as a function of the number of square feet.
|
163 |
+
|
164 |
+
# Student's Solution:
|
165 |
+
# Let x be the size of the installation in square feet.
|
166 |
+
# Costs:
|
167 |
+
# 1. Land cost: 100x
|
168 |
+
# 2. Solar panel cost: 250x
|
169 |
+
# 3. Maintenance cost: 100,000 + 100x
|
170 |
+
# Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
|
171 |
+
# """
|
172 |
+
# response = get_completion(prompt)
|
173 |
+
# print(response)
|
174 |
+
|
175 |
+
|
176 |
+
# prompt = f"""
|
177 |
+
# Your task is to determine if the student's solution \
|
178 |
+
# is correct or not.
|
179 |
+
# To solve the problem do the following:
|
180 |
+
# - First, work out your own solution to the problem including the final total.
|
181 |
+
# - Then compare your solution to the student's solution \
|
182 |
+
# and evaluate if the student's solution is correct or not.
|
183 |
+
# Don't decide if the student's solution is correct until
|
184 |
+
# you have done the problem yourself.
|
185 |
+
|
186 |
+
# Use the following format:
|
187 |
+
# Question:
|
188 |
+
# ```
|
189 |
+
# question here
|
190 |
+
# ```
|
191 |
+
# Student's solution:
|
192 |
+
# ```
|
193 |
+
# student's solution here
|
194 |
+
# ```
|
195 |
+
# Actual solution:
|
196 |
+
# ```
|
197 |
+
# steps to work out the solution and your solution here
|
198 |
+
# ```
|
199 |
+
# Is the student's solution the same as actual solution \
|
200 |
+
# just calculated:
|
201 |
+
# ```
|
202 |
+
# yes or no
|
203 |
+
# ```
|
204 |
+
# Student grade:
|
205 |
+
# ```
|
206 |
+
# correct or incorrect
|
207 |
+
# ```
|
208 |
+
|
209 |
+
# Question:
|
210 |
+
# ```
|
211 |
+
# I'm building a solar power installation and I need help \
|
212 |
+
# working out the financials.
|
213 |
+
# - Land costs $100 / square foot
|
214 |
+
# - I can buy solar panels for $250 / square foot
|
215 |
+
# - I negotiated a contract for maintenance that will cost \
|
216 |
+
# me a flat $100k per year, and an additional $10 / square \
|
217 |
+
# foot
|
218 |
+
# What is the total cost for the first year of operations \
|
219 |
+
# as a function of the number of square feet.
|
220 |
+
# ```
|
221 |
+
# Student's solution:
|
222 |
+
# ```
|
223 |
+
# Let x be the size of the installation in square feet.
|
224 |
+
# Costs:
|
225 |
+
# 1. Land cost: 100x
|
226 |
+
# 2. Solar panel cost: 250x
|
227 |
+
# 3. Maintenance cost: 100,000 + 100x
|
228 |
+
# Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
|
229 |
+
# ```
|
230 |
+
# Actual solution:
|
231 |
+
# """
|
232 |
+
# response = get_completion(prompt)
|
233 |
+
# print(response)
|
234 |
+
|
235 |
+
|
236 |
+
prompt = f"""
|
237 |
+
Tell me about AeroGlide UltraSlim Smart Toothbrush by Boie
|
238 |
+
"""
|
239 |
+
response = get_completion(prompt)
|
240 |
+
print(response)
|
241 |
+
|
tutorial_2.py
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
from IPython.display import display, HTML # type: ignore
|
4 |
+
|
5 |
+
from dotenv import load_dotenv, find_dotenv
|
6 |
+
_ = load_dotenv(find_dotenv()) # read local .env file
|
7 |
+
|
8 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
9 |
+
|
10 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
11 |
+
messages = [{"role": "user", "content": prompt}]
|
12 |
+
response = openai.ChatCompletion.create(
|
13 |
+
model=model,
|
14 |
+
messages=messages,
|
15 |
+
temperature=0, # this is the degree of randomness of the model's output
|
16 |
+
)
|
17 |
+
return response.choices[0].message["content"]
|
18 |
+
|
19 |
+
fact_sheet_chair = """
|
20 |
+
OVERVIEW
|
21 |
+
- Part of a beautiful family of mid-century inspired office furniture,
|
22 |
+
including filing cabinets, desks, bookcases, meeting tables, and more.
|
23 |
+
- Several options of shell color and base finishes.
|
24 |
+
- Available with plastic back and front upholstery (SWC-100)
|
25 |
+
or full upholstery (SWC-110) in 10 fabric and 6 leather options.
|
26 |
+
- Base finish options are: stainless steel, matte black,
|
27 |
+
gloss white, or chrome.
|
28 |
+
- Chair is available with or without armrests.
|
29 |
+
- Suitable for home or business settings.
|
30 |
+
- Qualified for contract use.
|
31 |
+
|
32 |
+
CONSTRUCTION
|
33 |
+
- 5-wheel plastic coated aluminum base.
|
34 |
+
- Pneumatic chair adjust for easy raise/lower action.
|
35 |
+
|
36 |
+
DIMENSIONS
|
37 |
+
- WIDTH 53 CM | 20.87”
|
38 |
+
- DEPTH 51 CM | 20.08”
|
39 |
+
- HEIGHT 80 CM | 31.50”
|
40 |
+
- SEAT HEIGHT 44 CM | 17.32”
|
41 |
+
- SEAT DEPTH 41 CM | 16.14”
|
42 |
+
|
43 |
+
OPTIONS
|
44 |
+
- Soft or hard-floor caster options.
|
45 |
+
- Two choices of seat foam densities:
|
46 |
+
medium (1.8 lb/ft3) or high (2.8 lb/ft3)
|
47 |
+
- Armless or 8 position PU armrests
|
48 |
+
|
49 |
+
MATERIALS
|
50 |
+
SHELL BASE GLIDER
|
51 |
+
- Cast Aluminum with modified nylon PA6/PA66 coating.
|
52 |
+
- Shell thickness: 10 mm.
|
53 |
+
SEAT
|
54 |
+
- HD36 foam
|
55 |
+
|
56 |
+
COUNTRY OF ORIGIN
|
57 |
+
- Italy
|
58 |
+
"""
|
59 |
+
|
60 |
+
prompt = f"""
|
61 |
+
Your task is to help a marketing team create a
|
62 |
+
description for a retail website of a product based
|
63 |
+
on a technical fact sheet.
|
64 |
+
|
65 |
+
Write a product description based on the information
|
66 |
+
provided in the technical specifications delimited by
|
67 |
+
triple backticks.
|
68 |
+
|
69 |
+
Technical specifications: ```{fact_sheet_chair}```
|
70 |
+
"""
|
71 |
+
response = get_completion(prompt)
|
72 |
+
print(response)
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
prompt = f"""
|
77 |
+
Your task is to help a marketing team create a
|
78 |
+
description for a retail website of a product based
|
79 |
+
on a technical fact sheet.
|
80 |
+
|
81 |
+
Write a product description based on the information
|
82 |
+
provided in the technical specifications delimited by
|
83 |
+
triple backticks.
|
84 |
+
|
85 |
+
Use at most 3 sentences..
|
86 |
+
|
87 |
+
Technical specifications: ```{fact_sheet_chair}```
|
88 |
+
"""
|
89 |
+
response = get_completion(prompt)
|
90 |
+
print(response)
|
91 |
+
|
92 |
+
|
93 |
+
prompt = f"""
|
94 |
+
Your task is to help a marketing team create a
|
95 |
+
description for a retail website of a product based
|
96 |
+
on a technical fact sheet.
|
97 |
+
|
98 |
+
Write a product description based on the information
|
99 |
+
provided in the technical specifications delimited by
|
100 |
+
triple backticks.
|
101 |
+
|
102 |
+
The description is intended for furniture retailers,
|
103 |
+
so should be technical in nature and focus on the
|
104 |
+
materials the product is constructed from.
|
105 |
+
|
106 |
+
At the end of the description, include every 7-character
|
107 |
+
Product ID in the technical specification.
|
108 |
+
|
109 |
+
After the description, include a table that gives the
|
110 |
+
product's dimensions. The table should have two columns.
|
111 |
+
In the first column include the name of the dimension.
|
112 |
+
In the second column include the measurements in inches only.
|
113 |
+
|
114 |
+
Give the table the title 'Product Dimensions'.
|
115 |
+
|
116 |
+
|
117 |
+
Format everything as HTML that can be used in a website.
|
118 |
+
Place the description in a <div> element.
|
119 |
+
|
120 |
+
Technical specifications: ```{fact_sheet_chair}```
|
121 |
+
"""
|
122 |
+
|
123 |
+
response = get_completion(prompt)
|
124 |
+
print(response)
|
125 |
+
|
126 |
+
display(HTML(response))
|
tutorial_3.py
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
|
4 |
+
from dotenv import load_dotenv, find_dotenv
|
5 |
+
_ = load_dotenv(find_dotenv()) # read local .env file
|
6 |
+
|
7 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
8 |
+
|
9 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
10 |
+
messages = [{"role": "user", "content": prompt}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages=messages,
|
14 |
+
temperature=0, # this is the degree of randomness of the model's output
|
15 |
+
)
|
16 |
+
return response.choices[0].message["content"]
|
17 |
+
|
18 |
+
|
19 |
+
prod_review = """
|
20 |
+
Got this panda plush toy for my daughter's birthday, \
|
21 |
+
who loves it and takes it everywhere. It's soft and \
|
22 |
+
super cute, and its face has a friendly look. It's \
|
23 |
+
a bit small for what I paid though. I think there \
|
24 |
+
might be other options that are bigger for the \
|
25 |
+
same price. It arrived a day earlier than expected, \
|
26 |
+
so I got to play with it myself before I gave it \
|
27 |
+
to her.
|
28 |
+
"""
|
29 |
+
|
30 |
+
prompt = f"""
|
31 |
+
Your task is to extract relevant information from \
|
32 |
+
a product review from an ecommerce site to give \
|
33 |
+
feedback to the Shipping department.
|
34 |
+
|
35 |
+
From the review below, delimited by triple quotes \
|
36 |
+
extract the information relevant to shipping and \
|
37 |
+
delivery. Limit to 30 words.
|
38 |
+
|
39 |
+
Review: ```{prod_review}``` # type: ignore
|
40 |
+
"""
|
41 |
+
|
42 |
+
response = get_completion(prompt)
|
43 |
+
print(response)
|
44 |
+
|
45 |
+
review_1 = prod_review
|
46 |
+
|
47 |
+
# review for a standing lamp
|
48 |
+
review_2 = """
|
49 |
+
Needed a nice lamp for my bedroom, and this one \
|
50 |
+
had additional storage and not too high of a price \
|
51 |
+
point. Got it fast - arrived in 2 days. The string \
|
52 |
+
to the lamp broke during the transit and the company \
|
53 |
+
happily sent over a new one. Came within a few days \
|
54 |
+
as well. It was easy to put together. Then I had a \
|
55 |
+
missing part, so I contacted their support and they \
|
56 |
+
very quickly got me the missing piece! Seems to me \
|
57 |
+
to be a great company that cares about their customers \
|
58 |
+
and products.
|
59 |
+
"""
|
60 |
+
|
61 |
+
# review for an electric toothbrush
|
62 |
+
review_3 = """
|
63 |
+
My dental hygienist recommended an electric toothbrush, \
|
64 |
+
which is why I got this. The battery life seems to be \
|
65 |
+
pretty impressive so far. After initial charging and \
|
66 |
+
leaving the charger plugged in for the first week to \
|
67 |
+
condition the battery, I've unplugged the charger and \
|
68 |
+
been using it for twice daily brushing for the last \
|
69 |
+
3 weeks all on the same charge. But the toothbrush head \
|
70 |
+
is too small. I’ve seen baby toothbrushes bigger than \
|
71 |
+
this one. I wish the head was bigger with different \
|
72 |
+
length bristles to get between teeth better because \
|
73 |
+
this one doesn’t. Overall if you can get this one \
|
74 |
+
around the $50 mark, it's a good deal. The manufactuer's \
|
75 |
+
replacements heads are pretty expensive, but you can \
|
76 |
+
get generic ones that're more reasonably priced. This \
|
77 |
+
toothbrush makes me feel like I've been to the dentist \
|
78 |
+
every day. My teeth feel sparkly clean!
|
79 |
+
"""
|
80 |
+
|
81 |
+
# review for a blender
|
82 |
+
review_4 = """
|
83 |
+
So, they still had the 17 piece system on seasonal \
|
84 |
+
sale for around $49 in the month of November, about \
|
85 |
+
half off, but for some reason (call it price gouging) \
|
86 |
+
around the second week of December the prices all went \
|
87 |
+
up to about anywhere from between $70-$89 for the same \
|
88 |
+
system. And the 11 piece system went up around $10 or \
|
89 |
+
so in price also from the earlier sale price of $29. \
|
90 |
+
So it looks okay, but if you look at the base, the part \
|
91 |
+
where the blade locks into place doesn’t look as good \
|
92 |
+
as in previous editions from a few years ago, but I \
|
93 |
+
plan to be very gentle with it (example, I crush \
|
94 |
+
very hard items like beans, ice, rice, etc. in the \
|
95 |
+
blender first then pulverize them in the serving size \
|
96 |
+
I want in the blender then switch to the whipping \
|
97 |
+
blade for a finer flour, and use the cross cutting blade \
|
98 |
+
first when making smoothies, then use the flat blade \
|
99 |
+
if I need them finer/less pulpy). Special tip when making \
|
100 |
+
smoothies, finely cut and freeze the fruits and \
|
101 |
+
vegetables (if using spinach-lightly stew soften the \
|
102 |
+
spinach then freeze until ready for use-and if making \
|
103 |
+
sorbet, use a small to medium sized food processor) \
|
104 |
+
that you plan to use that way you can avoid adding so \
|
105 |
+
much ice if at all-when making your smoothie. \
|
106 |
+
After about a year, the motor was making a funny noise. \
|
107 |
+
I called customer service but the warranty expired \
|
108 |
+
already, so I had to buy another one. FYI: The overall \
|
109 |
+
quality has gone done in these types of products, so \
|
110 |
+
they are kind of counting on brand recognition and \
|
111 |
+
consumer loyalty to maintain sales. Got it in about \
|
112 |
+
two days.
|
113 |
+
"""
|
114 |
+
|
115 |
+
reviews = [review_1, review_2, review_3, review_4]
|
116 |
+
|
117 |
+
for i in range(len(reviews)):
|
118 |
+
prompt = f"""
|
119 |
+
Your task is to generate a short summary of a product \
|
120 |
+
review from an ecommerce site.
|
121 |
+
|
122 |
+
Summarize the review below, delimited by triple \
|
123 |
+
backticks in at most 20 words.
|
124 |
+
|
125 |
+
Review: ```{reviews[i]}```
|
126 |
+
"""
|
127 |
+
|
128 |
+
response = get_completion(prompt)
|
129 |
+
print(i, response, "\n")
|
tutorial_4.py
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
|
4 |
+
from dotenv import load_dotenv, find_dotenv
|
5 |
+
_ = load_dotenv(find_dotenv()) # read local .env file
|
6 |
+
|
7 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
8 |
+
|
9 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
10 |
+
messages = [{"role": "user", "content": prompt}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages=messages,
|
14 |
+
temperature=0, # this is the degree of randomness of the model's output
|
15 |
+
)
|
16 |
+
return response.choices[0].message["content"]
|
17 |
+
|
18 |
+
lamp_review = """
|
19 |
+
Needed a nice lamp for my bedroom, and this one had \
|
20 |
+
additional storage and not too high of a price point. \
|
21 |
+
Got it fast. The string to our lamp broke during the \
|
22 |
+
transit and the company happily sent over a new one. \
|
23 |
+
Came within a few days as well. It was easy to put \
|
24 |
+
together. I had a missing part, so I contacted their \
|
25 |
+
support and they very quickly got me the missing piece! \
|
26 |
+
Lumina seems to me to be a great company that cares \
|
27 |
+
about their customers and products!!
|
28 |
+
"""
|
29 |
+
|
30 |
+
|
31 |
+
prompt = f"""
|
32 |
+
What is the sentiment of the following product review,
|
33 |
+
which is delimited with triple backticks?
|
34 |
+
|
35 |
+
Review text: '''{lamp_review}'''
|
36 |
+
"""
|
37 |
+
response = get_completion(prompt)
|
38 |
+
print(response)
|
39 |
+
|
40 |
+
|
41 |
+
prompt = f"""
|
42 |
+
What is the sentiment of the following product review,
|
43 |
+
which is delimited with triple backticks?
|
44 |
+
|
45 |
+
Give your answer as a single word, either "positive" \
|
46 |
+
or "negative".
|
47 |
+
|
48 |
+
Review text: '''{lamp_review}'''
|
49 |
+
"""
|
50 |
+
response = get_completion(prompt)
|
51 |
+
print(response)
|
52 |
+
|
53 |
+
|
54 |
+
prompt = f"""
|
55 |
+
Identify a list of emotions that the writer of the \
|
56 |
+
following review is expressing. Include no more than \
|
57 |
+
five items in the list. Format your answer as a list of \
|
58 |
+
lower-case words separated by commas.
|
59 |
+
|
60 |
+
Review text: '''{lamp_review}'''
|
61 |
+
"""
|
62 |
+
response = get_completion(prompt)
|
63 |
+
print(response)
|
64 |
+
|
65 |
+
|
66 |
+
prompt = f"""
|
67 |
+
Is the writer of the following review expressing anger?\
|
68 |
+
The review is delimited with triple backticks. \
|
69 |
+
Give your answer as either yes or no.
|
70 |
+
|
71 |
+
Review text: '''{lamp_review}'''
|
72 |
+
"""
|
73 |
+
response = get_completion(prompt)
|
74 |
+
print(response)
|
75 |
+
|
76 |
+
|
77 |
+
prompt = f"""
|
78 |
+
Identify the following items from the review text:
|
79 |
+
- Item purchased by reviewer
|
80 |
+
- Company that made the item
|
81 |
+
|
82 |
+
The review is delimited with triple backticks. \
|
83 |
+
Format your response as a JSON object with \
|
84 |
+
"Item" and "Brand" as the keys.
|
85 |
+
If the information isn't present, use "unknown" \
|
86 |
+
as the value.
|
87 |
+
Make your response as short as possible.
|
88 |
+
|
89 |
+
Review text: '''{lamp_review}'''
|
90 |
+
"""
|
91 |
+
response = get_completion(prompt)
|
92 |
+
print(response)
|
93 |
+
|
94 |
+
prompt = f"""
|
95 |
+
Identify the following items from the review text:
|
96 |
+
- Sentiment (positive or negative)
|
97 |
+
- Is the reviewer expressing anger? (true or false)
|
98 |
+
- Item purchased by reviewer
|
99 |
+
- Company that made the item
|
100 |
+
|
101 |
+
The review is delimited with triple backticks. \
|
102 |
+
Format your response as a JSON object with \
|
103 |
+
"Sentiment", "Anger", "Item" and "Brand" as the keys.
|
104 |
+
If the information isn't present, use "unknown" \
|
105 |
+
as the value.
|
106 |
+
Make your response as short as possible.
|
107 |
+
Format the Anger value as a boolean.
|
108 |
+
|
109 |
+
Review text: '''{lamp_review}'''
|
110 |
+
"""
|
111 |
+
response = get_completion(prompt)
|
112 |
+
print(response)
|
113 |
+
|
114 |
+
story = """
|
115 |
+
In a recent survey conducted by the government,
|
116 |
+
public sector employees were asked to rate their level
|
117 |
+
of satisfaction with the department they work at.
|
118 |
+
The results revealed that NASA was the most popular
|
119 |
+
department with a satisfaction rating of 95%.
|
120 |
+
|
121 |
+
One NASA employee, John Smith, commented on the findings,
|
122 |
+
stating, "I'm not surprised that NASA came out on top.
|
123 |
+
It's a great place to work with amazing people and
|
124 |
+
incredible opportunities. I'm proud to be a part of
|
125 |
+
such an innovative organization."
|
126 |
+
|
127 |
+
The results were also welcomed by NASA's management team,
|
128 |
+
with Director Tom Johnson stating, "We are thrilled to
|
129 |
+
hear that our employees are satisfied with their work at NASA.
|
130 |
+
We have a talented and dedicated team who work tirelessly
|
131 |
+
to achieve our goals, and it's fantastic to see that their
|
132 |
+
hard work is paying off."
|
133 |
+
|
134 |
+
The survey also revealed that the
|
135 |
+
Social Security Administration had the lowest satisfaction
|
136 |
+
rating, with only 45% of employees indicating they were
|
137 |
+
satisfied with their job. The government has pledged to
|
138 |
+
address the concerns raised by employees in the survey and
|
139 |
+
work towards improving job satisfaction across all departments.
|
140 |
+
"""
|
141 |
+
|
142 |
+
prompt = f"""
|
143 |
+
Determine five topics that are being discussed in the \
|
144 |
+
following text, which is delimited by triple backticks.
|
145 |
+
|
146 |
+
Make each item one or two words long.
|
147 |
+
|
148 |
+
Format your response as a list of items separated by commas.
|
149 |
+
|
150 |
+
Text sample: '''{story}'''
|
151 |
+
"""
|
152 |
+
response = get_completion(prompt)
|
153 |
+
print(response)
|
154 |
+
|
155 |
+
response.split(sep=',')
|
156 |
+
|
157 |
+
topic_list = [
|
158 |
+
"nasa", "local government", "engineering",
|
159 |
+
"employee satisfaction", "federal government"
|
160 |
+
]
|
161 |
+
|
162 |
+
prompt = f"""
|
163 |
+
Determine whether each item in the following list of \
|
164 |
+
topics is a topic in the text below, which
|
165 |
+
is delimited with triple backticks.
|
166 |
+
|
167 |
+
Give your answer as list with 0 or 1 for each topic.\
|
168 |
+
|
169 |
+
List of topics: {", ".join(topic_list)}
|
170 |
+
|
171 |
+
Text sample: '''{story}'''
|
172 |
+
"""
|
173 |
+
response = get_completion(prompt)
|
174 |
+
print(response)
|
175 |
+
|
176 |
+
response = """nasa: 1
|
177 |
+
space: 2
|
178 |
+
mars: 0
|
179 |
+
exploration: 3"""
|
180 |
+
|
181 |
+
topic_dict = {}
|
182 |
+
for line in response.split(sep='\n'):
|
183 |
+
parts = line.split(': ')
|
184 |
+
if len(parts) == 2:
|
185 |
+
topic_dict[parts[0]] = int(parts[1])
|
186 |
+
|
187 |
+
if topic_dict.get('nasa') == 1:
|
188 |
+
print("ALERT: New NASA story!")
|
189 |
+
|
190 |
+
|
191 |
+
# topic_dict = {i.split(': ')[0]: int(i.split(': ')[1]) for i in response.split(sep='\n')}
|
192 |
+
# if topic_dict['nasa'] == 1:
|
193 |
+
# print("ALERT: New NASA story!")
|
tutorial_5.py
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
|
4 |
+
from dotenv import load_dotenv, find_dotenv
|
5 |
+
_ = load_dotenv(find_dotenv()) # read local .env file
|
6 |
+
|
7 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
8 |
+
|
9 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
10 |
+
messages = [{"role": "user", "content": prompt}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages=messages,
|
14 |
+
temperature=0, # this is the degree of randomness of the model's output
|
15 |
+
)
|
16 |
+
return response.choices[0].message["content"]
|
17 |
+
|
18 |
+
prompt = f"""
|
19 |
+
Translate the following English text to Gujrati: \
|
20 |
+
```Hi, I would like to order a blender```
|
21 |
+
"""
|
22 |
+
response = get_completion(prompt)
|
23 |
+
print(response)
|
24 |
+
|
25 |
+
prompt = f"""
|
26 |
+
Tell me which language this is:
|
27 |
+
```Combien coûte le lampadaire?```
|
28 |
+
"""
|
29 |
+
response = get_completion(prompt)
|
30 |
+
print(response)
|
31 |
+
|
32 |
+
prompt = f"""
|
33 |
+
Translate the following text to French and Spanish
|
34 |
+
and English pirate: \
|
35 |
+
```I want to order a basketball```
|
36 |
+
"""
|
37 |
+
response = get_completion(prompt)
|
38 |
+
print(response)
|
39 |
+
|
40 |
+
prompt = f"""
|
41 |
+
Translate the following text to Spanish in both the \
|
42 |
+
formal and informal forms:
|
43 |
+
'Would you like to order a pillow?'
|
44 |
+
"""
|
45 |
+
response = get_completion(prompt)
|
46 |
+
print(response)
|
47 |
+
|
48 |
+
print("=======================")
|
49 |
+
user_messages = [
|
50 |
+
"La performance du système est plus lente que d'habitude.", # System performance is slower than normal
|
51 |
+
"Mi monitor tiene píxeles que no se iluminan.", # My monitor has pixels that are not lighting
|
52 |
+
"Il mio mouse non funziona", # My mouse is not working
|
53 |
+
"Mój klawisz Ctrl jest zepsuty", # My keyboard has a broken control key
|
54 |
+
"我的屏幕在闪烁",
|
55 |
+
"My name is Vivek Dabhi"
|
56 |
+
]
|
57 |
+
|
58 |
+
for issue in user_messages:
|
59 |
+
prompt = f"Tell me what language this is: ```{issue}```"
|
60 |
+
lang = get_completion(prompt)
|
61 |
+
print(f"Original message ({lang}): {issue}")
|
62 |
+
|
63 |
+
prompt = f"""
|
64 |
+
Translate the following text to English \
|
65 |
+
and Gujrati: ```{issue}```
|
66 |
+
"""
|
67 |
+
response = get_completion(prompt)
|
68 |
+
print(response, "\n")
|
69 |
+
|
70 |
+
print("=======================")
|
71 |
+
|
72 |
+
prompt = f"""
|
73 |
+
Translate the following from slang to a business letter:
|
74 |
+
'Dude, This is Joe, check out this spec on this standing lamp.'
|
75 |
+
"""
|
76 |
+
response = get_completion(prompt)
|
77 |
+
print(response)
|
78 |
+
|
79 |
+
data_json = { "resturant employees" :[
|
80 |
+
{"name":"Shyam", "email":"shyamjaiswal@gmail.com"},
|
81 |
+
{"name":"Bob", "email":"bob32@gmail.com"},
|
82 |
+
{"name":"Jai", "email":"jai87@gmail.com"}
|
83 |
+
]}
|
84 |
+
|
85 |
+
prompt = f"""
|
86 |
+
Translate the following python dictionary from JSON to an HTML \
|
87 |
+
table with column headers and title: {data_json}
|
88 |
+
"""
|
89 |
+
response = get_completion(prompt)
|
90 |
+
print(response)
|
91 |
+
|
92 |
+
from IPython.display import display, Markdown, Latex, HTML, JSON
|
93 |
+
display(HTML(response))
|
94 |
+
|
95 |
+
text = [
|
96 |
+
"The girl with the black and white puppies have a ball.", # The girl has a ball.
|
97 |
+
"Yolanda has her notebook.", # ok
|
98 |
+
"Its going to be a long day. Does the car need it’s oil changed?", # Homonyms
|
99 |
+
"Their goes my freedom. There going to bring they’re suitcases.", # Homonyms
|
100 |
+
"Your going to need you’re notebook.", # Homonyms
|
101 |
+
"That medicine effects my ability to sleep. Have you heard of the butterfly affect?", # Homonyms
|
102 |
+
"This phrase is to cherck chatGPT for speling abilitty" # spelling
|
103 |
+
]
|
104 |
+
for t in text:
|
105 |
+
prompt = f"""Proofread and correct the following text
|
106 |
+
and rewrite the corrected version. If you don't find
|
107 |
+
and errors, just say "No errors found". Don't use
|
108 |
+
any punctuation around the text:
|
109 |
+
```{t}```"""
|
110 |
+
response = get_completion(prompt)
|
111 |
+
print(response)
|
112 |
+
|
113 |
+
|
114 |
+
text = f"""
|
115 |
+
Got this for my daughter for her birthday cuz she keeps taking \
|
116 |
+
mine from my room. Yes, adults also like pandas too. She takes \
|
117 |
+
it everywhere with her, and it's super soft and cute. One of the \
|
118 |
+
ears is a bit lower than the other, and I don't think that was \
|
119 |
+
designed to be asymmetrical. It's a bit small for what I paid for it \
|
120 |
+
though. I think there might be other options that are bigger for \
|
121 |
+
the same price. It arrived a day earlier than expected, so I got \
|
122 |
+
to play with it myself before I gave it to my daughter.
|
123 |
+
"""
|
124 |
+
prompt = f"proofread and correct this review: ```{text}```"
|
125 |
+
response = get_completion(prompt)
|
126 |
+
print(response)
|
127 |
+
|
128 |
+
|
129 |
+
from redlines import Redlines
|
130 |
+
|
131 |
+
diff = Redlines(text,response)
|
132 |
+
display(Markdown(diff.output_markdown))
|
133 |
+
|
134 |
+
|
135 |
+
prompt = f"""
|
136 |
+
proofread and correct this review. Make it more compelling.
|
137 |
+
Ensure it follows APA style guide and targets an advanced reader.
|
138 |
+
Output in markdown format.
|
139 |
+
Text: ```{text}```
|
140 |
+
"""
|
141 |
+
response = get_completion(prompt)
|
142 |
+
display(Markdown(response))
|
tutorial_6.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
|
4 |
+
from dotenv import load_dotenv, find_dotenv
|
5 |
+
_ = load_dotenv(find_dotenv()) # read local .env file
|
6 |
+
|
7 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
8 |
+
|
9 |
+
def get_completion(prompt, model="gpt-3.5-turbo",temperature=0): # Andrew mentioned that the prompt/ completion paradigm is preferable for this class
|
10 |
+
messages = [{"role": "user", "content": prompt}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages=messages,
|
14 |
+
temperature=temperature, # this is the degree of randomness of the model's output
|
15 |
+
)
|
16 |
+
return response.choices[0].message["content"]
|
17 |
+
|
18 |
+
# given the sentiment from the lesson on "inferring",
|
19 |
+
# and the original customer message, customize the email
|
20 |
+
sentiment = "negative"
|
21 |
+
|
22 |
+
# review for a blender
|
23 |
+
review = f"""
|
24 |
+
So, they still had the 17 piece system on seasonal \
|
25 |
+
sale for around $49 in the month of November, about \
|
26 |
+
half off, but for some reason (call it price gouging) \
|
27 |
+
around the second week of December the prices all went \
|
28 |
+
up to about anywhere from between $70-$89 for the same \
|
29 |
+
system. And the 11 piece system went up around $10 or \
|
30 |
+
so in price also from the earlier sale price of $29. \
|
31 |
+
So it looks okay, but if you look at the base, the part \
|
32 |
+
where the blade locks into place doesn’t look as good \
|
33 |
+
as in previous editions from a few years ago, but I \
|
34 |
+
plan to be very gentle with it (example, I crush \
|
35 |
+
very hard items like beans, ice, rice, etc. in the \
|
36 |
+
blender first then pulverize them in the serving size \
|
37 |
+
I want in the blender then switch to the whipping \
|
38 |
+
blade for a finer flour, and use the cross cutting blade \
|
39 |
+
first when making smoothies, then use the flat blade \
|
40 |
+
if I need them finer/less pulpy). Special tip when making \
|
41 |
+
smoothies, finely cut and freeze the fruits and \
|
42 |
+
vegetables (if using spinach-lightly stew soften the \
|
43 |
+
spinach then freeze until ready for use-and if making \
|
44 |
+
sorbet, use a small to medium sized food processor) \
|
45 |
+
that you plan to use that way you can avoid adding so \
|
46 |
+
much ice if at all-when making your smoothie. \
|
47 |
+
After about a year, the motor was making a funny noise. \
|
48 |
+
I called customer service but the warranty expired \
|
49 |
+
already, so I had to buy another one. FYI: The overall \
|
50 |
+
quality has gone done in these types of products, so \
|
51 |
+
they are kind of counting on brand recognition and \
|
52 |
+
consumer loyalty to maintain sales. Got it in about \
|
53 |
+
two days.
|
54 |
+
"""
|
55 |
+
|
56 |
+
prompt = f"""
|
57 |
+
You are a customer service AI assistant.
|
58 |
+
Your task is to send an email reply to a valued customer.
|
59 |
+
Given the customer email delimited by ```, \
|
60 |
+
Generate a reply to thank the customer for their review.
|
61 |
+
If the sentiment is positive or neutral, thank them for \
|
62 |
+
their review.
|
63 |
+
If the sentiment is negative, apologize and suggest that \
|
64 |
+
they can reach out to customer service.
|
65 |
+
Make sure to use specific details from the review.
|
66 |
+
Write in a concise and professional tone.
|
67 |
+
Sign the email as `AI customer agent`.
|
68 |
+
Customer review: ```{review}```
|
69 |
+
Review sentiment: {sentiment}
|
70 |
+
"""
|
71 |
+
response = get_completion(prompt)
|
72 |
+
print(response)
|
73 |
+
|
74 |
+
prompt = f"""
|
75 |
+
You are a customer service AI assistant.
|
76 |
+
Your task is to send an email reply to a valued customer.
|
77 |
+
Given the customer email delimited by ```, \
|
78 |
+
Generate a reply to thank the customer for their review.
|
79 |
+
If the sentiment is positive or neutral, thank them for \
|
80 |
+
their review.
|
81 |
+
If the sentiment is negative, apologize and suggest that \
|
82 |
+
they can reach out to customer service.
|
83 |
+
Make sure to use specific details from the review.
|
84 |
+
Write in a concise and professional tone.
|
85 |
+
Sign the email as `AI customer agent`.
|
86 |
+
Customer review: ```{review}```
|
87 |
+
Review sentiment: {sentiment}
|
88 |
+
"""
|
89 |
+
response = get_completion(prompt, temperature=0.7)
|
90 |
+
print(response)
|