updates on the backend
This commit is contained in:
30
scripts/test_rag.py
Normal file
30
scripts/test_rag.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import sys
|
||||
from app.services.rag_service import retrieve, answer_query
|
||||
from app.services.query_intent import extract_max_price, extract_brand_mention, is_count_query
|
||||
|
||||
def run_test():
|
||||
queries = [
|
||||
"How many products are there in Cadbury?",
|
||||
"Suggest low sugar biscuits",
|
||||
"Recommend Paneer under ₹150",
|
||||
"Suggest panner less than ₹100",
|
||||
]
|
||||
|
||||
for q in queries:
|
||||
print("="*60)
|
||||
print(f"QUERY: {q}")
|
||||
print(f" Is Count: {is_count_query(q)}")
|
||||
print(f" Brand Mention: {extract_brand_mention(q)}")
|
||||
print(f" Max Price: {extract_max_price(q)}")
|
||||
|
||||
prods = retrieve(q)
|
||||
print(" Retrieved Products:")
|
||||
for p in prods[:5]:
|
||||
print(f" - {p.brand} | {p.product_name} | Price: {p.price_range} | Cat: {p.category}")
|
||||
|
||||
ans = answer_query(q)
|
||||
print(f" ANSWER:\n{ans.answer}")
|
||||
print("="*60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_test()
|
||||
Reference in New Issue
Block a user