agentsims 0.1.0__tar.gz
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-0.1.0/.gitignore +27 -0
- agentsims-0.1.0/LICENSE +21 -0
- agentsims-0.1.0/PKG-INFO +66 -0
- agentsims-0.1.0/README.md +25 -0
- agentsims-0.1.0/agentsims/__init__.py +79 -0
- agentsims-0.1.0/agentsims/core/__init__.py +0 -0
- agentsims-0.1.0/agentsims/core/agent.py +62 -0
- agentsims-0.1.0/agentsims/core/harness.py +645 -0
- agentsims-0.1.0/agentsims/core/memory.py +86 -0
- agentsims-0.1.0/agentsims/core/updater.py +155 -0
- agentsims-0.1.0/agentsims/core/world.py +64 -0
- agentsims-0.1.0/agentsims/crawlers/__init__.py +0 -0
- agentsims-0.1.0/agentsims/crawlers/base.py +14 -0
- agentsims-0.1.0/agentsims/crawlers/mock.py +70 -0
- agentsims-0.1.0/agentsims/db/__init__.py +0 -0
- agentsims-0.1.0/agentsims/db/database.py +376 -0
- agentsims-0.1.0/agentsims/db/schema.py +82 -0
- agentsims-0.1.0/agentsims/llm/__init__.py +0 -0
- agentsims-0.1.0/agentsims/llm/anthropic.py +105 -0
- agentsims-0.1.0/agentsims/llm/base.py +28 -0
- agentsims-0.1.0/agentsims/monitor/__init__.py +0 -0
- agentsims-0.1.0/agentsims/monitor/logger.py +125 -0
- agentsims-0.1.0/agentsims/retriever/__init__.py +28 -0
- agentsims-0.1.0/agentsims/retriever/detector.py +196 -0
- agentsims-0.1.0/agentsims/retriever/engine.py +266 -0
- agentsims-0.1.0/agentsims/retriever/fetcher.py +197 -0
- agentsims-0.1.0/agentsims/retriever/formulator.py +138 -0
- agentsims-0.1.0/agentsims/retriever/synthesizer.py +152 -0
- agentsims-0.1.0/pyproject.toml +65 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.env
|
|
2
|
+
.env.*
|
|
3
|
+
!.env.example
|
|
4
|
+
*.pem
|
|
5
|
+
*.key
|
|
6
|
+
*.db
|
|
7
|
+
*.db-*
|
|
8
|
+
*.sqlite
|
|
9
|
+
*.sqlite3
|
|
10
|
+
*_results.json
|
|
11
|
+
__pycache__/
|
|
12
|
+
*.py[cod]
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.ipynb_checkpoints/
|
|
16
|
+
.venv/
|
|
17
|
+
venv/
|
|
18
|
+
build/
|
|
19
|
+
dist/
|
|
20
|
+
*.egg-info/
|
|
21
|
+
node_modules/
|
|
22
|
+
.next/
|
|
23
|
+
.DS_Store
|
|
24
|
+
._*
|
|
25
|
+
.claude/
|
|
26
|
+
.codex/
|
|
27
|
+
cache/
|
agentsims-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentSims contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
agentsims-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentsims
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Time-stepped multi-agent simulation engine powered by LLMs
|
|
5
|
+
Project-URL: Homepage, https://github.com/muyuhuatang/agentsims
|
|
6
|
+
Project-URL: Repository, https://github.com/muyuhuatang/agentsims
|
|
7
|
+
Project-URL: Issues, https://github.com/muyuhuatang/agentsims/issues
|
|
8
|
+
Project-URL: Website, https://agentsims.agentsnet.org
|
|
9
|
+
Author: muyuhuatang (Fan)
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agent-based-modeling,anthropic,llm,multi-agent,simulation
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: anthropic>=0.30
|
|
25
|
+
Requires-Dist: httpx>=0.27
|
|
26
|
+
Requires-Dist: pydantic>=2.0
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Provides-Extra: demo
|
|
29
|
+
Requires-Dist: fastapi>=0.115; extra == 'demo'
|
|
30
|
+
Requires-Dist: uvicorn>=0.30; extra == 'demo'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
35
|
+
Provides-Extra: notebooks
|
|
36
|
+
Requires-Dist: jupyterlab>=4.0; extra == 'notebooks'
|
|
37
|
+
Requires-Dist: matplotlib>=3.8; extra == 'notebooks'
|
|
38
|
+
Provides-Extra: retriever
|
|
39
|
+
Requires-Dist: ddgs>=9.16; extra == 'retriever'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# AgentSims
|
|
43
|
+
|
|
44
|
+
A Python framework for time-stepped multi-agent simulations with role cards,
|
|
45
|
+
agent memory, replaceable LLM backends, adaptive retrieval, SQLite persistence,
|
|
46
|
+
and terminal replay. Requires Python 3.10 or later.
|
|
47
|
+
|
|
48
|
+
Source: <https://github.com/muyuhuatang/agentsims>
|
|
49
|
+
|
|
50
|
+
From a source checkout, install with:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
git clone https://github.com/muyuhuatang/agentsims.git
|
|
54
|
+
cd agentsims
|
|
55
|
+
python -m pip install -e ./packages/agentsims
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
An Anthropic API key is required for the default backend. Custom `BaseLLM`
|
|
59
|
+
implementations can run locally. The repository includes an offline smoke
|
|
60
|
+
example, four scenario scripts, four notebooks, a cookbook, and a read-only
|
|
61
|
+
FastAPI demo. See the repository README for setup and validation commands.
|
|
62
|
+
|
|
63
|
+
The examples are synthetic simulations, not forecasts. Live LLM and retrieval
|
|
64
|
+
calls may incur provider charges; the source's cost tables are estimates.
|
|
65
|
+
|
|
66
|
+
MIT license; see LICENSE.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# AgentSims
|
|
2
|
+
|
|
3
|
+
A Python framework for time-stepped multi-agent simulations with role cards,
|
|
4
|
+
agent memory, replaceable LLM backends, adaptive retrieval, SQLite persistence,
|
|
5
|
+
and terminal replay. Requires Python 3.10 or later.
|
|
6
|
+
|
|
7
|
+
Source: <https://github.com/muyuhuatang/agentsims>
|
|
8
|
+
|
|
9
|
+
From a source checkout, install with:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
git clone https://github.com/muyuhuatang/agentsims.git
|
|
13
|
+
cd agentsims
|
|
14
|
+
python -m pip install -e ./packages/agentsims
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
An Anthropic API key is required for the default backend. Custom `BaseLLM`
|
|
18
|
+
implementations can run locally. The repository includes an offline smoke
|
|
19
|
+
example, four scenario scripts, four notebooks, a cookbook, and a read-only
|
|
20
|
+
FastAPI demo. See the repository README for setup and validation commands.
|
|
21
|
+
|
|
22
|
+
The examples are synthetic simulations, not forecasts. Live LLM and retrieval
|
|
23
|
+
calls may incur provider charges; the source's cost tables are estimates.
|
|
24
|
+
|
|
25
|
+
MIT license; see LICENSE.
|
|
@@ -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
|
|
@@ -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
|