Spaces:
Sleeping
Sleeping
Update response generation in chatbot application to set default values for max_tokens, temperature, and top_p parameters. This enhancement ensures smoother operation when these parameters are not explicitly provided.
Browse files
app.py
CHANGED
|
@@ -33,13 +33,21 @@ def respond(
|
|
| 33 |
message,
|
| 34 |
history: list[dict[str, str]],
|
| 35 |
system_message,
|
| 36 |
-
max_tokens,
|
| 37 |
-
temperature,
|
| 38 |
-
top_p,
|
| 39 |
):
|
| 40 |
"""
|
| 41 |
Tạo phản hồi từ model coding assistant sử dụng pipeline
|
| 42 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Chuẩn bị prompt với chat template
|
| 44 |
messages = [{"role": "system", "content": system_message}]
|
| 45 |
messages.extend(history)
|
|
|
|
| 33 |
message,
|
| 34 |
history: list[dict[str, str]],
|
| 35 |
system_message,
|
| 36 |
+
max_tokens=None,
|
| 37 |
+
temperature=None,
|
| 38 |
+
top_p=None,
|
| 39 |
):
|
| 40 |
"""
|
| 41 |
Tạo phản hồi từ model coding assistant sử dụng pipeline
|
| 42 |
"""
|
| 43 |
+
# Đặt giá trị mặc định nếu không có
|
| 44 |
+
if max_tokens is None:
|
| 45 |
+
max_tokens = 100
|
| 46 |
+
if temperature is None:
|
| 47 |
+
temperature = 0.7
|
| 48 |
+
if top_p is None:
|
| 49 |
+
top_p = 0.95
|
| 50 |
+
|
| 51 |
# Chuẩn bị prompt với chat template
|
| 52 |
messages = [{"role": "system", "content": system_message}]
|
| 53 |
messages.extend(history)
|