Spaces:
Sleeping
Sleeping
Commit
·
c8ddc02
1
Parent(s):
a2d09ab
test deepseek
Browse files- call_api.py +5 -4
call_api.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from openai import OpenAI # type: ignore
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
|
| 5 |
def call_openai(
|
| 6 |
user_prompt,
|
| 7 |
chat_history: list[tuple[str, str]],
|
|
@@ -12,7 +12,7 @@ def call_openai(
|
|
| 12 |
file_upload=None,
|
| 13 |
image_upload=None
|
| 14 |
):
|
| 15 |
-
|
| 16 |
if file_upload == None:
|
| 17 |
try:
|
| 18 |
pass
|
|
@@ -40,7 +40,7 @@ def call_openai(
|
|
| 40 |
print("## Messages: \n", messages) #debug output
|
| 41 |
|
| 42 |
#create output
|
| 43 |
-
response =
|
| 44 |
model="gpt-4.1-nano",
|
| 45 |
input=messages,
|
| 46 |
temperature=temperature,
|
|
@@ -55,7 +55,7 @@ def call_openai(
|
|
| 55 |
yield response #chat reply
|
| 56 |
|
| 57 |
|
| 58 |
-
|
| 59 |
def call_deepseek(
|
| 60 |
user_prompt: str,
|
| 61 |
chat_history: list[tuple[str, str]],
|
|
@@ -66,6 +66,7 @@ def call_deepseek(
|
|
| 66 |
file_upload=None,
|
| 67 |
image_upload=None
|
| 68 |
):
|
|
|
|
| 69 |
"""
|
| 70 |
Gọi DeepSeek Chat qua OpenAI-compatible API (không stream).
|
| 71 |
- file_upload và image_upload tùy chọn (None để bỏ qua xử lý).
|
|
|
|
| 1 |
from openai import OpenAI # type: ignore
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
|
| 5 |
def call_openai(
|
| 6 |
user_prompt,
|
| 7 |
chat_history: list[tuple[str, str]],
|
|
|
|
| 12 |
file_upload=None,
|
| 13 |
image_upload=None
|
| 14 |
):
|
| 15 |
+
GPT = OpenAI(api_key = os.getenv("OPENAI_API_KEY"))
|
| 16 |
if file_upload == None:
|
| 17 |
try:
|
| 18 |
pass
|
|
|
|
| 40 |
print("## Messages: \n", messages) #debug output
|
| 41 |
|
| 42 |
#create output
|
| 43 |
+
response = GPT.responses.create(
|
| 44 |
model="gpt-4.1-nano",
|
| 45 |
input=messages,
|
| 46 |
temperature=temperature,
|
|
|
|
| 55 |
yield response #chat reply
|
| 56 |
|
| 57 |
|
| 58 |
+
|
| 59 |
def call_deepseek(
|
| 60 |
user_prompt: str,
|
| 61 |
chat_history: list[tuple[str, str]],
|
|
|
|
| 66 |
file_upload=None,
|
| 67 |
image_upload=None
|
| 68 |
):
|
| 69 |
+
deepseek = OpenAI(api_key = os.getenv("DEEPSEEK_API_KEY"), base_url="https://api.deepseek.com")
|
| 70 |
"""
|
| 71 |
Gọi DeepSeek Chat qua OpenAI-compatible API (không stream).
|
| 72 |
- file_upload và image_upload tùy chọn (None để bỏ qua xử lý).
|