Spaces:
Sleeping
Sleeping
Update cognitive_engine.py
Browse files- cognitive_engine.py +14 -12
cognitive_engine.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
"""
|
| 2 |
-
Nexari Cognitive Engine (
|
| 3 |
Author: Piyush
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
from datetime import datetime
|
|
@@ -11,29 +12,30 @@ import pytz
|
|
| 11 |
def get_time_context():
|
| 12 |
"""
|
| 13 |
MODULE 1: Fetches Real-Time Data.
|
| 14 |
-
Only called when intent is 'checking time or date'.
|
| 15 |
"""
|
| 16 |
IST = pytz.timezone('Asia/Kolkata')
|
| 17 |
now = datetime.now(IST)
|
| 18 |
-
current_time = now.strftime("%I:%M %p")
|
| 19 |
day_name = now.strftime("%A")
|
| 20 |
date_full = now.strftime("%d %B %Y")
|
| 21 |
-
|
| 22 |
return f"### REAL-TIME INFO ###\nCurrent Time: {current_time}\nDay: {day_name}\nDate: {date_full}"
|
| 23 |
|
| 24 |
def get_thinking_strategy(is_complex=False):
|
| 25 |
"""
|
| 26 |
MODULE 2: Sets the Thinking Strategy.
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
"""
|
| 29 |
if is_complex:
|
| 30 |
return (
|
| 31 |
-
"### STRATEGY:
|
| 32 |
-
"This is a complex
|
| 33 |
-
"
|
| 34 |
)
|
| 35 |
else:
|
| 36 |
return (
|
| 37 |
"### STRATEGY: CONVERSATIONAL ###\n"
|
| 38 |
-
"Keep
|
| 39 |
-
)
|
|
|
|
| 1 |
"""
|
| 2 |
+
Nexari Cognitive Engine (UPDATED)
|
| 3 |
Author: Piyush
|
| 4 |
+
Improvements:
|
| 5 |
+
- Safer 'thinking strategy' guidance (avoid raw chain-of-thought)
|
| 6 |
+
- More explicit small-plan + answer structure
|
| 7 |
"""
|
| 8 |
|
| 9 |
from datetime import datetime
|
|
|
|
| 12 |
def get_time_context():
|
| 13 |
"""
|
| 14 |
MODULE 1: Fetches Real-Time Data.
|
|
|
|
| 15 |
"""
|
| 16 |
IST = pytz.timezone('Asia/Kolkata')
|
| 17 |
now = datetime.now(IST)
|
| 18 |
+
current_time = now.strftime("%I:%M %p")
|
| 19 |
day_name = now.strftime("%A")
|
| 20 |
date_full = now.strftime("%d %B %Y")
|
| 21 |
+
|
| 22 |
return f"### REAL-TIME INFO ###\nCurrent Time: {current_time}\nDay: {day_name}\nDate: {date_full}"
|
| 23 |
|
| 24 |
def get_thinking_strategy(is_complex=False):
|
| 25 |
"""
|
| 26 |
MODULE 2: Sets the Thinking Strategy.
|
| 27 |
+
Instead of leaking chain-of-thought, instruct the model to provide:
|
| 28 |
+
- A 1-2 line '🧠 Plan:' (concise) when complex
|
| 29 |
+
- Then a '💡 Answer:' block with final result
|
| 30 |
"""
|
| 31 |
if is_complex:
|
| 32 |
return (
|
| 33 |
+
"### STRATEGY: STRUCTURED, SAFE THINKING ###\n"
|
| 34 |
+
"This is a technical/complex request. Provide a very short plan prefixed with '🧠 Plan:' (1-2 lines), "
|
| 35 |
+
"then provide the final result prefixed with '💡 Answer:'. Do NOT reveal internal chain-of-thought details."
|
| 36 |
)
|
| 37 |
else:
|
| 38 |
return (
|
| 39 |
"### STRATEGY: CONVERSATIONAL ###\n"
|
| 40 |
+
"Keep responses natural, warm and concise. If helpful, provide a one-line suggestion and a gentle follow-up question."
|
| 41 |
+
)
|