Spaces:
Sleeping
Sleeping
Update chatbot/core.py
Browse files- chatbot/core.py +5 -4
chatbot/core.py
CHANGED
@@ -15,8 +15,6 @@ def get_current_time():
|
|
15 |
now = datetime.now(utc_plus_7)
|
16 |
return now.strftime("%A, %Y-%m-%d %H:%M:%S") # Example: "Saturday, 2025-03-29 14:30:00"
|
17 |
|
18 |
-
current_time = get_current_time()
|
19 |
-
|
20 |
def translate_to_english(text: str) -> str:
|
21 |
"""Use Gemini LLM to translate text to English with recent chat context."""
|
22 |
recent_messages = memory.chat_memory.messages[-3:] # Lấy 3 tin nhắn gần nhất
|
@@ -29,8 +27,11 @@ def translate_to_english(text: str) -> str:
|
|
29 |
**If the query asks for general information**:
|
30 |
Extract and return only the most relevant keyword (e.g. a person's name, city, or key term) in English/international form.
|
31 |
If the query includes a specific time reference (date, month, or year), ensure that the translated keyword includes this time reference.
|
32 |
-
Current time: {
|
33 |
-
Identify the referenced time point (day, month, or
|
|
|
|
|
|
|
34 |
|
35 |
**If query asks about what happened to you**:
|
36 |
Interpret 'you' as Kumiko, based on your knowledge of the Hibike! Euphonium plot, return one of the following keywords:
|
|
|
15 |
now = datetime.now(utc_plus_7)
|
16 |
return now.strftime("%A, %Y-%m-%d %H:%M:%S") # Example: "Saturday, 2025-03-29 14:30:00"
|
17 |
|
|
|
|
|
18 |
def translate_to_english(text: str) -> str:
|
19 |
"""Use Gemini LLM to translate text to English with recent chat context."""
|
20 |
recent_messages = memory.chat_memory.messages[-3:] # Lấy 3 tin nhắn gần nhất
|
|
|
27 |
**If the query asks for general information**:
|
28 |
Extract and return only the most relevant keyword (e.g. a person's name, city, or key term) in English/international form.
|
29 |
If the query includes a specific time reference (date, month, or year), ensure that the translated keyword includes this time reference.
|
30 |
+
Current time: {get_current_time()}.
|
31 |
+
Identify the referenced time point (day, month, year, decade or century) mentioned in the query, calculate its exact value, and include it in the keyword if necessary.
|
32 |
+
If the query refers to time but does not require absolute precision (e.g., using words like "around" or "approximately"), return a broader time range and include it in the keyword if necessary.
|
33 |
+
For example:
|
34 |
+
If the current year is 2025, then: "around 30 years ago" is 1990s, "about 200 years ago" is 19th century.
|
35 |
|
36 |
**If query asks about what happened to you**:
|
37 |
Interpret 'you' as Kumiko, based on your knowledge of the Hibike! Euphonium plot, return one of the following keywords:
|