Created
November 4, 2023 08:36
-
-
Save rfeers/f5de49435e55110e3689963232e6ac67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
review = """ | |
I bought last week the latest Samsung washing machine. | |
The product is too expensive for what it is. | |
I won't recommend it to anyone. | |
""" | |
from langchain.llms import OpenAI | |
from langchain import PromptTemplate | |
llm = OpenAI(model_name="text-davinci-003") | |
template = """ | |
For any new review that is sent to you, extract the following information: | |
Product: What product is the buyer reviewing?\ | |
Answer the name of the product. If this information is not found, output unknown. | |
Reason why: Why's the buyer satisfied or unsatisfied? | |
Answer the main reason why. Answer unknown if you do not find the info. | |
Satisfied: Is the buyer satisfied with the product? \ | |
Answer True if yes, False if not or unknown. | |
Format the output as JSON with the following keys: | |
Product | |
Satisfaction | |
Reason | |
review: {review} | |
""" | |
prompt = PromptTemplate( | |
input_variables=["review"], | |
template=template, | |
) | |
final_prompt = prompt.format(review=review ) | |
print(f"LLM Output: {llm(final_prompt)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment