Spaces:
Sleeping
Sleeping
Update default max_tokens value and refactor variable names in response generation for clarity in chatbot application.
Browse files
app.py
CHANGED
|
@@ -42,7 +42,7 @@ def respond(
|
|
| 42 |
"""
|
| 43 |
# Đặt giá trị mặc định nếu không có
|
| 44 |
if max_tokens is None:
|
| 45 |
-
max_tokens =
|
| 46 |
if temperature is None:
|
| 47 |
temperature = 0.7
|
| 48 |
if top_p is None:
|
|
@@ -72,13 +72,13 @@ def respond(
|
|
| 72 |
)
|
| 73 |
|
| 74 |
# Lấy câu trả lời từ kết quả
|
| 75 |
-
|
| 76 |
|
| 77 |
# Loại bỏ prompt ban đầu để chỉ lấy phần response
|
| 78 |
-
if prompt in
|
| 79 |
-
|
| 80 |
|
| 81 |
-
return
|
| 82 |
|
| 83 |
|
| 84 |
"""
|
|
|
|
| 42 |
"""
|
| 43 |
# Đặt giá trị mặc định nếu không có
|
| 44 |
if max_tokens is None:
|
| 45 |
+
max_tokens = 250
|
| 46 |
if temperature is None:
|
| 47 |
temperature = 0.7
|
| 48 |
if top_p is None:
|
|
|
|
| 72 |
)
|
| 73 |
|
| 74 |
# Lấy câu trả lời từ kết quả
|
| 75 |
+
answer = generated[0]['generated_text']
|
| 76 |
|
| 77 |
# Loại bỏ prompt ban đầu để chỉ lấy phần response
|
| 78 |
+
if prompt in answer:
|
| 79 |
+
answer = answer.replace(prompt, "").strip()
|
| 80 |
|
| 81 |
+
return answer
|
| 82 |
|
| 83 |
|
| 84 |
"""
|