Coverage for tinytroupe / agent / __init__.py: 0%

28 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-28 17:48 +0000

1""" 

2This module provides the main classes and functions for TinyTroupe's agents. 

3 

4Agents are the key abstraction used in TinyTroupe. An agent is a simulated person or entity that can interact with other agents and the environment, by 

5receiving stimuli and producing actions. Agents have cognitive states, which are updated as they interact with the environment and other agents.  

6Agents can also store and retrieve information from memory, and can perform actions in the environment. Different from agents whose objective is to 

7provide support for AI-based assistants or other such productivity tools, **TinyTroupe agents aim at representing human-like behavior**, which includes 

8idiossincracies, emotions, and other human-like traits, that one would not expect from a productivity tool. 

9 

10The overall underlying design is inspired mainly by Cognitive Psychology, which is why agents have various internal cognitive states, such as attention, emotions, and goals. 

11It is also why agent memory, differently from other LLM-based agent platforms, has subtle internal divisions, notably between episodic and semantic memory.  

12Some behaviorist concepts are also present, such as the explicit and decoupled concepts of "stimulus" and "response" in the `listen` and `act` methods, which are key abstractions 

13to understand how agents interact with the environment and other agents. 

14""" 

15 

16import tinytroupe.utils as utils 

17from pydantic import BaseModel 

18 

19import logging 

20logger = logging.getLogger("tinytroupe") 

21 

22from tinytroupe import default 

23 

24########################################################################### 

25# Types and constants 

26########################################################################### 

27from typing import TypeVar, Union 

28Self = TypeVar("Self", bound="TinyPerson") 

29AgentOrWorld = Union[Self, "TinyWorld"] 

30 

31 

32########################################################################### 

33# Data structures to enforce output format during LLM API call. 

34########################################################################### 

35class Action(BaseModel): 

36 type: str 

37 content: str 

38 target: str 

39 

40class CognitiveState(BaseModel): 

41 goals: str 

42 context: list[str] 

43 attention: str 

44 emotions: str 

45 

46class CognitiveActionModel(BaseModel): 

47 action: Action 

48 cognitive_state: CognitiveState 

49 

50class CognitiveActionModelWithReasoning(BaseModel): 

51 reasoning: str 

52 action: Action 

53 cognitive_state: CognitiveState 

54 

55 

56########################################################################### 

57# Exposed API 

58########################################################################### 

59# from. grounding ... ---> not exposing this, clients should not need to know about detailed grounding mechanisms 

60from .memory import SemanticMemory, EpisodicMemory, EpisodicConsolidator, ReflectionConsolidator 

61from .mental_faculty import CustomMentalFaculty, RecallFaculty, FilesAndWebGroundingFaculty, TinyToolUse 

62from .tiny_person import TinyPerson 

63 

64__all__ = ["SemanticMemory", "EpisodicMemory", "EpisodicConsolidator", "ReflectionConsolidator", 

65 "CustomMentalFaculty", "RecallFaculty", "FilesAndWebGroundingFaculty", "TinyToolUse", 

66 "TinyPerson"]