■ PromptTemplate 클래스를 사용해 체계적으로 제품 리뷰 프롬프트를 만드는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from langchain.prompts import PromptTemplate promptTemplateString = """Given the following product review, conduct a comprehensive analysis to extract key aspects mentioned by the customer, with a focus on evaluating the product's design and distinguishing between positive aspects and areas for improvement. Identify primary features or attributes of the product that the customer appreciated or highlighted, specifically looking for mentions related to the feel of the keys, sound produced by the keys, overall user experience, charging aspect, and the design of the product, etc. Assess the overall tone of the review (positive, neutral, or negative) based on the sentiment expressed about these attributes. Additionally, provide a detailed evaluation of the design, outline the positive aspects that the customer enjoyed, and note any areas of improvement or disappointment mentioned. Extract the customer's rating of the product on a scale of 1 to 5, as indicated at the beginning of the review. Summarize your findings in a structured JSON format, including an array of keywords, evaluations for design, satisfaction points, improvement areas, the assessed tone, and the numerical rating. INPUT : {input} """ promptTemplate = PromptTemplate.from_template(promptTemplateString) |
※ pip install langchain 명령을 실행했다.