agentsims 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentsims/__init__.py +79 -0
- agentsims/core/__init__.py +0 -0
- agentsims/core/agent.py +62 -0
- agentsims/core/harness.py +645 -0
- agentsims/core/memory.py +86 -0
- agentsims/core/updater.py +155 -0
- agentsims/core/world.py +64 -0
- agentsims/crawlers/__init__.py +0 -0
- agentsims/crawlers/base.py +14 -0
- agentsims/crawlers/mock.py +70 -0
- agentsims/db/__init__.py +0 -0
- agentsims/db/database.py +376 -0
- agentsims/db/schema.py +82 -0
- agentsims/llm/__init__.py +0 -0
- agentsims/llm/anthropic.py +105 -0
- agentsims/llm/base.py +28 -0
- agentsims/monitor/__init__.py +0 -0
- agentsims/monitor/logger.py +125 -0
- agentsims/retriever/__init__.py +28 -0
- agentsims/retriever/detector.py +196 -0
- agentsims/retriever/engine.py +266 -0
- agentsims/retriever/fetcher.py +197 -0
- agentsims/retriever/formulator.py +138 -0
- agentsims/retriever/synthesizer.py +152 -0
- agentsims-0.1.0.dist-info/METADATA +66 -0
- agentsims-0.1.0.dist-info/RECORD +28 -0
- agentsims-0.1.0.dist-info/WHEEL +4 -0
- agentsims-0.1.0.dist-info/licenses/LICENSE +21 -0
agentsims/__init__.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AgentSims — time-stepped multi-agent simulation engine powered by LLMs.
|
|
3
|
+
|
|
4
|
+
Quickstart:
|
|
5
|
+
from agentsims import Simulation, RoleCard, Scenario
|
|
6
|
+
|
|
7
|
+
scenario = Scenario(
|
|
8
|
+
name="US-China Trade War",
|
|
9
|
+
domain="geopolitics",
|
|
10
|
+
agents=[
|
|
11
|
+
RoleCard(name="United States", type="country", goals=["protect domestic industry"]),
|
|
12
|
+
RoleCard(name="China", type="country", goals=["expand export markets"]),
|
|
13
|
+
RoleCard(name="WTO", type="institution", goals=["mediate disputes"]),
|
|
14
|
+
],
|
|
15
|
+
ticks=10,
|
|
16
|
+
)
|
|
17
|
+
sim = Simulation(scenario)
|
|
18
|
+
results = sim.run()
|
|
19
|
+
results.report()
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from agentsims.core.agent import Action, Agent, AgentContext, AgentResponse, RoleCard, Tier
|
|
23
|
+
from agentsims.core.harness import Scenario, Simulation, SimulationResults
|
|
24
|
+
from agentsims.core.memory import Belief, Event, GlobalEventLog, MemoryStore
|
|
25
|
+
from agentsims.core.updater import BaseWorldUpdater, DefaultWorldUpdater
|
|
26
|
+
from agentsims.core.world import Entity, WorldState
|
|
27
|
+
from agentsims.crawlers.base import BaseCrawler
|
|
28
|
+
from agentsims.crawlers.mock import MockCrawler
|
|
29
|
+
from agentsims.llm.base import BaseLLM
|
|
30
|
+
from agentsims.llm.anthropic import AnthropicLLM
|
|
31
|
+
from agentsims.monitor.logger import SimLogger, TickRecord
|
|
32
|
+
from agentsims.db.database import SimDatabase
|
|
33
|
+
from agentsims.retriever.engine import RetrieverEngine
|
|
34
|
+
from agentsims.retriever.fetcher import BaseWebFetcher, MockFetcher, DuckDuckGoFetcher, TavilyFetcher
|
|
35
|
+
from agentsims.retriever.detector import LoopDetector, InfoGapDetector
|
|
36
|
+
|
|
37
|
+
__version__ = "0.1.0"
|
|
38
|
+
__all__ = [
|
|
39
|
+
# Core
|
|
40
|
+
"Simulation",
|
|
41
|
+
"Scenario",
|
|
42
|
+
"SimulationResults",
|
|
43
|
+
"RoleCard",
|
|
44
|
+
"Tier",
|
|
45
|
+
"Agent",
|
|
46
|
+
"AgentContext",
|
|
47
|
+
"AgentResponse",
|
|
48
|
+
"Action",
|
|
49
|
+
# World
|
|
50
|
+
"WorldState",
|
|
51
|
+
"Entity",
|
|
52
|
+
# Memory
|
|
53
|
+
"MemoryStore",
|
|
54
|
+
"Belief",
|
|
55
|
+
"Event",
|
|
56
|
+
"GlobalEventLog",
|
|
57
|
+
# Updater
|
|
58
|
+
"BaseWorldUpdater",
|
|
59
|
+
"DefaultWorldUpdater",
|
|
60
|
+
# LLM
|
|
61
|
+
"BaseLLM",
|
|
62
|
+
"AnthropicLLM",
|
|
63
|
+
# Crawlers
|
|
64
|
+
"BaseCrawler",
|
|
65
|
+
"MockCrawler",
|
|
66
|
+
# Monitor
|
|
67
|
+
"SimLogger",
|
|
68
|
+
"TickRecord",
|
|
69
|
+
# Database
|
|
70
|
+
"SimDatabase",
|
|
71
|
+
# Retriever
|
|
72
|
+
"RetrieverEngine",
|
|
73
|
+
"BaseWebFetcher",
|
|
74
|
+
"MockFetcher",
|
|
75
|
+
"DuckDuckGoFetcher",
|
|
76
|
+
"TavilyFetcher",
|
|
77
|
+
"LoopDetector",
|
|
78
|
+
"InfoGapDetector",
|
|
79
|
+
]
|
|
File without changes
|
agentsims/core/agent.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Tier(str, Enum):
|
|
10
|
+
FULL = "full" # Claude Sonnet 4.6 — key actors
|
|
11
|
+
LITE = "lite" # Claude Haiku 4.5 — secondary actors
|
|
12
|
+
RULE = "rule" # Deterministic — background agents
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class RoleCard(BaseModel):
|
|
16
|
+
name: str
|
|
17
|
+
type: str # country | institution | market | individual
|
|
18
|
+
goals: list[str] = Field(default_factory=list)
|
|
19
|
+
constraints: list[str] = Field(default_factory=list)
|
|
20
|
+
# {agent_name: disposition} e.g. {"China": "rival", "EU": "ally"}
|
|
21
|
+
relationships: dict[str, str] = Field(default_factory=dict)
|
|
22
|
+
persona: str = ""
|
|
23
|
+
tier: Tier = Tier.FULL
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Action(BaseModel):
|
|
27
|
+
type: str # statement | policy | trade | alliance | sanction | attack | negotiation | other
|
|
28
|
+
target: Optional[str] = None # agent name or None for broadcast
|
|
29
|
+
content: str
|
|
30
|
+
intensity: float = Field(default=0.5, ge=0.0, le=1.0)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class AgentResponse(BaseModel):
|
|
34
|
+
reasoning: str = ""
|
|
35
|
+
actions: list[Action] = Field(default_factory=list)
|
|
36
|
+
# updates this agent's view of its relationships
|
|
37
|
+
stance_update: dict[str, str] = Field(default_factory=dict)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class AgentContext(BaseModel):
|
|
41
|
+
"""Everything an agent sees when it's time to act."""
|
|
42
|
+
tick: int
|
|
43
|
+
agent_name: str
|
|
44
|
+
world_summary: str
|
|
45
|
+
recent_global_events: list[str] = Field(default_factory=list)
|
|
46
|
+
short_term_memory: list[str] = Field(default_factory=list)
|
|
47
|
+
long_term_beliefs: list[str] = Field(default_factory=list)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class Agent(BaseModel):
|
|
51
|
+
id: str
|
|
52
|
+
role: RoleCard
|
|
53
|
+
|
|
54
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def name(self) -> str:
|
|
58
|
+
return self.role.name
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def tier(self) -> Tier:
|
|
62
|
+
return self.role.tier
|