36 lines
943 B
Python
36 lines
943 B
Python
from pydantic import BaseModel
|
|
|
|
|
|
class Belief(BaseModel):
|
|
"""
|
|
Represents a single belief in the BDI system.
|
|
|
|
:ivar name: The functor or name of the belief (e.g., 'user_said').
|
|
:ivar arguments: A list of string arguments for the belief, or None if the belief has no
|
|
arguments.
|
|
"""
|
|
|
|
name: str
|
|
arguments: list[str] | None = None
|
|
|
|
# To make it hashable
|
|
model_config = {"frozen": True}
|
|
|
|
|
|
class BeliefMessage(BaseModel):
|
|
"""
|
|
A container for communicating beliefs between agents.
|
|
|
|
:ivar create: Beliefs to create.
|
|
:ivar delete: Beliefs to delete.
|
|
:ivar replace: Beliefs to replace. Deletes all beliefs with the same name, replacing them with
|
|
one new belief.
|
|
"""
|
|
|
|
create: list[Belief] = []
|
|
delete: list[Belief] = []
|
|
replace: list[Belief] = []
|
|
|
|
def has_values(self) -> bool:
|
|
return len(self.create) > 0 or len(self.delete) > 0 or len(self.replace) > 0
|