anhdt-dsai-02 commited on
Commit
883a744
·
verified ·
1 Parent(s): b229e20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
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 GenItem(BaseModel):
10
- chat:list
11
- key:str
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("/complete")
24
- async def complete(item: GenItem):
25
  try:
26
- result = await complete_gemini_async(item.chat, item.key, item.params)
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()))