summaryrefslogtreecommitdiff
path: root/personal_agent/identity.py
blob: ec1cc19dfacddfd2972f454eaa6ac85f50b435a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import tomllib
from dataclasses import dataclass


@dataclass
class AgentIdentity:
    name: str
    personality: dict[str, str]
    values: dict[str, bool]
    quirks: dict[str, str]
    behavior: dict[str, str]


@dataclass
class UserProfile:
    name: str
    preferences: dict[str, str]


def load_agent_identity(path: str) -> AgentIdentity:
    with open(path, "rb") as file:
        data = tomllib.load(file)

    return AgentIdentity(
        name=data["name"],
        personality=data["personality"],
        values=data["values"],
        quirks=data["quirks"],
        behavior=data["behavior"],
    )


def load_user_profile(path: str) -> UserProfile:
    with open(path, "rb") as file:
        data = tomllib.load(file)

    return UserProfile(
        name=data["name"],
        preferences=data["preferences"],
    )