thoughtflow 0.0.1__tar.gz → 0.0.2__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.
- thoughtflow-0.0.2/.gitignore +162 -0
- thoughtflow-0.0.2/CHANGELOG.md +53 -0
- {thoughtflow-0.0.1 → thoughtflow-0.0.2}/LICENSE +1 -1
- thoughtflow-0.0.2/PKG-INFO +215 -0
- thoughtflow-0.0.2/README.md +132 -0
- thoughtflow-0.0.2/pyproject.toml +144 -0
- thoughtflow-0.0.2/src/thoughtflow/__init__.py +56 -0
- thoughtflow-0.0.2/src/thoughtflow/_util.py +108 -0
- thoughtflow-0.0.2/src/thoughtflow/adapters/__init__.py +43 -0
- thoughtflow-0.0.2/src/thoughtflow/adapters/anthropic.py +119 -0
- thoughtflow-0.0.2/src/thoughtflow/adapters/base.py +140 -0
- thoughtflow-0.0.2/src/thoughtflow/adapters/local.py +133 -0
- thoughtflow-0.0.2/src/thoughtflow/adapters/openai.py +118 -0
- thoughtflow-0.0.2/src/thoughtflow/agent.py +147 -0
- thoughtflow-0.0.2/src/thoughtflow/eval/__init__.py +34 -0
- thoughtflow-0.0.2/src/thoughtflow/eval/harness.py +200 -0
- thoughtflow-0.0.2/src/thoughtflow/eval/replay.py +137 -0
- thoughtflow-0.0.2/src/thoughtflow/memory/__init__.py +27 -0
- thoughtflow-0.0.2/src/thoughtflow/memory/base.py +142 -0
- thoughtflow-0.0.2/src/thoughtflow/message.py +140 -0
- thoughtflow-0.0.2/src/thoughtflow/py.typed +2 -0
- thoughtflow-0.0.2/src/thoughtflow/tools/__init__.py +27 -0
- thoughtflow-0.0.2/src/thoughtflow/tools/base.py +145 -0
- thoughtflow-0.0.2/src/thoughtflow/tools/registry.py +122 -0
- thoughtflow-0.0.2/src/thoughtflow/trace/__init__.py +34 -0
- thoughtflow-0.0.2/src/thoughtflow/trace/events.py +183 -0
- thoughtflow-0.0.2/src/thoughtflow/trace/schema.py +111 -0
- thoughtflow-0.0.2/src/thoughtflow/trace/session.py +141 -0
- thoughtflow-0.0.2/tests/__init__.py +7 -0
- thoughtflow-0.0.2/tests/conftest.py +165 -0
- thoughtflow-0.0.2/tests/integration/__init__.py +12 -0
- thoughtflow-0.0.2/tests/integration/test_anthropic_adapter.py +73 -0
- thoughtflow-0.0.2/tests/integration/test_openai_adapter.py +71 -0
- thoughtflow-0.0.2/tests/unit/__init__.py +9 -0
- thoughtflow-0.0.2/tests/unit/test_agent.py +84 -0
- thoughtflow-0.0.2/tests/unit/test_message.py +122 -0
- thoughtflow-0.0.2/tests/unit/test_trace.py +175 -0
- thoughtflow-0.0.1/PKG-INFO +0 -17
- thoughtflow-0.0.1/README.md +0 -60
- thoughtflow-0.0.1/setup.cfg +0 -4
- thoughtflow-0.0.1/setup.py +0 -40
- thoughtflow-0.0.1/thoughtflow/__init__.py +0 -7
- thoughtflow-0.0.1/thoughtflow/jtools1.py +0 -25
- thoughtflow-0.0.1/thoughtflow/jtools2.py +0 -27
- thoughtflow-0.0.1/thoughtflow.egg-info/PKG-INFO +0 -17
- thoughtflow-0.0.1/thoughtflow.egg-info/SOURCES.txt +0 -11
- thoughtflow-0.0.1/thoughtflow.egg-info/dependency_links.txt +0 -1
- thoughtflow-0.0.1/thoughtflow.egg-info/requires.txt +0 -2
- thoughtflow-0.0.1/thoughtflow.egg-info/top_level.txt +0 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
110
|
+
.pdm.toml
|
|
111
|
+
.pdm-python
|
|
112
|
+
.pdm-build/
|
|
113
|
+
|
|
114
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
115
|
+
__pypackages__/
|
|
116
|
+
|
|
117
|
+
# Celery stuff
|
|
118
|
+
celerybeat-schedule
|
|
119
|
+
celerybeat.pid
|
|
120
|
+
|
|
121
|
+
# SageMath parsed files
|
|
122
|
+
*.sage.py
|
|
123
|
+
|
|
124
|
+
# Environments
|
|
125
|
+
.env
|
|
126
|
+
.venv
|
|
127
|
+
env/
|
|
128
|
+
venv/
|
|
129
|
+
ENV/
|
|
130
|
+
env.bak/
|
|
131
|
+
venv.bak/
|
|
132
|
+
|
|
133
|
+
# Spyder project settings
|
|
134
|
+
.spyderproject
|
|
135
|
+
.spyproject
|
|
136
|
+
|
|
137
|
+
# Rope project settings
|
|
138
|
+
.ropeproject
|
|
139
|
+
|
|
140
|
+
# mkdocs documentation
|
|
141
|
+
/site
|
|
142
|
+
|
|
143
|
+
# mypy
|
|
144
|
+
.mypy_cache/
|
|
145
|
+
.dmypy.json
|
|
146
|
+
dmypy.json
|
|
147
|
+
|
|
148
|
+
# Pyre type checker
|
|
149
|
+
.pyre/
|
|
150
|
+
|
|
151
|
+
# pytype static type analyzer
|
|
152
|
+
.pytype/
|
|
153
|
+
|
|
154
|
+
# Cython debug symbols
|
|
155
|
+
cython_debug/
|
|
156
|
+
|
|
157
|
+
# PyCharm
|
|
158
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
159
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
160
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
161
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
162
|
+
#.idea/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to ThoughtFlow will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial project structure
|
|
12
|
+
- Core `Agent` contract
|
|
13
|
+
- `Message` schema
|
|
14
|
+
- Provider adapter interfaces (`OpenAI`, `Anthropic`, `Local`)
|
|
15
|
+
- `Tool` contract and registry
|
|
16
|
+
- `Memory` hooks interface
|
|
17
|
+
- `Session` and `Trace` objects for explicit state capture
|
|
18
|
+
- `Replay` and `Harness` for deterministic evaluation
|
|
19
|
+
- GitHub Actions CI/CD workflows
|
|
20
|
+
- Comprehensive documentation structure
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Nothing yet
|
|
24
|
+
|
|
25
|
+
### Deprecated
|
|
26
|
+
- Nothing yet
|
|
27
|
+
|
|
28
|
+
### Removed
|
|
29
|
+
- Nothing yet
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
- Nothing yet
|
|
33
|
+
|
|
34
|
+
### Security
|
|
35
|
+
- Nothing yet
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## [0.1.0] - Unreleased
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
- First alpha release
|
|
43
|
+
- Core primitives: Agent, Message, Adapter
|
|
44
|
+
- OpenAI adapter implementation
|
|
45
|
+
- Basic tracing infrastructure
|
|
46
|
+
- Unit test suite
|
|
47
|
+
- Documentation site
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
<!-- Release links -->
|
|
52
|
+
[Unreleased]: https://github.com/jrolf/thoughtflow/compare/v0.1.0...HEAD
|
|
53
|
+
[0.1.0]: https://github.com/jrolf/thoughtflow/releases/tag/v0.1.0
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: thoughtflow
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A minimal, explicit, Pythonic substrate for building reproducible, portable, testable LLM and agent systems.
|
|
5
|
+
Project-URL: Homepage, https://github.com/jrolf/thoughtflow
|
|
6
|
+
Project-URL: Documentation, https://thoughtflow.dev
|
|
7
|
+
Project-URL: Repository, https://github.com/jrolf/thoughtflow
|
|
8
|
+
Project-URL: Issues, https://github.com/jrolf/thoughtflow/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/jrolf/thoughtflow/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: "James A. Rolfsen" <james@think.dev>
|
|
11
|
+
Maintainer-email: "James A. Rolfsen" <james@think.dev>
|
|
12
|
+
License: MIT License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2025 James A. Rolfsen
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Keywords: agents,ai,anthropic,langchain-alternative,llm,machine-learning,openai,orchestration
|
|
35
|
+
Classifier: Development Status :: 3 - Alpha
|
|
36
|
+
Classifier: Intended Audience :: Developers
|
|
37
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
38
|
+
Classifier: Operating System :: OS Independent
|
|
39
|
+
Classifier: Programming Language :: Python :: 3
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
45
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
46
|
+
Classifier: Typing :: Typed
|
|
47
|
+
Requires-Python: >=3.9
|
|
48
|
+
Provides-Extra: all
|
|
49
|
+
Requires-Dist: anthropic>=0.18; extra == 'all'
|
|
50
|
+
Requires-Dist: mkdocs-material>=9.0; extra == 'all'
|
|
51
|
+
Requires-Dist: mkdocs>=1.5; extra == 'all'
|
|
52
|
+
Requires-Dist: mkdocstrings[python]>=0.24; extra == 'all'
|
|
53
|
+
Requires-Dist: mypy>=1.0; extra == 'all'
|
|
54
|
+
Requires-Dist: ollama>=0.1; extra == 'all'
|
|
55
|
+
Requires-Dist: openai>=1.0; extra == 'all'
|
|
56
|
+
Requires-Dist: pre-commit>=3.0; extra == 'all'
|
|
57
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'all'
|
|
58
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'all'
|
|
59
|
+
Requires-Dist: pytest>=7.0; extra == 'all'
|
|
60
|
+
Requires-Dist: ruff>=0.1; extra == 'all'
|
|
61
|
+
Provides-Extra: all-providers
|
|
62
|
+
Requires-Dist: anthropic>=0.18; extra == 'all-providers'
|
|
63
|
+
Requires-Dist: ollama>=0.1; extra == 'all-providers'
|
|
64
|
+
Requires-Dist: openai>=1.0; extra == 'all-providers'
|
|
65
|
+
Provides-Extra: anthropic
|
|
66
|
+
Requires-Dist: anthropic>=0.18; extra == 'anthropic'
|
|
67
|
+
Provides-Extra: dev
|
|
68
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
69
|
+
Requires-Dist: pre-commit>=3.0; extra == 'dev'
|
|
70
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
71
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
72
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
73
|
+
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
74
|
+
Provides-Extra: docs
|
|
75
|
+
Requires-Dist: mkdocs-material>=9.0; extra == 'docs'
|
|
76
|
+
Requires-Dist: mkdocs>=1.5; extra == 'docs'
|
|
77
|
+
Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
|
|
78
|
+
Provides-Extra: local
|
|
79
|
+
Requires-Dist: ollama>=0.1; extra == 'local'
|
|
80
|
+
Provides-Extra: openai
|
|
81
|
+
Requires-Dist: openai>=1.0; extra == 'openai'
|
|
82
|
+
Description-Content-Type: text/markdown
|
|
83
|
+
|
|
84
|
+
# ThoughtFlow
|
|
85
|
+
|
|
86
|
+
[](https://badge.fury.io/py/thoughtflow)
|
|
87
|
+
[](https://www.python.org/downloads/)
|
|
88
|
+
[](https://opensource.org/licenses/MIT)
|
|
89
|
+
[](https://github.com/jrolf/thoughtflow/actions/workflows/ci.yml)
|
|
90
|
+
|
|
91
|
+
**A minimal, explicit, Pythonic substrate for building reproducible, portable, testable LLM and agent systems.**
|
|
92
|
+
|
|
93
|
+
> *Tiny surface area. Explicit state. Portable execution. Deterministic testing.*
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Why ThoughtFlow?
|
|
98
|
+
|
|
99
|
+
The modern LLM/agent ecosystem often evolves into abstraction swamps—hidden state, magical callbacks, and frameworks that are hard to understand, test, and deploy.
|
|
100
|
+
|
|
101
|
+
**ThoughtFlow takes a different path:**
|
|
102
|
+
|
|
103
|
+
- ✅ **No hidden agent runtime** you can't reason about
|
|
104
|
+
- ✅ **No graph DSL** you must adopt to do anything serious
|
|
105
|
+
- ✅ **No implicit global memory** or callback chains
|
|
106
|
+
- ✅ **No abstraction layers** whose main job is wrapping other abstractions
|
|
107
|
+
|
|
108
|
+
Instead, ThoughtFlow makes orchestration logic **plain Python**: explicit inputs, explicit outputs, explicit state transitions, replayable sessions, deterministic evaluation paths.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Installation
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Core library (zero dependencies)
|
|
116
|
+
pip install thoughtflow
|
|
117
|
+
|
|
118
|
+
# With OpenAI support
|
|
119
|
+
pip install thoughtflow[openai]
|
|
120
|
+
|
|
121
|
+
# With Anthropic support
|
|
122
|
+
pip install thoughtflow[anthropic]
|
|
123
|
+
|
|
124
|
+
# With all providers
|
|
125
|
+
pip install thoughtflow[all-providers]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Quick Start
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from thoughtflow import Agent
|
|
134
|
+
from thoughtflow.adapters import OpenAIAdapter
|
|
135
|
+
|
|
136
|
+
# Create an adapter for your provider
|
|
137
|
+
adapter = OpenAIAdapter(api_key="your-api-key")
|
|
138
|
+
|
|
139
|
+
# Create an agent
|
|
140
|
+
agent = Agent(adapter)
|
|
141
|
+
|
|
142
|
+
# Call with a message list (the universal currency)
|
|
143
|
+
response = agent.call([
|
|
144
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
145
|
+
{"role": "user", "content": "What is ThoughtFlow?"}
|
|
146
|
+
])
|
|
147
|
+
|
|
148
|
+
print(response)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Core Concepts
|
|
154
|
+
|
|
155
|
+
### The Agent Contract
|
|
156
|
+
|
|
157
|
+
An Agent is something that can be called with messages and parameters:
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
class Agent:
|
|
161
|
+
def call(self, msg_list, params=None):
|
|
162
|
+
raise NotImplementedError
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
That's it. Everything else is composition.
|
|
166
|
+
|
|
167
|
+
### Messages: Stable Schema, Minimal Assumptions
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
msg_list = [
|
|
171
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
172
|
+
{"role": "user", "content": "Draft 3 names for a company."},
|
|
173
|
+
]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Explicit Tracing
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from thoughtflow.trace import Session
|
|
180
|
+
|
|
181
|
+
session = Session()
|
|
182
|
+
response = agent.call(msg_list, session=session)
|
|
183
|
+
|
|
184
|
+
# Session captures everything: inputs, outputs, timing, tokens, costs
|
|
185
|
+
print(session.to_dict())
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Design Principles
|
|
191
|
+
|
|
192
|
+
1. **Tiny Surface Area**: Few powerful primitives over many specialized classes
|
|
193
|
+
2. **Explicit State**: All state is visible, serializable, and replayable
|
|
194
|
+
3. **Portability**: Works across OpenAI, Anthropic, local models, serverless
|
|
195
|
+
4. **Deterministic Testing**: Record/replay workflows, stable sessions, predictable behavior
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Project Status
|
|
200
|
+
|
|
201
|
+
🚧 **Alpha** - ThoughtFlow is under active development. The API may change.
|
|
202
|
+
|
|
203
|
+
See the [CHANGELOG](CHANGELOG.md) for version history.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
[MIT](LICENSE) © James A. Rolfsen
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# ThoughtFlow
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/thoughtflow)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/jrolf/thoughtflow/actions/workflows/ci.yml)
|
|
7
|
+
|
|
8
|
+
**A minimal, explicit, Pythonic substrate for building reproducible, portable, testable LLM and agent systems.**
|
|
9
|
+
|
|
10
|
+
> *Tiny surface area. Explicit state. Portable execution. Deterministic testing.*
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why ThoughtFlow?
|
|
15
|
+
|
|
16
|
+
The modern LLM/agent ecosystem often evolves into abstraction swamps—hidden state, magical callbacks, and frameworks that are hard to understand, test, and deploy.
|
|
17
|
+
|
|
18
|
+
**ThoughtFlow takes a different path:**
|
|
19
|
+
|
|
20
|
+
- ✅ **No hidden agent runtime** you can't reason about
|
|
21
|
+
- ✅ **No graph DSL** you must adopt to do anything serious
|
|
22
|
+
- ✅ **No implicit global memory** or callback chains
|
|
23
|
+
- ✅ **No abstraction layers** whose main job is wrapping other abstractions
|
|
24
|
+
|
|
25
|
+
Instead, ThoughtFlow makes orchestration logic **plain Python**: explicit inputs, explicit outputs, explicit state transitions, replayable sessions, deterministic evaluation paths.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Core library (zero dependencies)
|
|
33
|
+
pip install thoughtflow
|
|
34
|
+
|
|
35
|
+
# With OpenAI support
|
|
36
|
+
pip install thoughtflow[openai]
|
|
37
|
+
|
|
38
|
+
# With Anthropic support
|
|
39
|
+
pip install thoughtflow[anthropic]
|
|
40
|
+
|
|
41
|
+
# With all providers
|
|
42
|
+
pip install thoughtflow[all-providers]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from thoughtflow import Agent
|
|
51
|
+
from thoughtflow.adapters import OpenAIAdapter
|
|
52
|
+
|
|
53
|
+
# Create an adapter for your provider
|
|
54
|
+
adapter = OpenAIAdapter(api_key="your-api-key")
|
|
55
|
+
|
|
56
|
+
# Create an agent
|
|
57
|
+
agent = Agent(adapter)
|
|
58
|
+
|
|
59
|
+
# Call with a message list (the universal currency)
|
|
60
|
+
response = agent.call([
|
|
61
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
62
|
+
{"role": "user", "content": "What is ThoughtFlow?"}
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
print(response)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Core Concepts
|
|
71
|
+
|
|
72
|
+
### The Agent Contract
|
|
73
|
+
|
|
74
|
+
An Agent is something that can be called with messages and parameters:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
class Agent:
|
|
78
|
+
def call(self, msg_list, params=None):
|
|
79
|
+
raise NotImplementedError
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
That's it. Everything else is composition.
|
|
83
|
+
|
|
84
|
+
### Messages: Stable Schema, Minimal Assumptions
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
msg_list = [
|
|
88
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
89
|
+
{"role": "user", "content": "Draft 3 names for a company."},
|
|
90
|
+
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Explicit Tracing
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from thoughtflow.trace import Session
|
|
97
|
+
|
|
98
|
+
session = Session()
|
|
99
|
+
response = agent.call(msg_list, session=session)
|
|
100
|
+
|
|
101
|
+
# Session captures everything: inputs, outputs, timing, tokens, costs
|
|
102
|
+
print(session.to_dict())
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Design Principles
|
|
108
|
+
|
|
109
|
+
1. **Tiny Surface Area**: Few powerful primitives over many specialized classes
|
|
110
|
+
2. **Explicit State**: All state is visible, serializable, and replayable
|
|
111
|
+
3. **Portability**: Works across OpenAI, Anthropic, local models, serverless
|
|
112
|
+
4. **Deterministic Testing**: Record/replay workflows, stable sessions, predictable behavior
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Project Status
|
|
117
|
+
|
|
118
|
+
🚧 **Alpha** - ThoughtFlow is under active development. The API may change.
|
|
119
|
+
|
|
120
|
+
See the [CHANGELOG](CHANGELOG.md) for version history.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Contributing
|
|
125
|
+
|
|
126
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
[MIT](LICENSE) © James A. Rolfsen
|