-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from langchain_community.document_loaders import TextLoader | ||
from langchain_core.prompts import ChatPromptTemplate | ||
from langchain_openai import ChatOpenAI | ||
from langchain_core.pydantic_v1 import BaseModel,Field | ||
|
||
class Reviews(BaseModel): | ||
sentiment: str =Field(description="the sentiment of the text") | ||
emotion: str=Field(description="what is the emotion expressed from text , is satisfied or unsatisfied") | ||
items:str=Field(description="the food , drinks or any the specific items mentioned") | ||
|
||
tagging_prompt=ChatPromptTemplate.from_template( | ||
""" | ||
Extract the desired information from the following passage. | ||
Only extraxct the properties mentioned in the "Reviews" function | ||
passage: | ||
{input} | ||
""" | ||
) | ||
llm=ChatOpenAI(model="gpt-4o").with_structured_output(Reviews) | ||
tagging_chain=tagging_prompt|llm | ||
|
||
loader=TextLoader(r"C:\Users\welcome\OneDrive\Documents\GitHub\LLMtutorial\tutorial96\review.txt") | ||
docs=loader.load() | ||
reviews=docs[0].page_content.split("\n") | ||
for review in reviews: | ||
response=tagging_chain.invoke({"input":review}) | ||
print(response) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Absolutely loved the ambiance at Savory Symphony! The roasted duck was cooked to perfection, and the staff was incredibly attentive. A must-visit for any food lover. | ||
What a fantastic experience! The live music perfectly complemented the gourmet dishes, creating a truly symphonic dining experience. The dessert platter is a dream! | ||
Savory Symphony never disappoints! Their wine selection is impressive and pairs wonderfully with their signature seafood dishes. Great spot for a romantic dinner | ||
I took my parents here for their anniversary, and we were all blown away by the quality of the food and service. The chef even came out to greet us! | ||
The brunch menu at Savory Symphony is exceptional. The eggs Benedict with homemade hollandaise is my new favorite. | ||
I was not impressed with the long wait times despite having a reservation. The food was decent, but not worth the hype. | ||
Found the menu to be quite limited and the prices too high for the quality offered. The service was slow, and the waiters seemed overwhelmed. | ||
Had high expectations but left disappointed. The steak was overcooked, and the music was too loud, making conversation difficult. | ||
Not what I expected from a place with such good reviews. The pasta was underseasoned, and the tables were too close together, lacking privacy. | ||
The worst dining experience in a while. The food came out at different times for everyone at our table, and my dish was cold. Will not be returning. |
Binary file not shown.