Spaces:
Sleeping
Sleeping
anhdt-dsai-02
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,10 +6,9 @@ import traceback
|
|
6 |
from fastapi.middleware.cors import CORSMiddleware
|
7 |
from gemini import complete_gemini_async
|
8 |
|
9 |
-
class
|
10 |
-
|
11 |
-
|
12 |
-
params:dict
|
13 |
|
14 |
app = FastAPI()
|
15 |
origins = ["*"]
|
@@ -20,10 +19,10 @@ app.add_middleware(
|
|
20 |
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
21 |
allow_headers=["*"],
|
22 |
)
|
23 |
-
@app.post("/
|
24 |
-
async def
|
25 |
try:
|
26 |
-
result = await complete_gemini_async(
|
27 |
return result
|
28 |
except Exception as e:
|
29 |
raise HTTPException(status_code=500, detail="An error occurred: {}".format(traceback.format_exc()))
|
|
|
6 |
from fastapi.middleware.cors import CORSMiddleware
|
7 |
from gemini import complete_gemini_async
|
8 |
|
9 |
+
class Text(BaseModel):
|
10 |
+
ques: str
|
11 |
+
ans: str
|
|
|
12 |
|
13 |
app = FastAPI()
|
14 |
origins = ["*"]
|
|
|
19 |
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
20 |
allow_headers=["*"],
|
21 |
)
|
22 |
+
@app.post("/geminiv2")
|
23 |
+
async def geminiv2(data: Text, api_key: str = Security(get_api_key)):
|
24 |
try:
|
25 |
+
result = await complete_gemini_async((data.ques, data.ans), "ahihi")
|
26 |
return result
|
27 |
except Exception as e:
|
28 |
raise HTTPException(status_code=500, detail="An error occurred: {}".format(traceback.format_exc()))
|