gabm 0.1.1__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.
gabm-0.1.1/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, compolis
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gabm-0.1.1/MANIFEST.in ADDED
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include src *
gabm-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,420 @@
1
+ Metadata-Version: 2.4
2
+ Name: gabm
3
+ Version: 0.1.1
4
+ Summary: Generative Agent-Based Model (GABM) framework.
5
+ Home-page: https://github.com/compolis/gabm
6
+ Author: GABM Contributors
7
+ Author-email: GABM Contributors <agdturner@gmail.com>
8
+ License: BSD-3-Clause
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: openai==1.13.3
16
+ Requires-Dist: google-generativeai==0.4.1
17
+ Requires-Dist: httpx==0.28.1
18
+ Requires-Dist: deepseek==1.0.0
19
+ Dynamic: license-file
20
+
21
+ #
22
+ <!-- Badges -->
23
+ <p align="left">
24
+ <a href="https://github.com/compolis/gabm/actions/workflows/ci.yml" title="Build Status">
25
+ <img src="https://img.shields.io/github/actions/workflow/status/compolis/gabm/ci.yml?branch=main&label=build" alt="Build Status" />
26
+ </a>
27
+ <a href="https://github.com/compolis/gabm/blob/main/LICENSE" title="License">
28
+ <img src="https://img.shields.io/github/license/compolis/gabm" alt="License" />
29
+ </a>
30
+ <a href="https://www.python.org/downloads/release/python-3120/" title="Python Version">
31
+ <img src="https://img.shields.io/badge/python-3.12%2B-blue.svg" alt="Python Version" />
32
+ </a>
33
+ <a href="https://compolis.github.io/gabm/" title="Documentation">
34
+ <img src="https://img.shields.io/badge/docs-Sphinx-green" alt="Documentation" />
35
+ </a>
36
+ </p>
37
+ > **Note for Fork Maintainers:**
38
+ > The badges and clone URLs above reference the canonical compolis/gabm repository.
39
+
40
+ > If you fork this project and want badges to reflect your fork’s status, update all `compolis/gabm` URLs to your own GitHub username/repo.
41
+
42
+ # GABM: Generative Agent-Based Model
43
+
44
+ ## Table of Contents
45
+ - [Development History & Project Journal](#development-history--project-journal)
46
+ - [Overview](#overview)
47
+ - [Roadmap](#roadmap)
48
+ - [Code of Conduct](#code-of-conduct)
49
+ - [Getting Started](#getting-started)
50
+ - [Set Up Your Environment](#2-set-up-your-environment)
51
+ - [Recommended Tools & IDEs](#recommended-tools--ides)
52
+ - [API Keys](#3-api-keys)
53
+ - [LLM Setup and Onboarding](#4-llm-setup-and-onboarding)
54
+ - [Running the Code](#5-running-the-code)
55
+ - [Usage](#usage)
56
+ - [Model Management & Caching](#model-management--caching)
57
+ - [Contribution Workflow](#contribution-workflow)
58
+ - [Makefile Reference](#makefile-reference)
59
+ - [Developer Guide](DEV_GUIDE.md)
60
+ - [User Guide](USER_GUIDE.md)
61
+ - [Documentation](#documentation)
62
+ - [License](#license)
63
+ - [Centralized Logging](#centralized-logging)
64
+ - [Files and Directories Excluded from Version Control](#files-and-directories-excluded-from-version-control)
65
+ - [Documentation Build Workflow](#documentation-build-workflow)
66
+ - [Acknowledgements](#acknowledgements)
67
+
68
+ ## Overview
69
+
70
+ GABM is a flexible, extensible Python framework for agent-based modeling (ABM) with a focus on integrating large language models (LLMs) as agent reasoning engines. It supports multiple LLM providers, persistent response caching, and robust onboarding for new users and contributors.
71
+
72
+ ## Roadmap
73
+
74
+ See [ROADMAP.md](ROADMAP.md) for planned next steps and future goals.
75
+
76
+ To create and push a release tag:
77
+
78
+ 1. Ensure all changes are committed and pushed to the main branch.
79
+ 2. Run:
80
+
81
+ ```bash
82
+ make release VERSION=x.y.z
83
+ ```
84
+
85
+ Replace `x.y.z` with the desired version number (e.g., `0.1.0`).
86
+ 3. The release will be tagged and pushed to the remote repository.
87
+
88
+
89
+ See [CHANGE_LOG.md](CHANGE_LOG.md) for details of each release, including the latest 0.1.1 documentation update.
90
+
91
+
92
+ ## Code of Conduct and Reporting
93
+
94
+ Please see our [Code of Conduct](CODE_OF_CONDUCT.md) for guidelines on expected behavior and reporting issues.
95
+
96
+ For security or conduct concerns, you can also use the “Contact maintainers” link on the GitHub repository, or see the [SECURITY.md](SECURITY.md) file in the documentation for details on confidential reporting.
97
+
98
+ ## Getting Started
99
+
100
+ ### 1. Clone the Repository
101
+ First, fork the [upstream repository](https://github.com/compolis/GABM) on GitHub to your own account. Then, clone your fork locally:
102
+ > Replace `<your-username>` with your GitHub username in the commands below.
103
+ ```bash
104
+ git clone https://github.com/<your-username>/GABM.git
105
+ ```
106
+ or
107
+ ```bash
108
+ git clone git@github.com:<your-username>/gabm.git
109
+ ```
110
+
111
+ #### Recommended: Onboard with the Latest Stable Release
112
+ For the most reliable onboarding experience, checkout the latest stable release branch (e.g., `stable/0.1.0`).
113
+ ```bash
114
+ git checkout stable/0.1.0
115
+ ```
116
+
117
+ This branch contains the most tested and stable code. For development or contributing, use the main or feature branches.
118
+
119
+
120
+ For a detailed, step-by-step walkthrough, see:
121
+ - [User Setup Guide](SETUP_GUIDE_USER.md) — for end users who want to run GABM
122
+ - [Developer Setup Guide](SETUP_GUIDE_DEV.md) — for contributors and advanced users
123
+
124
+
125
+ > **Note for Developers:**
126
+ >
127
+ > The documentation files in the `docs/` directory (such as `README.md`, `ROADMAP.md`, `CHANGE_LOG.md`, `CODE_OF_CONDUCT.md`, `SETUP_GUIDE_USER.md`, `SETUP_GUIDE_DEV.md`, `CONTRIBUTORS`, and `LICENSE`) are automatically copied from the project root as part of the documentation build process. **Do not edit these files in `docs/` directly.** Always edit the originals in the project root.
128
+
129
+ ### 2. Set Up Your Environment
130
+
131
+
132
+ Install Python 3.12 or higher and pip if you haven't already.
133
+
134
+ #### User Setup (Recommended for most users)
135
+
136
+ Install only the core runtime dependencies:
137
+
138
+ ```bash
139
+ pip install -r requirements.txt
140
+ ```
141
+
142
+ #### Developer Setup (For contributors, testing, and docs)
143
+
144
+ Install all runtime, development, and documentation dependencies:
145
+
146
+ ```bash
147
+ pip install -r requirements-dev.txt
148
+ ```
149
+
150
+ **[requirements.txt](requirements.txt)** contains only the packages needed to run GABM as a user.
151
+
152
+ **[requirements-dev.txt](requirements-dev.txt)** includes everything in requirements.txt plus extra packages for development, testing, and building documentation (e.g., pytest, Sphinx, linters).
153
+
154
+ Use the developer setup if you plan to contribute code, run tests, or build the documentation locally.
155
+
156
+ #### Recommended tools
157
+
158
+ - [Visual Studio Code](https://code.visualstudio.com/) is recommended for its excellent Python support and [GitHub Copilot](https://github.com/features/copilot) integration.
159
+ - Other good Python IDEs include [Spyder](https://www.spyder-ide.org/) (scientific workflow) and [PyCharm](https://www.jetbrains.com/pycharm/).
160
+ - [Make](https://www.gnu.org/software/make/) is used for build and clean workflow automation. All Makefile targets in this project are platform-agnostic and work on both Windows and Unix-like systems.
161
+ - You are free to use any editor, IDE, or workflow you prefer.
162
+
163
+
164
+ ### 3. API Keys
165
+ See [API_KEYS.md](API_KEYS.md) for instructions on setting up your API keys and initializing your environment.
166
+
167
+ ### 4. LLM Setup and Onboarding
168
+ To quickly initialize your environment, test your API keys, and generate model lists and caches for all supported LLMs, use the provided setup utility:
169
+
170
+ ```bash
171
+ make setup-llms
172
+ ```
173
+
174
+ This will:
175
+ - Check for all required API keys (OpenAI, GenAI, DeepSeek)
176
+ - Test each key with a default prompt and model
177
+ - Generate initial `models.json` and `models.txt` for each LLM
178
+ - Initialize response caches (`cache.pkl`)
179
+ - Report any issues or missing keys
180
+
181
+ If you need to clear all caches and model lists (for a fresh start or troubleshooting), use:
182
+ ```bash
183
+ make clear-caches
184
+ ```
185
+
186
+ **Note:** Model list files (`models.json`, `models.txt`) are lists of available models for each LLM service. This might change over time. To save generating the lists these are committed to the repository. Cache files (`cache.pkl`) are prompt/response data from each LLM service. These are currently not committed to the repository as they may become large. However, the intention is to store caches of prompts/responses and details of the Agent Based Models when run to generate results and explore reproducibility.
187
+
188
+ ### 5. Running the Code
189
+ From the project root, run:
190
+
191
+ ```bash
192
+ python3 -m gabm
193
+ ```
194
+
195
+ ## Usage
196
+
197
+ ### Running the Main Program
198
+
199
+ ```bash
200
+ python3 -m gabm
201
+ ```
202
+
203
+ ### Example: Persona Test Agent Fills Survey
204
+
205
+ ```bash
206
+ python3 src/io/persona_test_agent_fills_survey_v1.py
207
+ ```
208
+
209
+ ## Model Management & Caching
210
+
211
+ - All LLM responses are cached in `data/llm_cache/` (pickled)
212
+ - Model lists are cached in `data/model_lists/` (JSON/TXT)
213
+ - Use `make clear-caches` to clear all caches
214
+
215
+ ### Supported LLM Providers
216
+ - DeepSeek
217
+
218
+ ### Model Listing, Caching, and Validation
219
+ When a model list is fetched, it is cached locally. LLM responses are also cached for efficiency and reproducibility.
220
+
221
+ When running the main script, the selected model for each LLM is checked against the cached JSON model list. If the model is not found, a warning is shown and the available models can be listed automatically.
222
+
223
+ This workflow is consistent across all LLMs, making it easy to add new providers or update model selection logic.
224
+
225
+ #### Model Selection (Explicit Required)
226
+
227
+ When running the main script, you must explicitly set the model name for each LLM provider in `src/gabm/__main__.py`. There are no defaults—this ensures clarity and prevents accidental use of deprecated or unsupported models.
228
+
229
+ To select a model, set the variable (e.g., `openai_model`, `genai_model`, `deepseek_model`) at the top of the main function in `src/gabm/__main__.py`.
230
+
231
+ If you do not set a model, the script will raise an error and prompt you to specify one.
232
+
233
+ To see available models, run the model listing function for each provider or check the generated `models.json` file in `data/llm/{provider}/`.
234
+
235
+ Example:
236
+ ```python
237
+ openai_model = "gpt-3.5-turbo"
238
+ genai_model = "gemini-pro"
239
+ deepseek_model = "deepseek-model-1"
240
+ ```
241
+
242
+ See the API documentation and module docstrings for more details on how model management is implemented and used in the codebase.
243
+
244
+ ## Contribution Workflow
245
+
246
+ **Note:** The `main` branch is protected. All changes must be made through Pull Requests, which require at least one review and approval before merging. Direct pushes to `main` are not allowed. This ensures code quality and collaborative review.
247
+
248
+ ### How to Contribute
249
+
250
+ 1. Add your name to the `__author__` list in any Python file you edit.
251
+ 2. Increment the `__version__` string in the file if you make a significant change.
252
+ 3. Submit a pull request with a clear description of your changes.
253
+
254
+ ### Example Metadata Block
255
+
256
+ ```python
257
+ __author__ = ["Alice Smith", "Bob Jones"]
258
+ __version__ = "0.2.1"
259
+ __copyright__ = "2024-present Alice Smith, Bob Jones"
260
+ ```
261
+
262
+ ### Contributor Best Practices
263
+
264
+ - Keep `__author__` as a list (not a string)
265
+ - Update `__version__` for meaningful changes
266
+ - Add yourself to the list in every file you touch
267
+
268
+ ### Contributor Checklist (for PRs)
269
+ - [ ] Increment the `__version__` string for significant changes
270
+ - [ ] Update the CHANGE_LOG.md with a summary of your changes
271
+ - [ ] Ensure all tests pass and documentation builds
272
+ - **Major**: Increment for incompatible API changes or major new features.
273
+ - **Minor**: Increment for backward-compatible feature additions or improvements.
274
+ - **Fix**: Increment for backward-compatible bug fixes or minor changes.
275
+
276
+ Example: `0.2.1` → `0.2.2` (fix), `0.3.0` (minor), `1.0.0` (major).
277
+
278
+ If you contribute code to this project, please:
279
+
280
+ - Add your name and email to the end of the `__author__` list in any Python file you edit.
281
+ - Increment the `__version__` string if you make a significant change.
282
+ - Optionally, add a short comment in the file or in your pull request describing your contribution.
283
+
284
+ Example:
285
+ ```python
286
+ __author__ = [
287
+ "Andy Turner <agdturner@gmail.com>",
288
+ "Your Name <your.email@example.com>"
289
+ ]
290
+ ```
291
+
292
+ This helps ensure proper attribution and makes it easy to track contributors. For large or multi-author changes, consider also updating this README or adding a CONTRIBUTORS file.
293
+
294
+ ## Makefile Reference
295
+
296
+
297
+ ### Common Targets
298
+
299
+
300
+ - `make git-clean` — Clean up merged local branches and prune deleted remotes. This target automatically checks out the `main` branch before deleting merged branches to avoid errors if the active branch is merged and needs deletion.
301
+
302
+ ### Python Scripts Used by Makefile Targets
303
+
304
+ | Script | Used by Target | Purpose |
305
+ |-------------------------------|-------------------|--------------------------------------------------------------|
306
+ | scripts/docs.py | docs | Copies and normalizes Markdown docs for Sphinx |
307
+ | scripts/docs-clean.py | docs-clean | Removes auto-copied docs assets from docs/ |
308
+ | scripts/clean.py | clean | Removes build/test artifacts and Python caches |
309
+ | scripts/clear-caches.py | clear-caches | Deletes all LLM/model caches and model lists |
310
+ | scripts/gh-pages.py | gh-pages | Builds and deploys Sphinx docs to the gh-pages branch |
311
+
312
+ - All scripts are in the `scripts/` directory at the project root.
313
+ - These scripts ensure all Makefile targets are platform-agnostic and reproducible.
314
+
315
+
316
+ ## Documentation
317
+
318
+ Project documentation is available in the `docs/` directory and online via GitHub Pages.
319
+
320
+ - See [`DEV_GUIDE.md`](DEV_GUIDE.md) for developer workflow, collaboration, Makefile targets, and project structure.
321
+ - See [`USER_GUIDE.md`](USER_GUIDE.md) for user guidance, support, and future configuration instructions.
322
+ - See `SETUP_GUIDE_DEV.md` and `SETUP_GUIDE_USER.md` for environment setup instructions.
323
+
324
+ Docs are generated with Sphinx and output to `docs/_build/html/`.
325
+
326
+ > **To view the documentation:** Open `docs/_build/html/index.html` in your web browser after running `make docs`.
327
+
328
+ ### Adding New Modules to the Documentation
329
+
330
+ To add a new module to the docs:
331
+ 1. Create a new .rst file in the appropriate directory under `docs/`.
332
+ 2. Add the `automodule` directive for your module.
333
+ 3. Reference the new .rst file in the `toctree` in `index.rst`.
334
+ 4. Run `make docs` to rebuild the documentation.
335
+
336
+ This structure keeps documentation organized and easy to extend as the codebase grows.
337
+
338
+ ---
339
+ **Note on Sphinx/MyST Documentation Warnings:**
340
+
341
+ When building the documentation with Sphinx and MyST, you may see warnings like:
342
+
343
+ Document headings start at H2, not H1 [myst.header]
344
+
345
+ These warnings occur even though all Markdown files start with H2 (`##`). This is a known quirk with MyST/Sphinx and does not affect the rendered documentation. You can safely ignore these warnings unless the formatting in the HTML output is incorrect.
346
+ ---
347
+
348
+ ## LLM Model Listing, Caching, and Validation
349
+
350
+ This project supports multiple LLM providers (OpenAI, GenAI, DeepSeek, Anthropic) with a unified workflow for model management:
351
+
352
+ - **Model Listing:** Each LLM module provides a function to fetch and list available models from the provider's API. The full model list is saved as both JSON (machine-readable) and TXT (human-readable) in the corresponding `data/llm/{provider}/` directory.
353
+ - **Caching:** When a model list is fetched, it is cached locally. LLM responses are also cached for efficiency and reproducibility.
354
+ - **Validation:** When running the main script, the selected model for each LLM is checked against the cached JSON model list. If the model is not found, a warning is shown and the available models can be listed automatically.
355
+ - **Extensibility:** This workflow is consistent across all LLMs, making it easy to add new providers or update model selection logic.
356
+
357
+ ### LLM Model Selection (Explicit Required)
358
+
359
+ When running the main script, you must explicitly set the model name for each LLM provider in `src/gabm/__main__.py`. There are no defaults—this ensures clarity and prevents accidental use of deprecated or unsupported models.
360
+
361
+ - To select a model, set the variable (e.g., `openai_model`, `genai_model`, `deepseek_model`) at the top of the main function in `src/gabm/__main__.py`.
362
+ - If you do not set a model, the script will raise an error and prompt you to specify one.
363
+ - To see available models, run the model listing function for each provider or check the generated `models.json` file in `data/llm/{provider}/`.
364
+
365
+ Example:
366
+ ```python
367
+ openai_model = "gpt-3.5-turbo"
368
+ genai_model = "gemini-pro"
369
+ deepseek_model = "deepseek-model-1"
370
+ ```
371
+
372
+ See the API documentation and module docstrings for more details on how model management is implemented and used in the codebase.
373
+
374
+ ## Centralized Logging
375
+
376
+ All major modules and utilities in GABM use a centralized logging system. In addition to any console output, each LLM module and utility writes detailed logs automatically to the `data/logs/` directory. These logs include setup steps, API calls, warnings, and errors, making troubleshooting and reproducibility easier. See the [Developer Setup Guide](SETUP_GUIDE_DEV.md) for details on how to view and use these logs.
377
+
378
+ ## Files and Directories Excluded from Version Control
379
+
380
+ Certain files and directories are intentionally excluded from the repository via `.gitignore` to keep the project clean and secure:
381
+
382
+ - `data/logs/` — All log files generated by scripts and modules (can be large and environment-specific)
383
+ - `data/llm/*/cache.pkl` — LLM response cache files (can be large and are not needed for collaboration)
384
+ - `data/api_key.csv` — API keys (never commit secrets)
385
+
386
+ If you do not see these files or folders in the repository, this is expected. Each collaborator should generate their own as needed by following the setup guide.
387
+
388
+ - If you want to link to Markdown files (like ROADMAP.md, CHANGE_LOG.md, CODE_OF_CONDUCT.md, SETUP_GUIDE_USER.md, SETUP_GUIDE_DEV.md, CONTRIBUTORS, LICENSE) in the Sphinx docs, ensure they are present in the docs/ directory or use plain Markdown links (e.g., `[ROADMAP.md](../ROADMAP.md)`) instead of MyST cross-references. Otherwise, Sphinx will warn about missing references.
389
+ - If you want to include a file in the Sphinx navigation, add it to a toctree in index.rst. If not, remove or comment out the reference.
390
+
391
+ ## Documentation Build Workflow
392
+
393
+ - The Makefile `docs` target automatically runs `scripts/docs.py` to copy key documentation files (README.md, ROADMAP.md, etc.) from the project root to the `docs/` directory and update their internal links for Sphinx.
394
+ - **Edit only the originals in the project root.** Do not edit the auto-copied files in `docs/`—they will be overwritten.
395
+ - `.rst` files in `docs/` are meant to be created, edited, and maintained by developers for Sphinx documentation.
396
+ - This workflow ensures that all documentation is up to date, cross-referenced, and easy to navigate in both the repository and the generated HTML docs.
397
+
398
+ > **Platform Agnostic:** All core developer workflows (build, clean, cache management, docs, deployment) are fully platform-agnostic and work on both Windows and Unix-like systems. You can develop and contribute using your preferred OS.
399
+
400
+
401
+ ## License
402
+
403
+ See [LICENSE](LICENSE).
404
+
405
+
406
+ ## Development History & Project Journal
407
+
408
+ We are documenting the collaborative development of this project, including key milestones, decisions, and lessons learned. See:
409
+ - [DEVELOPMENT_HISTORY.md](DEVELOPMENT_HISTORY.md) for a full narrative and session summaries
410
+ - [data/logs/dev_sessions/](data/logs/dev_sessions/) for detailed session logs (may use GitHub LFS for large files)
411
+ - [Sphinx documentation: Development History](docs/development_history.md) for a published summary
412
+
413
+ This record is being maintained as part of our open science and transparency practices, and will be referenced in our planned [Journal of Open Source Software (JOSS)](https://joss.theoj.org/) submission.
414
+
415
+
416
+ ## Acknowledgements
417
+
418
+ This project was developed with significant assistance from [GitHub Copilot](https://github.com/features/copilot) for code generation, refactoring, and documentation improvements.
419
+
420
+ We gratefully acknowledge support from the [University of Leeds](https://www.leeds.ac.uk/). Funding for this project comes from a UKRI Future Leaders Fellowship awarded to [Professor Viktoria Spaiser](https://essl.leeds.ac.uk/politics/staff/102/professor-viktoria-spaiser) (grant reference: [UKRI2043](https://gtr.ukri.org/projects?ref=UKRI2043)).