too much
This commit is contained in:
46
living_agents/datatypes.py
Normal file
46
living_agents/datatypes.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional, Literal, TypedDict
|
||||
from datetime import datetime
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
class CharacterTemplate(TypedDict):
|
||||
name: str
|
||||
observations: List[str]
|
||||
reflections: List[str]
|
||||
plans: List[str]
|
||||
yaml_file: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Memory:
|
||||
"""A single memory object with Stanford's architecture"""
|
||||
description: str
|
||||
creation_time: datetime = field(default_factory=datetime.now)
|
||||
last_accessed: datetime = field(default_factory=datetime.now)
|
||||
importance_score: int = 5 # 1-10 scale
|
||||
embedding: Optional[List[float]] = None
|
||||
memory_type: Literal["observation", "reflection", "plan"] = "observation"
|
||||
related_memories: List[int] = field(default_factory=list) # IDs of supporting memories
|
||||
|
||||
def __post_init__(self):
|
||||
if self.last_accessed is None:
|
||||
self.last_accessed = self.creation_time
|
||||
|
||||
|
||||
@dataclass
|
||||
class Character:
|
||||
name: str # Still required
|
||||
age: Optional[int] = None
|
||||
personality: str = ""
|
||||
occupation: str = ""
|
||||
location: str = ""
|
||||
relationships: Dict[str, str] = field(default_factory=dict)
|
||||
goals: List[str] = field(default_factory=list)
|
||||
_id: str = field(default_factory=lambda: str(uuid4())[:8])
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._id)
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, Character) and self._id == other._id
|
||||
Reference in New Issue
Block a user