bitfab-py 0.10.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.
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: bitfab-py
3
+ Version: 0.10.0
4
+ Summary: Bitfab client for provider-based API calls with local BAML execution
5
+ Author: Harvest Team
6
+ Requires-Python: >=3.9
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Provides-Extra: baml
15
+ Provides-Extra: openai-tracing
16
+ Requires-Dist: baml-py (>=0.220.0,<0.221.0) ; extra == "baml"
17
+ Requires-Dist: jsonpickle (>=4.0.0,<5.0.0)
18
+ Requires-Dist: openai-agents (>=0.6.3) ; extra == "openai-tracing"
19
+ Requires-Dist: pydantic (>=2.0.0,<3.0.0)
20
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
21
+ Requires-Dist: tomli (>=2.0.1,<3.0.0) ; python_version < "3.11"
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Bitfab
25
+
26
+ Bitfab client for provider-based API calls.
27
+
28
+ ## Monorepo Structure
29
+
30
+ This package is part of the Harvest monorepo. While the TypeScript/JavaScript packages use a **pnpm workspace** for shared dependencies, this Python package uses Poetry for its dependency management.
31
+
32
+ **Note:** The pnpm workspace includes:
33
+
34
+ - `bitfab-web` - Next.js web application
35
+ - `bitfab-typescript-sdk` - TypeScript SDK
36
+ - `bitfab-vscode` - VS Code extension
37
+ - `frontend` - Legacy frontend
38
+
39
+ From the root directory, you can run TypeScript tests and validation across all packages with `pnpm test` or `pnpm validate`.
40
+
41
+ ## Installation
42
+
43
+ ### Basic Installation
44
+
45
+ ```bash
46
+ pip install bitfab-py
47
+ ```
48
+
49
+ ### With OpenAI Tracing Support
50
+
51
+ If you want to use the OpenAI Agents SDK tracing integration:
52
+
53
+ ```bash
54
+ pip install bitfab-py[openai-tracing]
55
+ ```
56
+
57
+ ### Local Development
58
+
59
+ For local development:
60
+
61
+ ```bash
62
+ cd bitfab-python-sdk
63
+ poetry install --with dev
64
+ ```
65
+
66
+ After installation, you can use developer tasks. For the best experience, add Poetry's venv to your PATH:
67
+
68
+ ```bash
69
+ # Add to your ~/.zshrc or ~/.bashrc
70
+ export PATH="$(poetry env info --path)/bin:$PATH"
71
+
72
+ # Then you can use 'dev' directly (no ./run or poetry run needed!)
73
+ dev list
74
+ dev test
75
+ ```
76
+
77
+ See [Development Tasks](#development-tasks) below for all available commands.
78
+
79
+ Or install as an editable package from the parent directory:
80
+
81
+ ```bash
82
+ poetry add --editable ../bitfab-python-sdk
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ ### Basic Usage
88
+
89
+ ```python
90
+ from bitfab import Bitfab
91
+
92
+ client = Bitfab(
93
+ api_key="sf_your_api_key_here",
94
+ service_url="https://bitfab.ai", # Optional, defaults to production
95
+ env_vars={"OPENAI_API_KEY": "sk-your-openai-key"}, # Optional, for local BAML execution
96
+ )
97
+
98
+ result = client.call("method_name", arg1="value1", arg2="value2")
99
+ ```
100
+
101
+ ### OpenAI Agents SDK Tracing
102
+
103
+ If you have the `openai-agents` package installed (via `pip install bitfab-py[openai-tracing]`), you can use the tracing processor:
104
+
105
+ ```python
106
+ from bitfab import Bitfab
107
+ from agents import set_trace_processors
108
+
109
+ bitfab = Bitfab(api_key="sf_your_api_key_here")
110
+ processor = bitfab.get_openai_tracing_processor()
111
+
112
+ # Register the processor with OpenAI Agents SDK
113
+ set_trace_processors([processor])
114
+
115
+ # Now all your agent traces will be sent to Bitfab
116
+ ```
117
+
118
+ **Note:** If you try to use `get_openai_tracing_processor()` without installing the `openai-tracing` extra, you'll get a helpful error message telling you to install it.
119
+
120
+ ## Configuration
121
+
122
+ - `api_key`: **Required** - Your Bitfab API key (generate from your Bitfab dashboard)
123
+ - `service_url`: Optional - The Bitfab service URL (defaults to `https://bitfab.ai`)
124
+ - `env_vars`: Optional - Environment variables for LLM providers (e.g., `{"OPENAI_API_KEY": "..."}`)
125
+ - `enabled`: Optional - Enable/disable tracing (defaults to `True`). When `False`, decorated functions still execute but no spans are sent.
126
+
127
+ ## Development Tasks
128
+
129
+ This project uses a Python-based developer tasks module (`dev/`) instead of Makefiles for better cross-platform support and more robust CLI capabilities.
130
+
131
+ ### Using Developer Tasks
132
+
133
+ After running `poetry install --with dev`, you can use developer tasks:
134
+
135
+ #### Quick Setup (One-time)
136
+
137
+ ```bash
138
+ # Install dependencies (creates the 'dev' script in the venv)
139
+ poetry install --with dev
140
+
141
+ # Run this script to add to PATH for current session and get command to make it permanent
142
+ ./setup-dev-path.sh
143
+
144
+ # Copy-paste the command it outputs, then reload your shell config:
145
+ source ~/.zshrc # or ~/.bashrc
146
+ ```
147
+
148
+ The `setup-dev-path.sh` script will:
149
+
150
+ - Add the venv bin to PATH for your current session
151
+ - Detect your shell (zsh/bash) and output a command you can copy-paste to make it permanent
152
+ - Skip if already configured
153
+
154
+ #### Using Developer Commands
155
+
156
+ Once PATH is set up, use commands directly - just like `make <target>`:
157
+
158
+ ```bash
159
+ dev list # List all available commands
160
+ dev test # Run tests
161
+ dev test --verbose # Run tests with verbose output
162
+ dev lint # Lint code
163
+ dev format # Format code
164
+ dev build # Build package
165
+ dev publish patch # Publish with version bump
166
+ ```
167
+
168
+ **How it works**: When you define `[tool.poetry.scripts]` in `pyproject.toml`, Poetry creates executable scripts in the venv's `bin/` directory. Adding that `bin/` to PATH makes those scripts available as commands.
169
+
170
+ **Key advantage**: Just like Makefiles, it's super clear - `dev <command>` is as obvious as `make <target>`!
171
+
172
+ ### Module Structure
173
+
174
+ Each command is in its own file in the `dev/` module:
175
+
176
+ - `dev/test.py` - Test commands
177
+ - `dev/lint.py` - Linting
178
+ - `dev/build.py` - Building
179
+ - `dev/publish.py` - Publishing
180
+ - etc.
181
+
182
+ This makes it easy to find and modify individual commands.
183
+
184
+ ## Publishing
185
+
186
+ This package uses `bump-my-version` for version management. To publish a new version:
187
+
188
+ ```bash
189
+ # Use the dev command
190
+ dev publish patch # Bump patch (0.3.0 -> 0.3.1)
191
+ dev publish minor # Bump minor (0.3.0 -> 0.4.0)
192
+ dev publish major # Bump major (0.3.0 -> 1.0.0)
193
+ dev publish version=1.2.3 # Custom version
194
+
195
+ # Or just bump version without publishing
196
+ dev bump patch
197
+ dev bump minor
198
+ ```
199
+
200
+ The publish process will:
201
+
202
+ 1. Run all tests
203
+ 2. Bump the version in `pyproject.toml`
204
+ 3. Commit and tag the changes
205
+ 4. Build the package
206
+ 5. Prompt for confirmation before publishing to PyPI
207
+
208
+ **Note:** Publishing requires:
209
+
210
+ - A clean git working directory (no uncommitted changes)
211
+ - Poetry installed and configured
212
+ - PyPI credentials configured (via `poetry config pypi-token.pypi <token>`)
213
+
@@ -0,0 +1,189 @@
1
+ # Bitfab
2
+
3
+ Bitfab client for provider-based API calls.
4
+
5
+ ## Monorepo Structure
6
+
7
+ This package is part of the Harvest monorepo. While the TypeScript/JavaScript packages use a **pnpm workspace** for shared dependencies, this Python package uses Poetry for its dependency management.
8
+
9
+ **Note:** The pnpm workspace includes:
10
+
11
+ - `bitfab-web` - Next.js web application
12
+ - `bitfab-typescript-sdk` - TypeScript SDK
13
+ - `bitfab-vscode` - VS Code extension
14
+ - `frontend` - Legacy frontend
15
+
16
+ From the root directory, you can run TypeScript tests and validation across all packages with `pnpm test` or `pnpm validate`.
17
+
18
+ ## Installation
19
+
20
+ ### Basic Installation
21
+
22
+ ```bash
23
+ pip install bitfab-py
24
+ ```
25
+
26
+ ### With OpenAI Tracing Support
27
+
28
+ If you want to use the OpenAI Agents SDK tracing integration:
29
+
30
+ ```bash
31
+ pip install bitfab-py[openai-tracing]
32
+ ```
33
+
34
+ ### Local Development
35
+
36
+ For local development:
37
+
38
+ ```bash
39
+ cd bitfab-python-sdk
40
+ poetry install --with dev
41
+ ```
42
+
43
+ After installation, you can use developer tasks. For the best experience, add Poetry's venv to your PATH:
44
+
45
+ ```bash
46
+ # Add to your ~/.zshrc or ~/.bashrc
47
+ export PATH="$(poetry env info --path)/bin:$PATH"
48
+
49
+ # Then you can use 'dev' directly (no ./run or poetry run needed!)
50
+ dev list
51
+ dev test
52
+ ```
53
+
54
+ See [Development Tasks](#development-tasks) below for all available commands.
55
+
56
+ Or install as an editable package from the parent directory:
57
+
58
+ ```bash
59
+ poetry add --editable ../bitfab-python-sdk
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ### Basic Usage
65
+
66
+ ```python
67
+ from bitfab import Bitfab
68
+
69
+ client = Bitfab(
70
+ api_key="sf_your_api_key_here",
71
+ service_url="https://bitfab.ai", # Optional, defaults to production
72
+ env_vars={"OPENAI_API_KEY": "sk-your-openai-key"}, # Optional, for local BAML execution
73
+ )
74
+
75
+ result = client.call("method_name", arg1="value1", arg2="value2")
76
+ ```
77
+
78
+ ### OpenAI Agents SDK Tracing
79
+
80
+ If you have the `openai-agents` package installed (via `pip install bitfab-py[openai-tracing]`), you can use the tracing processor:
81
+
82
+ ```python
83
+ from bitfab import Bitfab
84
+ from agents import set_trace_processors
85
+
86
+ bitfab = Bitfab(api_key="sf_your_api_key_here")
87
+ processor = bitfab.get_openai_tracing_processor()
88
+
89
+ # Register the processor with OpenAI Agents SDK
90
+ set_trace_processors([processor])
91
+
92
+ # Now all your agent traces will be sent to Bitfab
93
+ ```
94
+
95
+ **Note:** If you try to use `get_openai_tracing_processor()` without installing the `openai-tracing` extra, you'll get a helpful error message telling you to install it.
96
+
97
+ ## Configuration
98
+
99
+ - `api_key`: **Required** - Your Bitfab API key (generate from your Bitfab dashboard)
100
+ - `service_url`: Optional - The Bitfab service URL (defaults to `https://bitfab.ai`)
101
+ - `env_vars`: Optional - Environment variables for LLM providers (e.g., `{"OPENAI_API_KEY": "..."}`)
102
+ - `enabled`: Optional - Enable/disable tracing (defaults to `True`). When `False`, decorated functions still execute but no spans are sent.
103
+
104
+ ## Development Tasks
105
+
106
+ This project uses a Python-based developer tasks module (`dev/`) instead of Makefiles for better cross-platform support and more robust CLI capabilities.
107
+
108
+ ### Using Developer Tasks
109
+
110
+ After running `poetry install --with dev`, you can use developer tasks:
111
+
112
+ #### Quick Setup (One-time)
113
+
114
+ ```bash
115
+ # Install dependencies (creates the 'dev' script in the venv)
116
+ poetry install --with dev
117
+
118
+ # Run this script to add to PATH for current session and get command to make it permanent
119
+ ./setup-dev-path.sh
120
+
121
+ # Copy-paste the command it outputs, then reload your shell config:
122
+ source ~/.zshrc # or ~/.bashrc
123
+ ```
124
+
125
+ The `setup-dev-path.sh` script will:
126
+
127
+ - Add the venv bin to PATH for your current session
128
+ - Detect your shell (zsh/bash) and output a command you can copy-paste to make it permanent
129
+ - Skip if already configured
130
+
131
+ #### Using Developer Commands
132
+
133
+ Once PATH is set up, use commands directly - just like `make <target>`:
134
+
135
+ ```bash
136
+ dev list # List all available commands
137
+ dev test # Run tests
138
+ dev test --verbose # Run tests with verbose output
139
+ dev lint # Lint code
140
+ dev format # Format code
141
+ dev build # Build package
142
+ dev publish patch # Publish with version bump
143
+ ```
144
+
145
+ **How it works**: When you define `[tool.poetry.scripts]` in `pyproject.toml`, Poetry creates executable scripts in the venv's `bin/` directory. Adding that `bin/` to PATH makes those scripts available as commands.
146
+
147
+ **Key advantage**: Just like Makefiles, it's super clear - `dev <command>` is as obvious as `make <target>`!
148
+
149
+ ### Module Structure
150
+
151
+ Each command is in its own file in the `dev/` module:
152
+
153
+ - `dev/test.py` - Test commands
154
+ - `dev/lint.py` - Linting
155
+ - `dev/build.py` - Building
156
+ - `dev/publish.py` - Publishing
157
+ - etc.
158
+
159
+ This makes it easy to find and modify individual commands.
160
+
161
+ ## Publishing
162
+
163
+ This package uses `bump-my-version` for version management. To publish a new version:
164
+
165
+ ```bash
166
+ # Use the dev command
167
+ dev publish patch # Bump patch (0.3.0 -> 0.3.1)
168
+ dev publish minor # Bump minor (0.3.0 -> 0.4.0)
169
+ dev publish major # Bump major (0.3.0 -> 1.0.0)
170
+ dev publish version=1.2.3 # Custom version
171
+
172
+ # Or just bump version without publishing
173
+ dev bump patch
174
+ dev bump minor
175
+ ```
176
+
177
+ The publish process will:
178
+
179
+ 1. Run all tests
180
+ 2. Bump the version in `pyproject.toml`
181
+ 3. Commit and tag the changes
182
+ 4. Build the package
183
+ 5. Prompt for confirmation before publishing to PyPI
184
+
185
+ **Note:** Publishing requires:
186
+
187
+ - A clean git working directory (no uncommitted changes)
188
+ - Poetry installed and configured
189
+ - PyPI credentials configured (via `poetry config pypi-token.pypi <token>`)
@@ -0,0 +1,50 @@
1
+ """Bitfab client for provider-based API calls."""
2
+
3
+ from bitfab.client import (
4
+ AllowedEnvVars,
5
+ Bitfab,
6
+ BitfabFunction,
7
+ CurrentSpan,
8
+ CurrentTrace,
9
+ SpanType,
10
+ flush_traces,
11
+ get_current_span,
12
+ get_current_trace,
13
+ )
14
+ from bitfab.replay import ReplayItem, ReplayResult
15
+
16
+ # Only export BitfabTracingProcessor if openai-agents is available
17
+ try:
18
+ from bitfab.tracing import (
19
+ BitfabOpenAITracingProcessor as BitfabTracingProcessor,
20
+ )
21
+
22
+ __all__ = [
23
+ "AllowedEnvVars",
24
+ "Bitfab",
25
+ "BitfabFunction",
26
+ "BitfabTracingProcessor",
27
+ "CurrentSpan",
28
+ "CurrentTrace",
29
+ "ReplayItem",
30
+ "ReplayResult",
31
+ "SpanType",
32
+ "flush_traces",
33
+ "get_current_span",
34
+ "get_current_trace",
35
+ ]
36
+ except ImportError:
37
+ # openai-agents not installed, skip tracing processor export
38
+ __all__ = [
39
+ "AllowedEnvVars",
40
+ "Bitfab",
41
+ "BitfabFunction",
42
+ "CurrentSpan",
43
+ "CurrentTrace",
44
+ "ReplayItem",
45
+ "ReplayResult",
46
+ "SpanType",
47
+ "flush_traces",
48
+ "get_current_span",
49
+ "get_current_trace",
50
+ ]