randydev commited on
Commit
73c80c9
1 Parent(s): 708950b

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -0
main.py CHANGED
@@ -60,6 +60,7 @@ from fastapi.staticfiles import StaticFiles
60
  from fastapi.templating import Jinja2Templates
61
 
62
  import g4f
 
63
  from g4f.client import Client as BingClient
64
  from g4f.cookies import set_cookies
65
  from g4f.Provider import BingCreateImages, OpenaiChat, Gemini
@@ -888,6 +889,22 @@ async def chatgpt4_turbo(
888
  except Exception as e:
889
  return SuccessResponse(status="False", randydev={"message": str(e)})
890
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
891
  @app.post("/ryuzaki/chatgpt-custom", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
892
  async def chatgpt_customs(
893
  item: ChatgptNewo,
 
60
  from fastapi.templating import Jinja2Templates
61
 
62
  import g4f
63
+ from g4f.client import Client
64
  from g4f.client import Client as BingClient
65
  from g4f.cookies import set_cookies
66
  from g4f.Provider import BingCreateImages, OpenaiChat, Gemini
 
889
  except Exception as e:
890
  return SuccessResponse(status="False", randydev={"message": str(e)})
891
 
892
+ @app.post("/ryuzaki/chatgpt-4o", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
893
+ async def chatgpt_4o(
894
+ item: ChatgptCustom,
895
+ api_key: None = Depends(validate_api_key)
896
+ ):
897
+ client = Client()
898
+ response = client.chat.completions.create(
899
+ model="gpt-4o",
900
+ messages=[{"role": "user", "content": item.query}],
901
+ )
902
+ answer = response.choices[0].message.content
903
+ return SuccessResponse(
904
+ status="True",
905
+ randydev={"message": answer}
906
+ )
907
+
908
  @app.post("/ryuzaki/chatgpt-custom", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
909
  async def chatgpt_customs(
910
  item: ChatgptNewo,