Chinese notes of ChatGPT Prompt Engineering for Developers, I
Project Introduction
Project significance
Project Audience
Project highlights
content syllabus
-
Introduction -
Guidelines for Compiling Prompt -
Iterative prompt development Prompt Iterative -
Text Summary -
Text Inferring -
Text Transforming -
Text Expanding -
Chat Chatbot -
summary
Chapter I Introduction
Chapter II Principles of Compiling Prompt
1、 Environment configuration
pip install openai
pip install -U python-dotenv
#Import your API-KEY into the system environment variable ! export OPENAI_API_KEY='api-key'
import openai import os from dotenv import load_dotenv, find_dotenv #Import third-party library _ = load_dotenv(find_dotenv()) #Reading environment variables in the system openai.api_key = os.getenv('OPENAI_API_KEY') #Set API_KEY
#A function that encapsulates the OpenAI interface. The parameter is Prompt, and the corresponding result is returned def get_completion(prompt, model="gpt-3.5-turbo"): ''' Prompt: corresponding prompt Model: The called model is gpt-3.5-turbo (ChatGPT) by default. Users qualified for internal testing can select gpt-4 ''' messages = [{"role": "user", "content": prompt}] response = openai.ChatCompletion.create( model=model, messages=messages, Temperature=0, # temperature coefficient of model output, control the randomness of output ) #Call the ChatCompletion interface of OpenAI return response.choices[0].message["content"]
2、 Two basic principles
Principle 1: Write clear and specific instructions
text = f""" You should provide as clear and specific instructions as possible to express the tasks you want the model to perform\ This will guide the model toward the desired output and reduce the likelihood of receiving irrelevant or incorrect responses\ Don't confuse writing clear tips with writing short ones\ In many cases, longer prompts can provide more clarity and contextual information for the model, resulting in more detailed and relevant output. """ #Text content to be summarized prompt = f""" Summarize the text enclosed in three back quotes into one sentence. ```{text}``` """ #Instruction content, use '' to separate instructions and content to be summarized response = get_completion(prompt) print(response)
Provide clear and specific instructions, avoid irrelevant or incorrect responses, and do not confuse clear and short writing. Longer prompts can provide more clarity and contextual information, leading to more detailed and relevant output.
prompt = f""" Please generate a list of three fictional books, including the title, author and category\ It is provided in JSON format, including the following keys: book_id title、author、genre。 """ response = get_completion(prompt) print(response)
{ "books": [ { "book_id": 1, "title": "The Shadow of the Wind", "author": "Carlos Ruiz Zafón", "genre": "Mystery" }, { "book_id": 2, "title": "The Name of the Wind", "author": "Patrick Rothfuss", "genre": "Fantasy" }, { "book_id": 3, "title": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "genre": "Science Fiction" } ] }
#Stepped text text_1 = f""" It's easy to make a cup of tea. First, we need to boil the water\ While waiting, take a cup and put the tea bag in\ Once the water is hot enough, pour it on the tea bag\ Wait for a while and let the tea soak. After a few minutes, take out the tea bag\ If you like, you can add some sugar or milk to taste\ In this way, you can enjoy a cup of delicious tea. """ prompt = f""" You will get the text enclosed in three quotation marks\ If it contains a series of instructions, these instructions need to be rewritten in the following format: Step 1 - Step 2 - … Step N - If the text does not contain a series of instructions, write "No steps provided" directly. " \"\"\"{text_1}\"\"\" """ response = get_completion(prompt) Print ("Summary of Text 1:") print(response)
Summary of Text 1: Step 1 - boil the water. Step 2 - Take a cup and put the tea bag in. Step 3 - Pour boiling water on the tea bag. Step 4 - Wait a few minutes for the tea to soak. Step 5 - Take out the tea bag. Step 6 - If you like, you can add some sugar or milk to taste. Step 7 - In this way, you can enjoy a cup of delicious tea.
#Stepless text text_2 = f""" The sun is shining and the birds are singing today\ It's a nice day to go for a walk in the park\ The flowers are in full bloom, and the branches are swaying gently in the breeze\ People go out and enjoy the beautiful weather. Some people are having a picnic. Some people are playing games or relaxing on the grass\ This is a perfect day to spend outdoors and enjoy the beauty of nature. """ prompt = f""" You will get the text enclosed in three quotation marks\ If it contains a series of instructions, these instructions need to be rewritten in the following format: Step 1 - Step 2 - … Step N - If the text does not contain a series of instructions, write "No steps provided" directly. " \"\"\"{text_2}\"\"\" """ response = get_completion(prompt) Print ("Summary of Text 2:") print(response)
Summary of Text 2: No steps provided.
prompt = f""" Your task is to answer questions in a consistent style. <Child>: Teach me patience. <Grandparents>: The river where the deepest canyon was dug originates from an inconspicuous spring; The most magnificent symphony begins with a single note; The most complex tapestry begins with a lonely thread. <Children>: Teach me resilience. """ response = get_completion(prompt) print(response)
<Grandparents>: Resilience is like a tree. It needs to experience wind and rain, winter and summer to grow stronger. In life, we also need to experience various setbacks and difficulties to exercise resilience. Remember, don't give up easily, stick to it, you will find yourself stronger.
Principle 2: Give the model time to think
text = f""" In a charming village, brother and sister Jack and Jill set out to fetch water from a mountaintop well\ They climbed up while singing happy songs\ Unfortunately, Jack stumbled over a stone and rolled down the mountain, followed by Jill\ Although they were slightly injured, they still returned to their warm home\ Despite such an accident, their spirit of adventure has not weakened and they continue to explore happily. """ # example 1 prompt_1 = f""" Do the following: 1 - Summarize the following text enclosed in three back quotes in one sentence. 2 - Translate the abstract into French. 3 - List each person's name in the French summary. 4 - Output a JSON object containing the following keys: French_summary, num_names. Please separate your answers with line breaks. Text: ```{text}``` """ response = get_completion(prompt_1) print("prompt 1:") print(response)
prompt 1: 1 - Brother and sister had an accident while fetching water in the well at the top of the mountain, but they still kept an adventurous spirit. 2-Dans un charmant village, les frère et sœur Jack et Jill partent chercher de l'eau dans un puits au sommet de la montagne. Malheureusement, Jack trébuche sur une pierre et tombe de la montagne, suivi de près par Jill. Bien qu'ils soient légèrement blessés, ils retournent chez eux chaleureusement. Malgré cet accident, leur esprit d'aventure ne diminue pas et ils continuent à explorer joyeusement. 3-Jack, Jill 4-{ "French_summary": "Dans un charmant village, les frère et sœur Jack et Jill partent chercher de l'eau dans un puits au sommet de la montagne. Malheureusement, Jack trébuche sur une pierre et tombe de la montagne, suivi de près par Jill. Bien qu'ils soient légèrement blessés, ils retournent chez eux chaleureusement. Malgré cet accident, leur esprit d'aventure ne diminue pas et ils continuent à explorer joyeusement. ", "num_names": 2 }
prompt_2 = f""" 1 - Summarize the following text enclosed with<>in one sentence. 2 - Translate the abstract into English. 3 - List each name in the English summary. 4 - Output a JSON object containing the following keys: English_summary, num_names. Please use the following format: Text:<Text to summarize> Summary:<Summary> Translation:<translation of abstract> Name:<name list in English summary> Output JSON:<JSON with English_summary and num_names> Text: <{text}> """ response = get_completion(prompt_2) print("\nprompt 2:") print(response)
prompt 2: Abstract: Brother and sister Jack and Jill took an adventure in the charming village. Unfortunately, they returned home after falling, but they were still full of adventure spirit. Translator: In a charging village, siblings Jack and Jill set out to fetch water from a mountaintop well. While climbing and singing, Jack trips on a stone and tumbles down the mountain, with Jill following closely behind. Despite some bruises, they make it back home safely. Their adventurous spirit remains undiminished as they continue to explore with joy. Name: Jack, Jill Output JSON: {"English_summary": "In a charging village, siblings Jack and Jill set out to fetch water from a mountaintop well. While climbing and singing, Jack trips on a stone and tumbles down the mountain, with Jill following closely behind. Despite some bruises, they make it back home safely. Their adventurous spirit remains undiminished as they continue to explore with joy.", "num_names": 2}
prompt = f""" Judge whether the student's solution is correct. Question: I'm building a solar power station, and I need help with financial calculations. The cost of land is $100 per square foot I can buy solar panels for 250 dollars/square foot I have negotiated a maintenance contract, which requires a fixed annual payment of $100000 and an additional payment of $10 per square foot As a function of square feet, what is the total cost of the first year's operation. Student's solution: Let x be the size of the power station, in square feet. cost: Land cost: 100x Solar panel cost: 250x Maintenance cost: $100000+100x Total cost: 100x+250x+100000 US dollars+100x=450x+100000 US dollars """ response = get_completion(prompt) print(response)
The student's solution is correct.
prompt = f""" Please judge whether the student's solution is correct. Please solve this problem through the following steps: Step: First, solve problems by yourself. Then compare your solution with the student's solution and evaluate whether the student's solution is correct. Do not decide whether the student's solution is correct until you complete the problem yourself. Use the following format: Question: Question Text Student's solution: student's solution text Actual Solution and Step: Actual Solution and Step Text Whether the student's solution is the same as the actual solution: Yes or No Student's grade: correct or incorrect Question: I'm building a solar power station, and I need help with financial calculations. -The cost of land is $100 per square foot -I can buy solar panels at $250 per square foot -I have negotiated a maintenance contract, which requires a fixed annual payment of $100000 and an additional payment of $10 per square foot As a function of square feet, what is the total cost of the first year's operation. Student's solution: Let x be the size of the power station, in square feet. cost: 1. Land cost: 100x 2. Solar panel cost: 250x 3. Maintenance cost: 100000+100x Total cost: 100x+250x+100000+100x=450x+100000 Actual solutions and steps: """ response = get_completion(prompt) print(response)
Correct solutions and steps: 1. Calculate the land cost: $100/square foot * x square foot=$100x 2. Calculate the cost of solar panel: 250 dollars/square foot * x square foot=250x dollars 3. Calculate the maintenance cost: $100000+$10/square foot * x square foot=$100000+$10x 4. Calculate the total cost: 100x USD+250x USD+100000 USD+10x USD=360x+100000 USD Whether the student's solution is the same as the actual solution: No Student's score: incorrect
3、 Limitations
prompt = f""" Tell me about AeroGlide UltraSlim Smart Toothrush produced by Boie Company """ response = get_completion(prompt) print(response)
AeroGlide UltraSlim Smart Toothbrush produced by Boie Company is a smart toothbrush with the following characteristics: 1. Ultra thin design: the brush head is only 0.8mm thick, which can easily enter the deep mouth and clean more thoroughly. 2. Intelligent induction: The toothbrush is equipped with intelligent induction technology, which can automatically identify the position and direction of the brush head to ensure that each part is fully cleaned. 3. Efficient cleaning: The toothbrush adopts high-speed vibration technology, which can reach 40000 times per minute, and can effectively remove dental plaque and stains. 4. Easy to carry: The toothbrush adopts a portable design, which can be easily put into the pocket or travel bag for oral cleaning anytime and anywhere. 5. Environmental protection materials: toothbrushes are made of environmental protection materials, free of harmful substances and environmentally friendly. In a word, AeroGlide UltraSlim Smart Toothbrush produced by Boie Company is an efficient, intelligent and environmentally friendly toothbrush that can help users easily maintain oral health.
Chapter III Iterative Prompt Development
Environment configuration
import openai import os from dotenv import load_dotenv, find_dotenv #Import third-party library _ = load_dotenv(find_dotenv()) #Reading environment variables in the system openai.api_key = os.getenv('OPENAI_API_KEY') #Set API_KEY
#A function that encapsulates the OpenAI interface. The parameter is Prompt, and the corresponding result is returned def get_completion(prompt, model="gpt-3.5-turbo"): ''' Prompt: corresponding prompt Model: The called model is gpt-3.5-turbo (ChatGPT) by default. Users qualified for internal testing can select gpt-4 ''' messages = [{"role": "user", "content": prompt}] response = openai.ChatCompletion.create( model=model, messages=messages, Temperature=0, # temperature coefficient of model output, control the randomness of output ) #Call the ChatCompletion interface of OpenAI return response.choices[0].message["content"]
Task - generate a marketing product description from the product description
#Example: Product manual fact_sheet_chair = """ summary Part of the beautiful medieval style office furniture series, including filing cabinets, desks, bookcases, conference tables, etc. Various housing colors and base coatings are available. Plastic front and rear backrest decoration (SWC-100) or full decoration of 10 kinds of fabrics and 6 kinds of leather (SWC-110) are available. Base coating options are: stainless steel, matte black, gloss white or chrome. Chairs may or may not have arms. Applicable to family or business places. Meet the contract use qualification. structure Plastic coated aluminum base for five wheels. Pneumatic chair adjustment, convenient for lifting. size Width 53 cm | 20.87 in Depth 51 cm | 20.08 in Height 80 cm | 31.50 in Seat height 44 cm | 17.32 in Seat depth 41 cm | 16.14 in option Soft or hard floor wheel options. Two seat foam densities are available: medium (1.8 lbs/cubic foot) or high (2.8 lbs/cubic foot). No handrail or 8 position PU handrail. Material Science Housing base slide Cast aluminum with modified nylon PA6/PA66 coating. Shell thickness: 10 mm. chair HD36 foam Country of origin Italy """
#Tip: Create a marketing description based on the manual prompt = f""" Your task is to help the marketing team create a product marketing description based on the technical specification. Write a product description according to the information provided in the marked technical specification. Technical description: ` ` ` {fact_sheet_hair}``` """ response = get_completion(prompt) print(response)
Product description: We are proud to launch a beautiful series of medieval office furniture, including filing cabinets, desks, bookcases, conference tables, etc. Our products use a variety of shell colors and base coatings to meet your personalized needs. You can choose the plastic front and rear backrest decoration (SWC-100) or the comprehensive decoration of 10 kinds of fabrics and 6 kinds of leather (SWC-110) to make your office more comfortable and fashionable. Our base coating options include stainless steel, matte black, gloss white or chrome to meet your different needs. The chair can be used with or without arms, and is suitable for family or business places. Our products are qualified for contract use, providing you with more reliable protection. Our products use five wheels of plastic coated aluminum base, pneumatic chair adjustment, easy lifting. The dimensions are 53 cm | 20.87 inch wide, 51 cm | 20.08 inch deep, 80 cm | 31.50 inch high, 44 cm | 17.32 inch high and 41 cm | 16.14 inch deep, providing you with a comfortable use experience. Our products also provide soft floor or hard floor roller options. Two kinds of seat foam density are available: medium (1.8 pounds/cubic foot) or high (2.8 pounds/cubic foot), and no armrest or eight position PU armrest to meet your different needs. Our products use modified nylon PA6/PA66 coating cast aluminum shell base slider, the shell thickness is 10 mm, and the seat uses HD36 foam, providing you with a more comfortable use experience. The country of origin of our products is Italy, providing you with more high-quality quality assurance.
Problem 1: The generated text is too long
#The optimized Prompt is required to generate no more than 50 words of description prompt = f""" Your task is to help a marketing team create a description for a retail website of a product based on a technical fact sheet. Write a product description based on the information provided in the technical specifications delimited by triple backticks. Use at most 50 words. Technical specifications: ```{fact_sheet_chair}``` """ response = get_completion(prompt) print(response)
Introducing our beautiful medieval-style office furniture collection, including filing cabinets, desks, bookcases, and conference tables. Choose from a variety of shell colors and base coatings, with optional plastic or fabric/leather decoration. The chair features a plastic-coated aluminum base with five wheels and pneumatic height adjustment. Perfect for home or commercial use. Made in Italy.
lst = response.split() print(len(lst))
fifty-four
#The optimized Prompt is required to generate no more than 50 words of description prompt = f""" Your task is to help the marketing team create a retail website description of the product based on the technical specification. Write a product description according to the information provided in the marked technical specification. Use up to 50 words. Technical Specifications: ` ` ` {fact_sheet_hair}``` """ response = get_completion(prompt) print(response)
Medieval style office furniture series, including file cabinet, desk, bookcase, conference table, etc. Various colors and coatings are available, with or without handrails. Base coating options are stainless steel, matte black, gloss white or chrome. It is applicable to family or business places and meets the contract use qualification. Made in Italy.
#Since Chinese requires word segmentation, the overall length is calculated here directly len(response)
ninety-seven
Problem 2: The text focuses on the wrong details
#The optimized Prompt explains the object-oriented nature and focus prompt = f""" Your task is to help the marketing team create a retail website description of the product based on the technical specification. Write a product description according to the information provided in the marked technical specification. This description is intended for furniture retailers, so it should be of a technical nature and focus on the material structure of the product. Use up to 50 words. Technical Specifications: ` ` ` {fact_sheet_hair}``` """ response = get_completion(prompt) print(response)
This medieval style office furniture series includes file cabinets, desks, bookcases and conference tables, which are suitable for home or business places. A variety of housing colors and base coatings are available, and the base coating options are stainless steel, matte black, shiny white or chrome. Chairs can be equipped with or without armrests, soft floor or hard floor rollers can be selected, and two kinds of seat foam density can be selected. The sliding part of the shell base is made of cast aluminum coated with modified nylon PA6/PA66, and the seat is made of HD36 foam. The country of origin is Italy.
#Further prompt = f""" Your task is to help the marketing team create a retail website description of the product based on the technical specification. Write a product description according to the information provided in the marked technical specification. This description is intended for furniture retailers, so it should be of a technical nature and focus on the material structure of the product. At the end of the description, include the product ID of each 7 characters in the technical specification. Use up to 50 words. Technical Specifications: ` ` ` {fact_sheet_hair}``` """ response = get_completion(prompt) print(response)
This medieval style office furniture series includes file cabinets, desks, bookcases and conference tables, which are suitable for home or business places. A variety of housing colors and base coatings are available, and the base coating options are stainless steel, matte black, shiny white or chrome. The chair can be equipped with or without armrests, and can be decorated with plastic front and rear backrest or 10 kinds of fabrics and 6 kinds of leather. The seat adopts HD36 foam, which can be medium or high density. The height of the seat is 44cm, and the depth is 41cm. The sliding part of the housing base is made of cast aluminum coated with modified nylon PA6/PA66, and the thickness of the housing is 10mm. The country of origin is Italy. Product ID: SWC-100/SWC-110.
Question 3: Need a description in tabular form
#It is required to extract information and organize it into a table, and specify the column, table name and format of the table prompt = f""" Your task is to help the marketing team create a retail website description of the product based on the technical specification. Write a product description according to the information provided in the marked technical specification. This description is intended for furniture retailers, so it should be of a technical nature and focus on the material structure of the product. At the end of the description, include the product ID of each 7 characters in the technical specification. After the description, include a table to provide the dimensions of the product. The table should have two columns. The first column contains the name of the dimension. The second column contains measurements in inches only. Name the table Product Size. Format all content in HTML format that can be used for the website. Place the description in the<div>element. Technical Specifications: ` ` ` {fact_sheet_hair}``` """ response = get_completion(prompt) print(response)
<div> <h2>Medieval style office furniture series chairs</h2> <p>This chair is part of the Medieval style office furniture series, suitable for home or business places. It is available in a variety of shell colors and base coatings, including stainless steel, matte black, gloss white or chrome. You can select chairs with or without armrests, and soft or hard floor wheel options. In addition, you can choose between two seat foam densities: medium (1.8 pounds/cubic foot) or high (2.8 pounds/cubic foot)</ p> <p>The sliding part of the chair shell base is cast aluminum coated with modified nylon PA6/PA66, and the shell thickness is 10mm. The seat adopts HD36 foam, and the base is a plastic coated aluminum base with five wheels, which can be adjusted by pneumatic chair for easy lifting. In addition, the chair meets the contract qualification and is your ideal choice</ p> <p>Product ID: SWC-100</p> </div> <table> <caption>Product size</caption> <tr> <th>Width</th> <td>20.87 in</td> </tr> <tr> <th>Depth</th> <td>20.08 in</td> </tr> <tr> <th>Height</th> <td>31.50 in</td> </tr> <tr> <th>Seat height</th> <td>17.32 in</td> </tr> <tr> <th>Seat depth</th> <td>16.14 in</td> </tr> </table>
#The table is rendered in HTML format and loaded from IPython.display import display, HTML display(HTML(response))
Medieval style office furniture series chairs
| |
---|---|
| |
| |
| |
| |
Chapter IV Text Summary
introduction
import openai import os OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY") openai.api_key = OPENAI_API_KEY def get_completion(prompt, model="gpt-3.5-turbo"): messages = [{"role": "user", "content": prompt}] response = openai.ChatCompletion.create( model=model, messages=messages, Temperature=0, the lower the # value, the lower the randomness of the output text ) return response.choices[0].message["content"]
Single text summary Prompt experiment
prod_review_zh = """ This panda doll is my birthday gift for my daughter. She likes it very much and takes it everywhere. The doll is soft, super cute, and has a nice facial expression. But compared with the price, It's a little small. I feel I can buy a bigger one at the same price elsewhere. The express arrived a day earlier than expected, so I had a party before giving it to my daughter. """
Limit output text length
prompt = f""" Your task is to generate a short summary of product reviews from e-commerce websites. Please summarize the comment text between the three back quotes, up to 30 words. Comments: ` ` ` {prod_review_zh}``` """ response = get_completion(prompt) print(response)
The cute soft panda doll is liked by her daughter. Her facial expression is kind, but the price is a little expensive. The express delivery arrived one day in advance.
Key perspectives
prompt = f""" Your task is to generate a short summary of product reviews from e-commerce websites. Please summarize the comment text between the three back quotes, with a maximum of 30 words, and focus on product transportation. Comments: ` ` ` {prod_review_zh}``` """ response = get_completion(prompt) print(response)
The delivery arrived in advance. The panda doll is soft and cute, but it is a little small, and the price is not very cost-effective.
prompt = f""" Your task is to generate a short summary of product reviews from e-commerce websites. Please summarize the comment text between the three back quotes, with a maximum of 30 words, and focus on product price and quality. Comments: ` ` ` {prod_review_zh}``` """ response = get_completion(prompt) print(response)
The cute soft panda doll has a friendly facial expression, but its price is a little high and its size is small. Express delivery arrived one day ahead of schedule.
Key information extraction
prompt = f""" Your task is to extract relevant information from product reviews on e-commerce websites. Please extract the information related to product transportation from the comment text between the following three back quotes, up to 30 words. Comments: ` ` ` {prod_review_zh}``` """ response = get_completion(prompt) print(response)
The express delivery arrived a day earlier than expected.
Multiple Text Summarization Prompt Experiment
review_1 = prod_review # review for a standing lamp review_2 = """ Needed a nice lamp for my bedroom, and this one \ had additional storage and not too high of a price \ point. Got it fast - arrived in 2 days. The string \ to the lamp broke during the transit and the company \ happily sent over a new one. Came within a few days \ as well. It was easy to put together. Then I had a \ missing part, so I contacted their support and they \ very quickly got me the missing piece! Seems to me \ to be a great company that cares about their customers \ and products. """ # review for an electric toothbrush review_3 = """ My dental hygienist recommended an electric toothbrush, \ which is why I got this. The battery life seems to be \ pretty impressive so far. After initial charging and \ leaving the charger plugged in for the first week to \ condition the battery, I've unplugged the charger and \ been using it for twice daily brushing for the last \ 3 weeks all on the same charge. But the toothbrush head \ is too small. I’ve seen baby toothbrushes bigger than \ this one. I wish the head was bigger with different \ length bristles to get between teeth better because \ this one doesn’t. Overall if you can get this one \ around the $50 mark, it's a good deal. The manufactuer's \ replacements heads are pretty expensive, but you can \ get generic ones that're more reasonably priced. This \ toothbrush makes me feel like I've been to the dentist \ every day. My teeth feel sparkly clean! """ # review for a blender review_4 = """ So, they still had the 17 piece system on seasonal \ sale for around $49 in the month of November, about \ half off, but for some reason (call it price gouging) \ around the second week of December the prices all went \ up to about anywhere from between $70-$89 for the same \ system. And the 11 piece system went up around $10 or \ so in price also from the earlier sale price of $29. \ So it looks okay, but if you look at the base, the part \ where the blade locks into place doesn’t look as good \ as in previous editions from a few years ago, but I \ plan to be very gentle with it (example, I crush \ very hard items like beans, ice, rice, etc. in the \ blender first then pulverize them in the serving size \ I want in the blender then switch to the whipping \ blade for a finer flour, and use the cross cutting blade \ first when making smoothies, then use the flat blade \ if I need them finer/less pulpy). Special tip when making \ smoothies, finely cut and freeze the fruits and \ vegetables (if using spinach-lightly stew soften the \ spinach then freeze until ready for use-and if making \ sorbet, use a small to medium sized food processor) \ that you plan to use that way you can avoid adding so \ much ice if at all-when making your smoothie. \ After about a year, the motor was making a funny noise. \ I called customer service but the warranty expired \ already, so I had to buy another one. FYI: The overall \ quality has gone done in these types of products, so \ they are kind of counting on brand recognition and \ consumer loyalty to maintain sales. Got it in about \ two days. """ reviews = [review_1, review_2, review_3, review_4]
for i in range(len(reviews)): prompt = f""" Your task is to generate a short summary of a product \ review from an ecommerce site. Summarize the review below, delimited by triple \ backticks in at most 20 words. Review: ```{reviews[i]}``` """ response = get_completion(prompt) print(i, response, "\n")
0 Soft and cute panda plush toy loved by daughter, but a bit small for the price. Arrived early. 1 Affordable lamp with storage, fast shipping, and excellent customer service. Easy to assemble and missing parts were quickly replaced. 2 Good battery life, small toothbrush head, but effective cleaning. Good deal if bought around $50. 3 The product was on sale for $49 in November, but the price increased to $70-$89 in December. The base doesn't look as good as previous editions, but the reviewer plans to be gentle with it. A special tip for making smoothies is to freeze the fruits and vegetables beforehand. The motor made a funny noise after a year, and the warranty had expired. Overall quality has decreased.