55from streamlit_chat import message
66from typing import Dict , Any
77
8-
98# ← Move imports to module level (critical for patching!)
109# requests is now available as app.frontend.requests
1110
@@ -14,6 +13,7 @@ def make_prediction(payload: Dict[str, Any]) -> str:
1413 """Helper to call prediction endpoint"""
1514 try :
1615 response = requests .post ("http://localhost:8000/predict" , json = payload )
16+
1717 if response .status_code == 200 :
1818 score = response .json ()["predicted_success_score" ]
1919 return f"Predicted Success Score: { score :.2f} "
@@ -29,6 +29,7 @@ def ask_question(question: str) -> str:
2929 response = requests .post (
3030 "http://localhost:8000/ask" , json = {"question" : question }
3131 )
32+
3233 if response .status_code == 200 :
3334 return response .json ()["answer" ]
3435 else :
@@ -58,6 +59,18 @@ def main():
5859 # ... all your inputs ...
5960 Original_Price = st .number_input ("Original Price" , value = 1650 )
6061 Discount_Price = st .number_input ("Discount Price" , value = 725 )
62+ Number_of_Ratings = st .number_input ("Number of Ratings" , value = 31 )
63+ Positive_Seller_Ratings = st .number_input (
64+ "Positive Seller Ratings" , value = 86
65+ )
66+ Ship_On_Time = st .number_input ("Ship On Time" , value = 0 )
67+ Chat_Response_Rate = st .number_input ("Chat Response Rate" , value = 93 )
68+ No_of_products_to_be_sold = st .number_input (
69+ "No. of products to be sold" , value = 113.79
70+ )
71+ Category = st .text_input ("Category" , value = "Watches, Bags, Jewellery" )
72+ Delivery_Type = st .text_input ("Delivery Type" , value = "Free Delivery" )
73+ Flagship_Store = st .text_input ("Flagship Store" , value = "No" )
6174 # ... etc ...
6275
6376 submitted = st .form_submit_button ("Predict Success Score" )
@@ -66,7 +79,14 @@ def main():
6679 payload = {
6780 "Original_Price" : Original_Price ,
6881 "Discount_Price" : Discount_Price ,
69- # ... include all fields ...
82+ "Number_of_Ratings" : Number_of_Ratings ,
83+ "Positive_Seller_Ratings" : Positive_Seller_Ratings ,
84+ "Ship_On_Time" : Ship_On_Time ,
85+ "Chat_Response_Rate" : Chat_Response_Rate ,
86+ "No_of_products_to_be_sold" : No_of_products_to_be_sold ,
87+ "Category" : Category ,
88+ "Delivery_Type" : Delivery_Type ,
89+ "Flagship_Store" : Flagship_Store ,
7090 }
7191 result = make_prediction (payload )
7292 if "Success Score" in result :
0 commit comments