Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
from flask import Flask, request, jsonify
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
| 6 |
# Load Hugging Face model for conversation
|
| 7 |
chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
|
|
|
| 8 |
|
| 9 |
# Endpoint for chat with the chatbot
|
| 10 |
@app.route('/chat', methods=['POST'])
|
|
@@ -13,6 +16,7 @@ def chat():
|
|
| 13 |
|
| 14 |
if user_message.lower() == 'hi':
|
| 15 |
# Send a greeting message when the user says "hi"
|
|
|
|
| 16 |
return jsonify({"response": "Hello! Welcome to the Indian Recipe Bot. What ingredients do you have today?"})
|
| 17 |
|
| 18 |
# Get response from the chatbot model
|
|
@@ -45,4 +49,5 @@ def ingredients():
|
|
| 45 |
|
| 46 |
|
| 47 |
if __name__ == '__main__':
|
| 48 |
-
|
|
|
|
|
|
| 1 |
from flask import Flask, request, jsonify
|
| 2 |
from transformers import pipeline
|
| 3 |
+
import logging
|
| 4 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
|
| 8 |
# Load Hugging Face model for conversation
|
| 9 |
chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
| 10 |
+
print("Model Loaded")
|
| 11 |
|
| 12 |
# Endpoint for chat with the chatbot
|
| 13 |
@app.route('/chat', methods=['POST'])
|
|
|
|
| 16 |
|
| 17 |
if user_message.lower() == 'hi':
|
| 18 |
# Send a greeting message when the user says "hi"
|
| 19 |
+
chatbot_response = chatbot(user_message)
|
| 20 |
return jsonify({"response": "Hello! Welcome to the Indian Recipe Bot. What ingredients do you have today?"})
|
| 21 |
|
| 22 |
# Get response from the chatbot model
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
if __name__ == '__main__':
|
| 52 |
+
app.run(debug=True, use_reloader=False, port=5001)
|
| 53 |
+
|