econagents 0.0.3__tar.gz → 0.0.7__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.
Files changed (30) hide show
  1. {econagents-0.0.3 → econagents-0.0.7}/PKG-INFO +18 -10
  2. {econagents-0.0.3 → econagents-0.0.7}/README.md +6 -4
  3. {econagents-0.0.3 → econagents-0.0.7}/econagents/__init__.py +1 -1
  4. econagents-0.0.7/econagents/cli.py +136 -0
  5. econagents-0.0.7/econagents/config_parser/__init__.py +18 -0
  6. econagents-0.0.7/econagents/config_parser/base.py +518 -0
  7. econagents-0.0.7/econagents/config_parser/basic.py +45 -0
  8. econagents-0.0.7/econagents/config_parser/ibex_tudelft.py +243 -0
  9. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/game_runner.py +112 -13
  10. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/manager/base.py +4 -8
  11. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/transport.py +62 -28
  12. {econagents-0.0.3 → econagents-0.0.7}/pyproject.toml +28 -33
  13. {econagents-0.0.3 → econagents-0.0.7}/LICENSE +0 -0
  14. {econagents-0.0.3 → econagents-0.0.7}/econagents/_c_extension.pyi +0 -0
  15. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/__init__.py +0 -0
  16. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/agent_role.py +0 -0
  17. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/events.py +0 -0
  18. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/logging_mixin.py +0 -0
  19. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/manager/__init__.py +0 -0
  20. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/manager/phase.py +0 -0
  21. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/state/__init__.py +0 -0
  22. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/state/fields.py +0 -0
  23. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/state/game.py +0 -0
  24. {econagents-0.0.3 → econagents-0.0.7}/econagents/core/state/market.py +0 -0
  25. {econagents-0.0.3 → econagents-0.0.7}/econagents/llm/__init__.py +0 -0
  26. {econagents-0.0.3 → econagents-0.0.7}/econagents/llm/base.py +0 -0
  27. {econagents-0.0.3 → econagents-0.0.7}/econagents/llm/observability.py +0 -0
  28. {econagents-0.0.3 → econagents-0.0.7}/econagents/llm/ollama.py +0 -0
  29. {econagents-0.0.3 → econagents-0.0.7}/econagents/llm/openai.py +0 -0
  30. {econagents-0.0.3 → econagents-0.0.7}/econagents/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: econagents
3
- Version: 0.0.3
3
+ Version: 0.0.7
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Dylan Castillo
@@ -13,26 +13,32 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Provides-Extra: all
16
- Provides-Extra: default
17
16
  Provides-Extra: langfuse
18
17
  Provides-Extra: langsmith
19
18
  Provides-Extra: ollama
20
19
  Provides-Extra: openai
21
- Requires-Dist: jinja2 (>=3.1.6,<4.0.0)
22
- Requires-Dist: pydantic (>=2.11.3,<3.0.0)
23
- Requires-Dist: requests (>=2.32.3,<3.0.0)
24
- Requires-Dist: websockets (>=15.0,<16.0)
20
+ Provides-Extra: standard
21
+ Requires-Dist: langfuse ; extra == "all"
22
+ Requires-Dist: langfuse ; extra == "langfuse"
23
+ Requires-Dist: langsmith ; extra == "all"
24
+ Requires-Dist: langsmith ; extra == "langsmith"
25
+ Requires-Dist: langsmith ; extra == "standard"
26
+ Requires-Dist: ollama ; extra == "all"
27
+ Requires-Dist: ollama ; extra == "ollama"
28
+ Requires-Dist: openai ; extra == "all"
29
+ Requires-Dist: openai ; extra == "openai"
30
+ Requires-Dist: openai ; extra == "standard"
25
31
  Description-Content-Type: text/markdown
26
32
 
27
33
  <div align="center">
28
- <img src="https://raw.githubusercontent.com/iwanalabs/econagents/main/assets/logo_200w.png">
34
+ <img src="https://raw.githubusercontent.com/IBEX-TUDelft/econagents/main/assets/logo_200w.png">
29
35
  </div>
30
36
 
31
37
  <div align="center">
32
38
 
33
39
  ![Python compat](https://img.shields.io/badge/%3E=python-3.10-blue.svg)
34
40
  [![PyPi](https://img.shields.io/pypi/v/econagents.svg)](https://pypi.python.org/pypi/econagents)
35
- [![GHA Status](https://github.com/iwanalabs/econagents/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/iwanalabs/econagents/actions?query=workflow%3Atests)
41
+ [![GHA Status](https://github.com/IBEX-TUDelft/econagents/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/IBEX-TUDelft/econagents/actions?query=workflow%3Atests)
36
42
  [![Documentation Status](https://readthedocs.org/projects/econagents/badge/?version=latest)](https://econagents.readthedocs.io/en/latest/?badge=latest)
37
43
 
38
44
  </div>
@@ -50,7 +56,7 @@ econagents is a Python library that lets you use LLM agents in economic experime
50
56
  pip install econagents
51
57
 
52
58
  # Or install directly from GitHub
53
- pip install git+https://github.com/iwanalabs/econagents.git
59
+ pip install git+https://github.com/IBEX-TUDelft/econagents.git
54
60
  ```
55
61
 
56
62
  ## Framework Components
@@ -76,7 +82,7 @@ The simplest game to run is a version of the repeated prisoner's dilemma game th
76
82
 
77
83
  ```shell
78
84
  # Run the server
79
- python examples/server/prisoner/server.py
85
+ python examples/prisoner/server/server.py
80
86
 
81
87
  # Run the experiment (in a separate terminal)
82
88
  python examples/prisoner/run_game.py
@@ -95,3 +101,5 @@ Note: you still have to set up the connection to the agents.
95
101
 
96
102
  For detailed guides and API reference, visit [the documentation](https://econagents.readthedocs.io/en/latest/).
97
103
 
104
+ You should also check out the [econagents cookbook](https://github.com/iwanalabs/econagents-cookbook/tree/main/) for more examples.
105
+
@@ -1,12 +1,12 @@
1
1
  <div align="center">
2
- <img src="https://raw.githubusercontent.com/iwanalabs/econagents/main/assets/logo_200w.png">
2
+ <img src="https://raw.githubusercontent.com/IBEX-TUDelft/econagents/main/assets/logo_200w.png">
3
3
  </div>
4
4
 
5
5
  <div align="center">
6
6
 
7
7
  ![Python compat](https://img.shields.io/badge/%3E=python-3.10-blue.svg)
8
8
  [![PyPi](https://img.shields.io/pypi/v/econagents.svg)](https://pypi.python.org/pypi/econagents)
9
- [![GHA Status](https://github.com/iwanalabs/econagents/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/iwanalabs/econagents/actions?query=workflow%3Atests)
9
+ [![GHA Status](https://github.com/IBEX-TUDelft/econagents/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/IBEX-TUDelft/econagents/actions?query=workflow%3Atests)
10
10
  [![Documentation Status](https://readthedocs.org/projects/econagents/badge/?version=latest)](https://econagents.readthedocs.io/en/latest/?badge=latest)
11
11
 
12
12
  </div>
@@ -24,7 +24,7 @@ econagents is a Python library that lets you use LLM agents in economic experime
24
24
  pip install econagents
25
25
 
26
26
  # Or install directly from GitHub
27
- pip install git+https://github.com/iwanalabs/econagents.git
27
+ pip install git+https://github.com/IBEX-TUDelft/econagents.git
28
28
  ```
29
29
 
30
30
  ## Framework Components
@@ -50,7 +50,7 @@ The simplest game to run is a version of the repeated prisoner's dilemma game th
50
50
 
51
51
  ```shell
52
52
  # Run the server
53
- python examples/server/prisoner/server.py
53
+ python examples/prisoner/server/server.py
54
54
 
55
55
  # Run the experiment (in a separate terminal)
56
56
  python examples/prisoner/run_game.py
@@ -68,3 +68,5 @@ Note: you still have to set up the connection to the agents.
68
68
  ## Documentation
69
69
 
70
70
  For detailed guides and API reference, visit [the documentation](https://econagents.readthedocs.io/en/latest/).
71
+
72
+ You should also check out the [econagents cookbook](https://github.com/iwanalabs/econagents-cookbook/tree/main/) for more examples.
@@ -12,7 +12,7 @@ from econagents.core.state.game import GameState, MetaInformation, PrivateInform
12
12
  from econagents.llm.openai import ChatOpenAI
13
13
 
14
14
  # Don't manually change, let poetry-dynamic-versioning handle it.
15
- __version__ = "0.0.3"
15
+ __version__ = "0.0.7"
16
16
 
17
17
  __all__: list[str] = [
18
18
  "AgentRole",
@@ -0,0 +1,136 @@
1
+ import argparse
2
+ import asyncio
3
+ import sys
4
+ import json
5
+ from pathlib import Path
6
+ from typing import Dict, List, Any
7
+
8
+ from econagents.config_parser.base import BaseConfigParser
9
+
10
+
11
+ async def async_main(args: argparse.Namespace):
12
+ """Asynchronous main function to run the experiment."""
13
+ config_path = Path(args.config_path).resolve()
14
+ login_payloads_path = Path(args.login_payloads_file).resolve()
15
+
16
+ if not config_path.is_file():
17
+ print(f"Error: Configuration file not found at {config_path}", file=sys.stderr)
18
+ sys.exit(1)
19
+
20
+ if not login_payloads_path.is_file():
21
+ print(f"Error: Login payloads file not found at {login_payloads_path}", file=sys.stderr)
22
+ sys.exit(1)
23
+
24
+ try:
25
+ # Load configuration using the base parser
26
+ parser = BaseConfigParser(config_path)
27
+ config = parser.config
28
+ except Exception as e:
29
+ print(f"Error loading or parsing config file {config_path}: {e}", file=sys.stderr)
30
+ sys.exit(1)
31
+
32
+ login_payloads: List[Dict[str, Any]] = [] # Initialize empty list
33
+ try:
34
+ with open(login_payloads_path, "r") as f:
35
+ for line_num, line in enumerate(f, 1):
36
+ line = line.strip() # Remove leading/trailing whitespace
37
+ if not line: # Skip empty lines
38
+ continue
39
+ try:
40
+ payload = json.loads(line)
41
+ if not isinstance(payload, dict):
42
+ raise ValueError("Each line must be a valid JSON object.")
43
+ login_payloads.append(payload)
44
+ except json.JSONDecodeError as e:
45
+ print(f"Error decoding JSON on line {line_num} in {login_payloads_path}: {e}", file=sys.stderr)
46
+ sys.exit(1)
47
+ except ValueError as e:
48
+ print(f"Error processing line {line_num} in {login_payloads_path}: {e}", file=sys.stderr)
49
+ sys.exit(1)
50
+
51
+ if not login_payloads: # Check if any payloads were loaded
52
+ print(f"Error: No valid login payloads found in {login_payloads_path}", file=sys.stderr)
53
+ sys.exit(1)
54
+
55
+ except Exception as e:
56
+ print(f"Error reading login payloads file {login_payloads_path}: {e}", file=sys.stderr)
57
+ sys.exit(1)
58
+
59
+ # Ensure the number of payloads matches the number of agents defined
60
+ num_defined_agents = len(config.agents)
61
+ if len(login_payloads) != num_defined_agents:
62
+ print(
63
+ f"Error: Number of login payloads ({len(login_payloads)}) in {login_payloads_path} "
64
+ f"does not match the number of agents defined in the config ({num_defined_agents}).",
65
+ file=sys.stderr,
66
+ )
67
+ sys.exit(1)
68
+
69
+ # Extract gameId from the first payload for display purposes (assuming all payloads are for the same game)
70
+ # Add basic check to ensure payloads exist and have gameId
71
+ game_id_display = "N/A"
72
+ if login_payloads and isinstance(login_payloads[0], dict) and "gameId" in login_payloads[0]:
73
+ game_id_display = login_payloads[0]["gameId"]
74
+
75
+ print(f"Starting experiment '{config.name}' with Game ID: {game_id_display}...")
76
+ print(f"Using config: {config_path}")
77
+ print(f"Using login payloads from: {login_payloads_path}")
78
+ print(f"Number of agents: {len(login_payloads)}")
79
+
80
+ try:
81
+ await parser.run_experiment(login_payloads)
82
+ print("Experiment finished.")
83
+ except Exception as e:
84
+ print(f"Error running experiment: {e}", file=sys.stderr)
85
+ sys.exit(1)
86
+
87
+
88
+ def run_cli():
89
+ """Entry point function for the CLI script."""
90
+ parser = argparse.ArgumentParser(
91
+ description=(
92
+ "Economic Agents CLI - Run experiments with AI agents in economic simulations.\n\n"
93
+ "Example usage:\n"
94
+ " econagents run config.yaml --login-payloads-file payloads.jsonl\n\n"
95
+ "The config file should be a YAML file defining the experiment setup.\n"
96
+ "The login payloads file should be a JSONL file with login credentials for each agent."
97
+ ),
98
+ formatter_class=argparse.RawDescriptionHelpFormatter
99
+ )
100
+ subparsers = parser.add_subparsers(dest="command", required=True, help="Available commands")
101
+
102
+ # --- Run Command ---
103
+ run_parser = subparsers.add_parser(
104
+ "run",
105
+ help="Run an experiment defined by a YAML configuration file.",
106
+ description=(
107
+ "Run an economic agent experiment using the specified configuration.\n\n"
108
+ "Example:\n"
109
+ " econagents run experiments/market_sim.yaml --login-payloads-file credentials.jsonl"
110
+ ),
111
+ formatter_class=argparse.RawDescriptionHelpFormatter
112
+ )
113
+ run_parser.add_argument(
114
+ "config_path",
115
+ type=str,
116
+ help="Path to the experiment configuration YAML file that defines the agent behaviors and experiment parameters."
117
+ )
118
+ run_parser.add_argument(
119
+ "--login-payloads-file",
120
+ required=True,
121
+ type=str,
122
+ help="Path to a JSON Lines (.jsonl) file containing login credentials for each agent, one per line."
123
+ )
124
+
125
+ args = parser.parse_args()
126
+
127
+ if args.command == "run":
128
+ try:
129
+ asyncio.run(async_main(args))
130
+ except KeyboardInterrupt:
131
+ print("\nExperiment interrupted by user.")
132
+ sys.exit(0)
133
+
134
+
135
+ if __name__ == "__main__":
136
+ run_cli()
@@ -0,0 +1,18 @@
1
+ """
2
+ Configuration parsers for different server types.
3
+
4
+ This package provides configuration parsers for different server types:
5
+ - Base: No custom event handlers
6
+ - Basic: Custom event handler for player-is-ready messages
7
+ - IBEX-TUDelft: Handles player-is-ready messages and role assignment
8
+ """
9
+
10
+ from econagents.config_parser.base import BaseConfigParser
11
+ from econagents.config_parser.basic import BasicConfigParser
12
+ from econagents.config_parser.ibex_tudelft import IbexTudelftConfigParser
13
+
14
+ __all__ = [
15
+ "BaseConfigParser",
16
+ "BasicConfigParser",
17
+ "IbexTudelftConfigParser",
18
+ ]