/
githubmirror
/
Multi-GPT
Обзор
Документация
Войти
/
githubmirror
/
Multi-GPT
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
multigpt/agent_traits.py
37 строк
1 KB
Lukas Ruflair
cleaned up code
26 апр 2023, 15:52
26 апр 2023, 15:52
54f86a7
Код
Авторство
О чём код?
from yaml.constructor import SafeConstructor from yaml.representer import SafeRepresenter class AgentTraits: def __init__(self, openness: int = -1, agreeableness: int = -1, conscientiousness: int = -1, emotional_stability: int = -1, assertiveness: int = -1, description: str = ""): self.openness = openness self.agreeableness = agreeableness self.conscientiousness = conscientiousness self.emotional_stability = emotional_stability self.assertiveness = assertiveness self.description = description def __str__(self): return ( f"Openness: {self.openness}\n" f"Agreeableness: {self.agreeableness}\n" f"Conscientiousness: {self.conscientiousness}\n" f"Emotional Stability: {self.emotional_stability}\n" f"Assertiveness: {self.assertiveness}\n\n" f"{self.description}" ) def agent_traits_constructor(loader, node): values = loader.construct_mapping(node) return AgentTraits(**values) def agent_traits_representer(dumper, data): return dumper.represent_mapping('tag:yaml.org,2002:python/object:multigpt.agent_traits.AgentTraits', data.__dict__) SafeConstructor.add_constructor('tag:yaml.org,2002:python/object:multigpt.agent_traits.AgentTraits', agent_traits_constructor) SafeRepresenter.add_representer(AgentTraits, agent_traits_representer)