ayush2917 commited on
Commit
e9d3ae2
·
verified ·
1 Parent(s): 2e851e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -1
app.py CHANGED
@@ -532,4 +532,33 @@ def riddle():
532
  "max_length": 60,
533
  "temperature": 0.9,
534
  "top_p": 0.9,
535
- "top_k": 50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
  "max_length": 60,
533
  "temperature": 0.9,
534
  "top_p": 0.9,
535
+ "top_k": 50
536
+ }
537
+ }
538
+ response = make_api_request(
539
+ "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1",
540
+ headers=headers,
541
+ payload=payload
542
+ )
543
+ result = parse_huggingface_response(response)
544
+ if result:
545
+ return jsonify({'riddle': result})
546
+ logger.error("Failed to generate riddle after retries.")
547
+ return jsonify({'riddle': "Hare Manavi! I play a tune that makes the gopis dance, but I’m not a drum—what am I? (Answer: Flute)"})
548
+ except Exception as e:
549
+ logger.error(f"Error in /riddle route: {str(e)}")
550
+ return jsonify({'error': 'Internal Server Error: Please try again later.'}), 500
551
+
552
+ @app.route('/countdown')
553
+ def countdown():
554
+ """Return the number of days until Manavi's birthday."""
555
+ try:
556
+ days_left = get_countdown()
557
+ return jsonify({'days': days_left})
558
+ except Exception as e:
559
+ logger.error(f"Error in /countdown route: {str(e)}")
560
+ return jsonify({'error': 'Internal Server Error: Please try again later.'}), 500
561
+
562
+ if __name__ == '__main__':
563
+ port = int(os.environ.get('PORT', 7860))
564
+ app.run(host='0.0.0.0', port=port, debug=False)