Spaces:
Runtime error
Runtime error
usag1e
commited on
Commit
·
a931f78
1
Parent(s):
5d91af1
Fix: Parse input_text from request body
Browse files
app.py
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
-
from
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
8 |
|
9 |
@app.get("/")
|
10 |
def root():
|
11 |
return {"message": "Welcome to the LLM API"}
|
12 |
|
13 |
@app.post("/predict")
|
14 |
-
def predict(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
except Exception as e:
|
20 |
-
raise HTTPException(status_code=500, detail=str(e))
|
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
+
from pydantic import BaseModel
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
+
# Define the input schema
|
7 |
+
class InputText(BaseModel):
|
8 |
+
input_text: str
|
9 |
|
10 |
@app.get("/")
|
11 |
def root():
|
12 |
return {"message": "Welcome to the LLM API"}
|
13 |
|
14 |
@app.post("/predict")
|
15 |
+
def predict(data: InputText):
|
16 |
+
# Access the input_text from the request body
|
17 |
+
input_text = data.input_text
|
18 |
+
# For now, return the input text as a response
|
19 |
+
return {"response": f"The input was: {input_text}"}
|
|
|
|