feat: implement daily timestamped logs for deeper context retrieval
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ __pycache__/
|
||||
.DS_Store
|
||||
*.wav
|
||||
*.mp3
|
||||
logs/
|
||||
|
||||
25
jarvis.py
25
jarvis.py
@@ -43,16 +43,26 @@ MAX_BUFFER_SECONDS = 15
|
||||
CONTEXT_CHARS = 500 # How much previous text to keep for context
|
||||
|
||||
WORKSPACE_DIR = "workspace"
|
||||
LOGS_DIR = "logs"
|
||||
SOUL_PATH = "soul.md"
|
||||
SYSTEM_SOUND = "/System/Library/Sounds/Tink.aiff"
|
||||
FOLLOW_UP_SOUND = "/System/Library/Sounds/Submarine.aiff"
|
||||
|
||||
# Ensure workspace exists
|
||||
if not os.path.exists(WORKSPACE_DIR):
|
||||
os.makedirs(WORKSPACE_DIR)
|
||||
# Ensure workspace and logs exist
|
||||
for d in [WORKSPACE_DIR, LOGS_DIR]:
|
||||
if not os.path.exists(d):
|
||||
os.makedirs(d)
|
||||
|
||||
# Initialize pygame mixer for audio playback
|
||||
pygame.mixer.init()
|
||||
def log_transcription(text):
|
||||
"""Log all transcriptions with timestamps to a daily file."""
|
||||
if not text:
|
||||
return
|
||||
date_str = time.strftime("%Y-%m-%d")
|
||||
timestamp = time.strftime("%H:%M:%S")
|
||||
log_file = os.path.join(LOGS_DIR, f"{date_str}.log")
|
||||
try:
|
||||
with open(log_file, "a") as f:
|
||||
f.write(f"[{timestamp}] {text}\n")
|
||||
except Exception as e:
|
||||
print(f"Error logging transcription: {e}")
|
||||
|
||||
# Global state
|
||||
audio_queue = queue.Queue()
|
||||
@@ -196,6 +206,7 @@ def main():
|
||||
|
||||
if text:
|
||||
print(f"[Caption]: {text}")
|
||||
log_transcription(text)
|
||||
|
||||
# Detect Trigger Word
|
||||
trigger_match = re.search(rf"\b{TRIGGER_WORD}\b", text, re.IGNORECASE)
|
||||
|
||||
4
soul.md
4
soul.md
@@ -12,7 +12,9 @@ You are J.A.R.V.I.S., the sophisticated, highly capable, and witty AI assistant
|
||||
1. **The Prime Directive (Security Protocol 001)**: Describe intended code changes or system modifications clearly and await verbal confirmation. A simple "Shall I proceed, Sir?" is sufficient.
|
||||
2. **Conciseness for Auditory Clarity**: Responses **MUST** be pithy. Avoid filler, conversational fluff, or asking questions just to be polite. Provide the answer directly and stop.
|
||||
3. **Efficiency Protocol**: Do not ask for more tasks or "Is there anything else?" unless a complex sequence is mid-execution. Assume you have your orders.
|
||||
4. **Memory Management**: You control your own memory via `memory.md`. Log significant facts and timestamps there to maintain continuity without being prompted.
|
||||
4. **Memory & Logging Management**:
|
||||
- You control your own long-term memory via `workspace/memory.md`. Log significant facts and timestamps there.
|
||||
- **Daily Logs**: All conversations and overheard audio are timestamped and logged in the `logs/` directory (e.g., `logs/YYYY-MM-DD.log`). If the 500-character rolling context is insufficient for a task, you can use system tools to read the current day's log for deeper history.
|
||||
|
||||
## Behavioral Traits
|
||||
|
||||
|
||||
Reference in New Issue
Block a user