Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -894,16 +894,19 @@ async def chatgpt_4o(
|
|
894 |
item: ChatgptCustom,
|
895 |
api_key: None = Depends(validate_api_key)
|
896 |
):
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
|
|
|
|
|
|
907 |
|
908 |
@app.post("/ryuzaki/chatgpt-custom", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
909 |
async def chatgpt_customs(
|
|
|
894 |
item: ChatgptCustom,
|
895 |
api_key: None = Depends(validate_api_key)
|
896 |
):
|
897 |
+
try:
|
898 |
+
client = Client()
|
899 |
+
response = client.chat.completions.create(
|
900 |
+
model="gpt-4o",
|
901 |
+
messages=[{"role": "user", "content": item.query}]
|
902 |
+
)
|
903 |
+
answer = response.choices[0].message.content
|
904 |
+
return SuccessResponse(
|
905 |
+
status="True",
|
906 |
+
randydev={"message": answer}
|
907 |
+
)
|
908 |
+
except Exception as e:
|
909 |
+
return SuccessResponse(status="False", randydev={"message": str(e)})
|
910 |
|
911 |
@app.post("/ryuzaki/chatgpt-custom", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
912 |
async def chatgpt_customs(
|