-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (20 loc) · 775 Bytes
/
main.py
File metadata and controls
27 lines (20 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from langchain_ollama.llms import OllamaLLM
from langchain_core.prompts import ChatPromptTemplate
from vector import retriever
model = OllamaLLM(model="llama3.2")
template = """
You are an expert in answering questions about a pizza restaurant.
here are some relevant reviews: {reviews}
here is the question to answer: {question}
"""
prompt = ChatPromptTemplate.from_template(template)
chain = prompt | model
while True:
print("====================================")
question = input("Ask your question (q to quit): ")
print("====================================")
if question == "q":
break
reviews = retriever.invoke(question)
result = chain.invoke({"reviews":reviews,"question":question})
print(result)