Hasitha16 commited on
Commit
ee1188d
·
verified ·
1 Parent(s): e44b4ba

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -78,8 +78,8 @@ def auto_fill(value: Optional[str], fallback: str) -> str:
78
  async def analyze(data: ReviewInput, x_api_key: str = Header(None)):
79
  if x_api_key != VALID_API_KEY:
80
  raise HTTPException(status_code=401, detail="❌ Unauthorized: Invalid API key")
81
- if len(data.text.split()) < 10:
82
- raise HTTPException(status_code=400, detail="⚠️ Review too short for analysis (min. 10 words).")
83
 
84
  try:
85
  # Smart summary logic based on verbosity and intelligence
@@ -92,8 +92,8 @@ async def analyze(data: ReviewInput, x_api_key: str = Header(None)):
92
  emotion = "joy"
93
 
94
  # Auto-detection logic
95
- industry: auto_fill(data.industry, detect_industry(data.text))
96
- product_category: auto_fill(data.product_category, detect_product_category(data.text))
97
  device = "Web"
98
 
99
  follow_up_response = None
 
78
  async def analyze(data: ReviewInput, x_api_key: str = Header(None)):
79
  if x_api_key != VALID_API_KEY:
80
  raise HTTPException(status_code=401, detail="❌ Unauthorized: Invalid API key")
81
+ if len(data.text.split()) < 20:
82
+ raise HTTPException(status_code=400, detail="⚠️ Review too short for analysis (min. 20 words).")
83
 
84
  try:
85
  # Smart summary logic based on verbosity and intelligence
 
92
  emotion = "joy"
93
 
94
  # Auto-detection logic
95
+ industry = detect_industry(data.text) if not data.industry or "auto" in data.industry.lower() else data.industry
96
+ product_category = detect_product_category(data.text) if not data.product_category or "auto" in data.product_category.lower() else data.product_category
97
  device = "Web"
98
 
99
  follow_up_response = None