Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import Dict, Any
|
|
| 4 |
from functools import partial
|
| 5 |
import warnings
|
| 6 |
|
| 7 |
-
from flask import Flask, request, jsonify
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
# Suppress the FutureWarning
|
|
@@ -158,6 +158,10 @@ class EliteDeveloperCluster:
|
|
| 158 |
# Flask App for handling agent requests
|
| 159 |
app = Flask(__name__)
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
@app.route('/agent', methods=['POST'])
|
| 162 |
async def agent_request():
|
| 163 |
data = request.get_json()
|
|
@@ -169,6 +173,16 @@ async def agent_request():
|
|
| 169 |
else:
|
| 170 |
return jsonify({'response': 'Invalid input'})
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
# Chat Interface
|
| 173 |
async def get_response(query: str) -> str:
|
| 174 |
return await cluster.route_request(query)
|
|
|
|
| 4 |
from functools import partial
|
| 5 |
import warnings
|
| 6 |
|
| 7 |
+
from flask import Flask, request, jsonify, render_template
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
# Suppress the FutureWarning
|
|
|
|
| 158 |
# Flask App for handling agent requests
|
| 159 |
app = Flask(__name__)
|
| 160 |
|
| 161 |
+
@app.route('/')
|
| 162 |
+
def index():
|
| 163 |
+
return render_template('index.html')
|
| 164 |
+
|
| 165 |
@app.route('/agent', methods=['POST'])
|
| 166 |
async def agent_request():
|
| 167 |
data = request.get_json()
|
|
|
|
| 173 |
else:
|
| 174 |
return jsonify({'response': 'Invalid input'})
|
| 175 |
|
| 176 |
+
@app.route('/chat', methods=['POST'])
|
| 177 |
+
async def chat():
|
| 178 |
+
data = request.get_json()
|
| 179 |
+
query = data.get('query')
|
| 180 |
+
if query:
|
| 181 |
+
response = await get_response(query)
|
| 182 |
+
return jsonify({'response': response})
|
| 183 |
+
else:
|
| 184 |
+
return jsonify({'response': 'Invalid input'})
|
| 185 |
+
|
| 186 |
# Chat Interface
|
| 187 |
async def get_response(query: str) -> str:
|
| 188 |
return await cluster.route_request(query)
|