binaychandra commited on
Commit
e710ae2
·
1 Parent(s): 82b91c3

Added ai feature

Browse files
Files changed (1) hide show
  1. app.py +36 -1
app.py CHANGED
@@ -12,7 +12,7 @@ app = FastAPI()
12
  # Configure CORS settings
13
  app.add_middleware(
14
  CORSMiddleware,
15
- allow_origins=["https://npd-studio.vercel.app/"], # List of allowed origins
16
  allow_credentials=True,
17
  allow_methods=["*"], # Allow all HTTP methods
18
  allow_headers=["*"], # Allow all headers
@@ -102,6 +102,41 @@ def run_xpipeline():
102
 
103
  return nb_output
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  @app.get("/items/{item_id}")
106
  def read_item(item_id: int, q: Union[str, None] = None):
107
  return {"item_id": item_id, "q": q}
 
12
  # Configure CORS settings
13
  app.add_middleware(
14
  CORSMiddleware,
15
+ allow_origins=["*"], # Allow all origins in development
16
  allow_credentials=True,
17
  allow_methods=["*"], # Allow all HTTP methods
18
  allow_headers=["*"], # Allow all headers
 
102
 
103
  return nb_output
104
 
105
+ from pydantic import BaseModel
106
+
107
+ class QueryRequest(BaseModel):
108
+ query: str
109
+
110
+ @app.post("/query_ai")
111
+ async def query_ai(request: QueryRequest):
112
+ try:
113
+ # TODO: Implement actual AI processing here
114
+ # For now, return sample product data
115
+ return {
116
+ "status": "success",
117
+ "data": {
118
+ "baseCode": "CHOC123",
119
+ "scenario": "New Product Launch",
120
+ "weekDate": "2025-01-15",
121
+ "levelOfSugar": "Medium",
122
+ "packGroup": "Premium",
123
+ "productRange": "Dark Chocolate",
124
+ "segment": "Luxury",
125
+ "superSegment": "Premium Confectionery",
126
+ "baseNumberInMultipack": 6,
127
+ "flavor": "Dark Chocolate with Sea Salt",
128
+ "choco": "Dark",
129
+ "salty": "Medium",
130
+ "weightPerUnitMl": 100,
131
+ "listPricePerUnitMl": 2.99
132
+ }
133
+ }
134
+ except Exception as e:
135
+ return {
136
+ "status": "error",
137
+ "error": str(e)
138
+ }
139
+
140
  @app.get("/items/{item_id}")
141
  def read_item(item_id: int, q: Union[str, None] = None):
142
  return {"item_id": item_id, "q": q}