Spaces:
Sleeping
Sleeping
Update cognitive_engine.py
Browse files- cognitive_engine.py +12 -25
cognitive_engine.py
CHANGED
|
@@ -1,41 +1,28 @@
|
|
| 1 |
"""
|
| 2 |
-
|
| 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
|
| 10 |
import pytz
|
| 11 |
|
| 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 |
-
|
| 19 |
-
day_name = now.strftime("%A")
|
| 20 |
-
date_full = now.strftime("%d %B %Y")
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
def get_thinking_strategy(is_complex=False):
|
| 25 |
"""
|
| 26 |
-
|
| 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
|
| 34 |
-
"
|
| 35 |
-
"then
|
|
|
|
| 36 |
)
|
| 37 |
else:
|
| 38 |
return (
|
| 39 |
-
"### STRATEGY:
|
| 40 |
-
"Keep responses
|
| 41 |
-
)
|
|
|
|
| 1 |
"""
|
| 2 |
+
cognitive_engine.py - thinking strategy with `detail` flag
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
from datetime import datetime
|
| 6 |
import pytz
|
| 7 |
|
| 8 |
def get_time_context():
|
|
|
|
|
|
|
|
|
|
| 9 |
IST = pytz.timezone('Asia/Kolkata')
|
| 10 |
now = datetime.now(IST)
|
| 11 |
+
return f"### REAL-TIME INFO ###\nCurrent Time: {now.strftime('%I:%M %p')}\nDay: {now.strftime('%A')}\nDate: {now.strftime('%d %B %Y')}"
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
def get_thinking_strategy(is_complex=False, detail=False):
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
+
If detail==True, instruct model to produce a numbered, stepwise, longer answer.
|
|
|
|
|
|
|
|
|
|
| 16 |
"""
|
| 17 |
+
if is_complex or detail:
|
| 18 |
return (
|
| 19 |
+
"### STRATEGY: STRUCTURED & DETAILED ###\n"
|
| 20 |
+
"If complex or user requested detail, provide a short '🧠 Plan:' (max 2 lines),\n"
|
| 21 |
+
"then a numbered, step-by-step '💡 Answer:' with clear numbered lines. "
|
| 22 |
+
"Aim for thorough coverage if requested by user. Do NOT leak chain-of-thought."
|
| 23 |
)
|
| 24 |
else:
|
| 25 |
return (
|
| 26 |
+
"### STRATEGY: CONCISE ###\n"
|
| 27 |
+
"Keep responses friendly and brief. Offer a one-line suggestion and a follow-up question."
|
| 28 |
+
)
|