Update main.py
Browse files
main.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from fastapi import FastAPI, Request, HTTPException
|
2 |
-
from fastapi.responses import
|
3 |
from fastapi.staticfiles import StaticFiles
|
4 |
from huggingface_hub import InferenceClient
|
5 |
import json
|
@@ -53,13 +53,11 @@ async def generate(request: Request):
|
|
53 |
raise HTTPException(status_code=400, detail="Prompt is required")
|
54 |
|
55 |
response_generator = respond(prompt, history)
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
return StreamingResponse(event_stream(), media_type="text/plain")
|
63 |
|
64 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
65 |
|
|
|
1 |
from fastapi import FastAPI, Request, HTTPException
|
2 |
+
from fastapi.responses import JSONResponse, FileResponse
|
3 |
from fastapi.staticfiles import StaticFiles
|
4 |
from huggingface_hub import InferenceClient
|
5 |
import json
|
|
|
53 |
raise HTTPException(status_code=400, detail="Prompt is required")
|
54 |
|
55 |
response_generator = respond(prompt, history)
|
56 |
+
final_response = ""
|
57 |
+
for part in response_generator:
|
58 |
+
final_response += part
|
59 |
+
|
60 |
+
return JSONResponse(content={"response": final_response})
|
|
|
|
|
61 |
|
62 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
63 |
|