too much
This commit is contained in:
@@ -94,31 +94,32 @@ class CharacterExplorer:
|
||||
|
||||
filter_choice = input("Choose filter (1-6): ").strip()
|
||||
|
||||
memories = self.agent.memory_stream.memories.copy()
|
||||
# memories = self.agent.memory_stream.memories.copy()
|
||||
|
||||
if filter_choice == "2":
|
||||
memories = [m for m in memories if m.memory_type == "observation"]
|
||||
memories = [m for m in self.agent.memory_stream.memories if m.memory_type == "observation"]
|
||||
title = "Observations"
|
||||
elif filter_choice == "3":
|
||||
memories = [m for m in memories if m.memory_type == "reflection"]
|
||||
memories = [m for m in self.agent.memory_stream.memories if m.memory_type == "reflection"]
|
||||
title = "Reflections"
|
||||
elif filter_choice == "4":
|
||||
memories = [m for m in memories if m.memory_type == "plan"]
|
||||
memories = [m for m in self.agent.memory_stream.memories if m.memory_type == "plan"]
|
||||
title = "Plans"
|
||||
elif filter_choice == "5":
|
||||
memories = sorted(memories, key=lambda m: m.importance_score, reverse=True)
|
||||
memories = sorted(self.agent.memory_stream.memories, key=lambda m: m.importance_score, reverse=True)
|
||||
title = "All Memories (by importance)"
|
||||
elif filter_choice == "6":
|
||||
memories = sorted(memories, key=lambda m: m.creation_time, reverse=True)
|
||||
memories = sorted(self.agent.memory_stream.memories, key=lambda m: m.creation_time, reverse=True)
|
||||
title = "All Memories (by recency)"
|
||||
else:
|
||||
memories = self.agent.memory_stream.memories
|
||||
title = "All Memories"
|
||||
|
||||
print(f"\n📋 {title} ({len(memories)} total):")
|
||||
for i, memory in enumerate(memories, 1):
|
||||
for i, memory in enumerate(memories):
|
||||
age_hours = (memory.last_accessed - memory.creation_time).total_seconds() / 3600
|
||||
print(
|
||||
f"{i:3d}. [{memory.memory_type[:4]}] [imp:{memory.importance_score}] [age:{age_hours:.1f}h] {memory.description}")
|
||||
f"[#{i:3d}] [{memory.memory_type[:4]}] [imp:{memory.importance_score}] [age:{age_hours:.1f}h] {memory.description}")
|
||||
|
||||
if len(memories) > 20:
|
||||
print(f"\n... showing first 20 of {len(memories)} memories")
|
||||
@@ -126,43 +127,28 @@ class CharacterExplorer:
|
||||
|
||||
async def _handle_view_memory(self):
|
||||
"""View a specific memory with its related memories"""
|
||||
try:
|
||||
memory_num = int(input(f"\nEnter memory number (1-{len(self.agent.memory_stream.memories)}): ").strip())
|
||||
memory_num = int(input(f"\nEnter memory number (1-{len(self.agent.memory_stream.memories) - 1}): ").strip())
|
||||
|
||||
if 1 <= memory_num <= len(self.agent.memory_stream.memories):
|
||||
memory = self.agent.memory_stream.memories[memory_num - 1]
|
||||
if 0 <= memory_num <= len(self.agent.memory_stream.memories) - 1:
|
||||
memory = self.agent.memory_stream.memories[memory_num]
|
||||
|
||||
print(f"\n🔍 Memory #{memory_num} Details:")
|
||||
print(f" Type: {memory.memory_type}")
|
||||
print(f" Importance: {memory.importance_score}/10")
|
||||
print(f" Created: {memory.creation_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f" Last accessed: {memory.last_accessed.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f" Description: {memory.description}")
|
||||
print(f"\n🔍 Memory #{memory_num} Details:")
|
||||
print(f" Type: {memory.memory_type}")
|
||||
print(f" Importance: {memory.importance_score}/10")
|
||||
print(f" Created: {memory.creation_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f" Last accessed: {memory.last_accessed.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f" Description: {memory.description}")
|
||||
|
||||
# Show related memories using embeddings
|
||||
print(f"\n🔗 Related memories (by similarity):")
|
||||
try:
|
||||
related = await self.agent._get_related_memories_for_scoring(
|
||||
memory.description,
|
||||
exclude_self=memory,
|
||||
k=5
|
||||
)
|
||||
for i, rel_mem in enumerate(related, 1):
|
||||
rel_index = self.agent.memory_stream.memories.index(rel_mem) + 1
|
||||
print(
|
||||
f" {i}. [#{rel_index}] [{rel_mem.memory_type}] {rel_mem.description[:70]}{'...' if len(rel_mem.description) > 70 else ''}")
|
||||
# Show related memories using embeddings
|
||||
if memory.memory_type == 'observation' or memory.memory_type == 'plan':
|
||||
print(f"\n🔗 Related memories:")
|
||||
|
||||
if not related:
|
||||
print(" (No related memories found)")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ❌ Error finding related memories: {e}")
|
||||
|
||||
else:
|
||||
print(f"❌ Invalid memory number. Range: 1-{len(self.agent.memory_stream.memories)}")
|
||||
|
||||
except ValueError:
|
||||
print("❌ Please enter a valid number")
|
||||
for rel_mem in memory.related_memories:
|
||||
rel_index = self.agent.memory_stream.memories.index(rel_mem)
|
||||
print(
|
||||
f" [#{rel_index:3d}] [{rel_mem.memory_type}] {rel_mem.description}")
|
||||
else:
|
||||
print(f"❌ Invalid memory number. Range: 1-{len(self.agent.memory_stream.memories)}")
|
||||
|
||||
async def _handle_memory_stats(self):
|
||||
"""Show detailed memory statistics"""
|
||||
@@ -217,7 +203,10 @@ class CharacterExplorer:
|
||||
print(f" Personality: {self.agent.character.personality}")
|
||||
print(f" Occupation: {self.agent.character.occupation}")
|
||||
print(f" Location: {self.agent.character.location}")
|
||||
|
||||
print("")
|
||||
print(f" Traits")
|
||||
traits_summary = "\n".join([f" - {trait.strength}/10 {trait.name} ({trait.description})" for trait in self.agent.character.traits]) if self.agent.character.traits else "No traits yet."
|
||||
print(traits_summary)
|
||||
if self.agent.character.relationships:
|
||||
print(f" Relationships:")
|
||||
for person, relationship in self.agent.character.relationships.items():
|
||||
|
||||
Reference in New Issue
Block a user