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