The Big One #43

Merged
k.marinus merged 93 commits from feat/reset-experiment-and-phase into dev 2026-01-26 19:20:45 +00:00
2 changed files with 26 additions and 5 deletions
Showing only changes of commit af832980c8 - Show all commits

View File

@@ -361,6 +361,10 @@ class AgentSpeakGenerator:
def _(self, goal: Goal, achieved: bool = False) -> AstExpression: def _(self, goal: Goal, achieved: bool = False) -> AstExpression:
return AstLiteral(f"{'achieved_' if achieved else ''}{self._slugify_str(goal.name)}") return AstLiteral(f"{'achieved_' if achieved else ''}{self._slugify_str(goal.name)}")
@_astify.register
def _(self, trigger: Trigger) -> AstExpression:
return AstLiteral(self.slugify(trigger))
@_astify.register @_astify.register
def _(self, sa: SpeechAction) -> AstExpression: def _(self, sa: SpeechAction) -> AstExpression:
return AstLiteral("say", [AstString(sa.text)]) return AstLiteral("say", [AstString(sa.text)])
@@ -374,6 +378,26 @@ class AgentSpeakGenerator:
def _(self, la: LLMAction) -> AstExpression: def _(self, la: LLMAction) -> AstExpression:
return AstLiteral("reply_with_goal", [AstString(la.goal)]) return AstLiteral("reply_with_goal", [AstString(la.goal)])
@staticmethod
@singledispatchmethod
def slugify(element: ProgramElement) -> str:
raise NotImplementedError(f"Cannot convert element {element} to a slug.")
@staticmethod
@slugify.register
def _(sb: SemanticBelief) -> str:
return f"semantic_{AgentSpeakGenerator._slugify_str(sb.name)}"
@staticmethod
@slugify.register
def _(g: Goal) -> str:
return AgentSpeakGenerator._slugify_str(g.name)
@staticmethod
@slugify.register
def _(t: Trigger):
return f"trigger_{AgentSpeakGenerator._slugify_str(t.name)}"
@staticmethod @staticmethod
def _slugify_str(text: str) -> str: def _slugify_str(text: str) -> str:
return slugify(text, separator="_", stopwords=["a", "an", "the", "we", "you", "I"]) return slugify(text, separator="_", stopwords=["a", "an", "the", "we", "you", "I"])

View File

@@ -177,7 +177,7 @@ class TextBeliefExtractorAgent(BaseAgent):
@staticmethod @staticmethod
def _create_belief_schema(belief: SemanticBelief) -> tuple[str, dict]: def _create_belief_schema(belief: SemanticBelief) -> tuple[str, dict]:
return AgentSpeakGenerator.get_semantic_belief_slug(belief), { return AgentSpeakGenerator.slugify(belief), {
"type": ["boolean", "null"], "type": ["boolean", "null"],
"description": belief.description, "description": belief.description,
} }
@@ -207,10 +207,7 @@ class TextBeliefExtractorAgent(BaseAgent):
@staticmethod @staticmethod
def _format_beliefs(beliefs: list[SemanticBelief]): def _format_beliefs(beliefs: list[SemanticBelief]):
return "\n".join( return "\n".join(
[ [f"- {AgentSpeakGenerator.slugify(belief)}: {belief.description}" for belief in beliefs]
f"- {AgentSpeakGenerator.get_semantic_belief_slug(belief)}: {belief.description}"
for belief in beliefs
]
) )
async def _infer_beliefs( async def _infer_beliefs(