Spaces:
Sleeping
Sleeping
Update chatbot/core.py
Browse files- chatbot/core.py +4 -0
chatbot/core.py
CHANGED
@@ -15,6 +15,8 @@ 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 |
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,6 +29,8 @@ def translate_to_english(text: str) -> str:
|
|
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 |
|
31 |
**If query asks about what happened to you**:
|
32 |
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 |
+
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 |
**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: {current_time}.
|
33 |
+
Identify the referenced time point (day, month, or year) mentioned in the query, calculate its exact value, and include it in the keyword if necessary.
|
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:
|