Spaces:
Runtime error
Runtime error
dwfefef
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
|
|
1 |
from flask import Flask, render_template, request, jsonify
|
2 |
import requests
|
3 |
|
4 |
app = Flask(__name__)
|
|
|
5 |
|
6 |
API_URL = "https://gefiwek187-ecfefsegegegeg1.hf.space"
|
7 |
|
@@ -27,12 +29,18 @@ def chat():
|
|
27 |
user_input = data['user_input']
|
28 |
conversation_history = data.get('conversation_history', [])
|
29 |
|
|
|
|
|
30 |
# Combine the conversation history into a single string
|
31 |
full_context = "\n".join([f"{msg['role']}: {msg['content']}" for msg in conversation_history])
|
32 |
full_context += f"\nuser: {user_input}"
|
33 |
|
|
|
|
|
34 |
try:
|
35 |
response = requests.post(f"{API_URL}/chat/", params={"user_input": full_context})
|
|
|
|
|
36 |
response.raise_for_status()
|
37 |
ai_response = response.json()["response"]
|
38 |
return jsonify({"response": ai_response})
|
|
|
1 |
+
import logging
|
2 |
from flask import Flask, render_template, request, jsonify
|
3 |
import requests
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
+
logging.basicConfig(level=logging.DEBUG)
|
7 |
|
8 |
API_URL = "https://gefiwek187-ecfefsegegegeg1.hf.space"
|
9 |
|
|
|
29 |
user_input = data['user_input']
|
30 |
conversation_history = data.get('conversation_history', [])
|
31 |
|
32 |
+
app.logger.debug(f"Received request: {data}")
|
33 |
+
|
34 |
# Combine the conversation history into a single string
|
35 |
full_context = "\n".join([f"{msg['role']}: {msg['content']}" for msg in conversation_history])
|
36 |
full_context += f"\nuser: {user_input}"
|
37 |
|
38 |
+
app.logger.debug(f"Full context: {full_context}")
|
39 |
+
|
40 |
try:
|
41 |
response = requests.post(f"{API_URL}/chat/", params={"user_input": full_context})
|
42 |
+
app.logger.debug(f"API response status: {response.status_code}")
|
43 |
+
app.logger.debug(f"API response content: {response.text}")
|
44 |
response.raise_for_status()
|
45 |
ai_response = response.json()["response"]
|
46 |
return jsonify({"response": ai_response})
|