Spaces:
Sleeping
Sleeping
Commit
·
f1b344d
1
Parent(s):
2a99d71
test deepseek
Browse files- app.py +1 -1
- call_api.py +11 -11
app.py
CHANGED
@@ -41,7 +41,7 @@ with gr.Blocks() as demo: # Bắt đầu Blocks
|
|
41 |
# Sự kiện submit
|
42 |
txt.submit(
|
43 |
call_api.call_deepseek_new,
|
44 |
-
inputs=[txt, chatbot
|
45 |
outputs=chatbot,
|
46 |
)
|
47 |
|
|
|
41 |
# Sự kiện submit
|
42 |
txt.submit(
|
43 |
call_api.call_deepseek_new,
|
44 |
+
inputs=[txt, chatbot],
|
45 |
outputs=chatbot,
|
46 |
)
|
47 |
|
call_api.py
CHANGED
@@ -112,19 +112,19 @@ def call_deepseek(
|
|
112 |
def call_deepseek_new(
|
113 |
user_prompt: str,
|
114 |
chat_history: list[dict], # sẽ là [{"role":"user"/"assistant","content":...}, …]
|
115 |
-
system_prompt: str,
|
116 |
-
max_tokens: int,
|
117 |
-
temperature: float,
|
118 |
-
top_p: float,
|
119 |
-
file_upload=None,
|
120 |
-
image_upload=None
|
121 |
):
|
122 |
# Khởi tạo history nếu None
|
123 |
history = chat_history or []
|
124 |
|
125 |
# Append system prompt (chỉ ở lần đầu nếu bạn muốn)
|
126 |
-
if not any(m["role"]=="system" for m in history):
|
127 |
-
|
128 |
|
129 |
# Append message mới của user
|
130 |
history.append({"role": "user", "content": user_prompt})
|
@@ -133,9 +133,9 @@ def call_deepseek_new(
|
|
133 |
response = deepseek.chat.completions.create(
|
134 |
model = "deepseek-chat", # hoặc model bạn đã config
|
135 |
messages = history,
|
136 |
-
temperature= temperature,
|
137 |
-
top_p = top_p,
|
138 |
-
max_tokens = max_tokens
|
139 |
)
|
140 |
|
141 |
# Lấy nội dung assistant trả về
|
|
|
112 |
def call_deepseek_new(
|
113 |
user_prompt: str,
|
114 |
chat_history: list[dict], # sẽ là [{"role":"user"/"assistant","content":...}, …]
|
115 |
+
# system_prompt: str,
|
116 |
+
# max_tokens: int,
|
117 |
+
# temperature: float,
|
118 |
+
# top_p: float,
|
119 |
+
# file_upload=None,
|
120 |
+
# image_upload=None
|
121 |
):
|
122 |
# Khởi tạo history nếu None
|
123 |
history = chat_history or []
|
124 |
|
125 |
# Append system prompt (chỉ ở lần đầu nếu bạn muốn)
|
126 |
+
# if not any(m["role"]=="system" for m in history):
|
127 |
+
# history.insert(0, {"role": "system", "content": system_prompt})
|
128 |
|
129 |
# Append message mới của user
|
130 |
history.append({"role": "user", "content": user_prompt})
|
|
|
133 |
response = deepseek.chat.completions.create(
|
134 |
model = "deepseek-chat", # hoặc model bạn đã config
|
135 |
messages = history,
|
136 |
+
# temperature= temperature,
|
137 |
+
# top_p = top_p,
|
138 |
+
# max_tokens = max_tokens
|
139 |
)
|
140 |
|
141 |
# Lấy nội dung assistant trả về
|