Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -628,25 +628,16 @@ def chatgpt_model(item: ChatgptModel):
|
|
628 |
@app.post("/ryuzaki/chatgpt3-turbo", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
629 |
def chatgpt3_turbo(item: Chatgpt3Texts):
|
630 |
if item.is_openai_original:
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
model="gpt-3.5-turbo"
|
635 |
-
|
636 |
-
|
|
|
|
|
|
|
637 |
)
|
638 |
-
if isinstance(chat_completion, dict):
|
639 |
-
answer = chat_completion.choices[0].message.content
|
640 |
-
else:
|
641 |
-
answer = ""
|
642 |
-
for token in chat_completion:
|
643 |
-
content = token["choices"][0]["delta"].get("content")
|
644 |
-
if content is not None:
|
645 |
-
answer += content
|
646 |
-
return SuccessResponse(
|
647 |
-
status="True",
|
648 |
-
randydev={"message": answer}
|
649 |
-
)
|
650 |
else:
|
651 |
url = "https://lexica.qewertyy.me/models"
|
652 |
params = {"model_id": 5, "prompt": item.query}
|
@@ -665,25 +656,16 @@ def chatgpt4_turbo(
|
|
665 |
item: OpenaiTexts,
|
666 |
api_key: None = Depends(validate_api_key)
|
667 |
):
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
model="gpt-4-turbo"
|
672 |
-
|
673 |
-
|
|
|
|
|
|
|
674 |
)
|
675 |
-
if isinstance(chat_completion, dict):
|
676 |
-
answer = chat_completion.choices[0].message.content
|
677 |
-
else:
|
678 |
-
answer = ""
|
679 |
-
for token in chat_completion:
|
680 |
-
content = token["choices"][0]["delta"].get("content")
|
681 |
-
if content is not None:
|
682 |
-
answer += content
|
683 |
-
return SuccessResponse(
|
684 |
-
status="True",
|
685 |
-
randydev={"message": answer}
|
686 |
-
)
|
687 |
|
688 |
@app.post("/ryuzaki/google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
689 |
def v1beta3_google_ai(
|
|
|
628 |
@app.post("/ryuzaki/chatgpt3-turbo", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
629 |
def chatgpt3_turbo(item: Chatgpt3Texts):
|
630 |
if item.is_openai_original:
|
631 |
+
GPTbase = SOURCE_OPENAI_ACCESS_URL
|
632 |
+
response = OpenAiToken(api_key=item.api_key, api_base=GPTbase).chat_message_turbo(
|
633 |
+
query=item.query,
|
634 |
+
model="gpt-3.5-turbo"
|
635 |
+
)
|
636 |
+
answer = response["choices"][0]["message"]["content"]
|
637 |
+
return SuccessResponse(
|
638 |
+
status="True",
|
639 |
+
randydev={"message": answer}
|
640 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
else:
|
642 |
url = "https://lexica.qewertyy.me/models"
|
643 |
params = {"model_id": 5, "prompt": item.query}
|
|
|
656 |
item: OpenaiTexts,
|
657 |
api_key: None = Depends(validate_api_key)
|
658 |
):
|
659 |
+
GPTbase = SOURCE_OPENAI_ACCESS_URL
|
660 |
+
response = OpenAiToken(api_key=item.api_key, api_base=GPTbase).chat_message_turbo(
|
661 |
+
query=item.query,
|
662 |
+
model="gpt-4-turbo"
|
663 |
+
)
|
664 |
+
answer = response["choices"][0]["message"]["content"]
|
665 |
+
return SuccessResponse(
|
666 |
+
status="True",
|
667 |
+
randydev={"message": answer}
|
668 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
669 |
|
670 |
@app.post("/ryuzaki/google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
671 |
def v1beta3_google_ai(
|