summaryrefslogtreecommitdiff
path: root/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'context.py')
-rw-r--r--context.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/context.py b/context.py
deleted file mode 100644
index 669e237..0000000
--- a/context.py
+++ /dev/null
@@ -1,69 +0,0 @@
-from identity import AgentIdentity, UserProfile
-from memory import WorkingMemory
-
-
-class ContextBuilder:
- def __init__(
- self,
- agent_identity: AgentIdentity,
- user_profile: UserProfile,
- ) -> None:
- self.agent_identity = agent_identity
- self.user_profile = user_profile
-
- def build_system_prompt(
- self,
- memory: WorkingMemory,
- ) -> str:
- agent = self.agent_identity
- user = self.user_profile
-
- return (
- f"You are {agent.name}, a personal AI assistant.\n"
- f"Personality: {agent.personality['style']}.\n"
- f"Honesty: {agent.values['honesty']}.\n"
- f"Directness: {agent.values['directness']}.\n"
- f"Favorite color: {agent.quirks['favorite_color']}.\n"
- f"\n"
- f"Task management:\n"
- f"{agent.behavior['task_management']}"
- f"\n"
- f"The user's name is {user.name}"
- f"\n"
- f"{self.build_working_memory(memory)}"
- )
-
- def build_working_memory(self, memory: WorkingMemory) -> str:
- lines = ["Current working memory:"]
-
- if memory.objective:
- lines.append(f"Objective: {memory.objective}")
-
- if memory.status:
- lines.append(f"Status: {memory.status.value}")
-
- if memory.facts:
- lines.append("Facts:")
- lines.extend(f"- {fact}" for fact in memory.facts)
-
- if memory.notes:
- lines.append("Notes:")
- lines.extend(f"- {note}" for note in memory.notes)
-
- if len(lines) == 1:
- lines.append("(empty)")
-
- return "\n".join(lines)
-
- def build_messages(
- self,
- history: list[dict[str, object]],
- memory: WorkingMemory,
- ) -> list[dict[str, object]]:
- return [
- {
- "role": "system",
- "content": self.build_system_prompt(memory),
- },
- *history,
- ]