Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
from llama_cpp import Llama
|
|
@@ -69,7 +70,7 @@ def get_response(text: str) -> str:
|
|
| 69 |
@app.post("/ask")
|
| 70 |
def ask_question(question: Question):
|
| 71 |
response = get_response(question.text)
|
| 72 |
-
return {"response": response}
|
| 73 |
|
| 74 |
# Executa a aplicação
|
| 75 |
if __name__ == "__main__":
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from fastapi.responses import JSONResponse
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
from llama_cpp import Llama
|
|
|
|
| 70 |
@app.post("/ask")
|
| 71 |
def ask_question(question: Question):
|
| 72 |
response = get_response(question.text)
|
| 73 |
+
return JSONResponse({"response": response})
|
| 74 |
|
| 75 |
# Executa a aplicação
|
| 76 |
if __name__ == "__main__":
|