Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -116,23 +116,22 @@ def generate_chat_response(request, model_data):
|
|
116 |
try:
|
117 |
user_input = normalize_input(request.message)
|
118 |
response = model(user_input, top_k=request.top_k, top_p=request.top_p, temperature=request.temperature)
|
119 |
-
return
|
120 |
except Exception:
|
121 |
pass
|
122 |
|
123 |
-
@
|
124 |
async def generate(request: ChatRequest):
|
125 |
try:
|
126 |
responses = []
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
pass
|
136 |
|
137 |
if not responses:
|
138 |
raise HTTPException(status_code=500, detail="Error: No responses generated.")
|
@@ -152,7 +151,7 @@ async def handle_request(method_name: str, request: Request):
|
|
152 |
body = await request.json()
|
153 |
return {"message": "Request handled successfully", "body": body}
|
154 |
except Exception:
|
155 |
-
|
156 |
|
157 |
if __name__ == "__main__":
|
158 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
116 |
try:
|
117 |
user_input = normalize_input(request.message)
|
118 |
response = model(user_input, top_k=request.top_k, top_p=request.top_p, temperature=request.temperature)
|
119 |
+
return response
|
120 |
except Exception:
|
121 |
pass
|
122 |
|
123 |
+
@app.post("/generate")
|
124 |
async def generate(request: ChatRequest):
|
125 |
try:
|
126 |
responses = []
|
127 |
+
models = global_data['models']
|
128 |
+
for model_data in models:
|
129 |
+
response = generate_chat_response(request, model_data)
|
130 |
+
if response:
|
131 |
+
responses.append({
|
132 |
+
"model": model_data['name'],
|
133 |
+
"response": response
|
134 |
+
})
|
|
|
135 |
|
136 |
if not responses:
|
137 |
raise HTTPException(status_code=500, detail="Error: No responses generated.")
|
|
|
151 |
body = await request.json()
|
152 |
return {"message": "Request handled successfully", "body": body}
|
153 |
except Exception:
|
154 |
+
pass
|
155 |
|
156 |
if __name__ == "__main__":
|
157 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|