promptic-sdk 0.2.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.
Files changed (27) hide show
  1. promptic_sdk-0.2.0/LICENSE +21 -0
  2. promptic_sdk-0.2.0/PKG-INFO +255 -0
  3. promptic_sdk-0.2.0/README.md +231 -0
  4. promptic_sdk-0.2.0/pyproject.toml +137 -0
  5. promptic_sdk-0.2.0/src/promptic_sdk/__init__.py +97 -0
  6. promptic_sdk-0.2.0/src/promptic_sdk/cli/__init__.py +28 -0
  7. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/__init__.py +0 -0
  8. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/annotations.py +126 -0
  9. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/components.py +106 -0
  10. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/configure.py +25 -0
  11. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/datasets.py +134 -0
  12. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/deployments.py +103 -0
  13. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/evaluations.py +196 -0
  14. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/evaluators.py +106 -0
  15. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/experiments.py +228 -0
  16. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/iterations.py +121 -0
  17. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/login.py +161 -0
  18. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/observations.py +158 -0
  19. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/runs.py +128 -0
  20. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/traces.py +164 -0
  21. promptic_sdk-0.2.0/src/promptic_sdk/cli/commands/workspace.py +102 -0
  22. promptic_sdk-0.2.0/src/promptic_sdk/cli/config.py +116 -0
  23. promptic_sdk-0.2.0/src/promptic_sdk/cli/main.py +67 -0
  24. promptic_sdk-0.2.0/src/promptic_sdk/client.py +1013 -0
  25. promptic_sdk-0.2.0/src/promptic_sdk/models.py +488 -0
  26. promptic_sdk-0.2.0/src/promptic_sdk/py.typed +0 -0
  27. promptic_sdk-0.2.0/src/promptic_sdk/tracing.py +377 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Promptic GmbH
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.
@@ -0,0 +1,255 @@
1
+ Metadata-Version: 2.4
2
+ Name: promptic-sdk
3
+ Version: 0.2.0
4
+ Summary: Python SDK for the Promptic platform — tracing, API client, and CLI.
5
+ Author: Promptic GmbH
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: opentelemetry-sdk>=1.20.0
9
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20.0
10
+ Requires-Dist: httpx>=0.27.0
11
+ Requires-Dist: typer>=0.15.0
12
+ Requires-Dist: rich>=13.0.0
13
+ Requires-Dist: tomli>=2.0.0 ; python_full_version < '3.11'
14
+ Requires-Dist: promptic-sdk[openai,anthropic,langchain] ; extra == 'all'
15
+ Requires-Dist: opentelemetry-instrumentation-anthropic>=0.30b0 ; extra == 'anthropic'
16
+ Requires-Dist: opentelemetry-instrumentation-langchain>=0.30b0,!=0.53.0 ; extra == 'langchain'
17
+ Requires-Dist: opentelemetry-instrumentation-openai>=0.30b0 ; extra == 'openai'
18
+ Requires-Python: >=3.11
19
+ Provides-Extra: all
20
+ Provides-Extra: anthropic
21
+ Provides-Extra: langchain
22
+ Provides-Extra: openai
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Promptic Python SDK
26
+
27
+ Python SDK and CLI for the [Promptic](https://promptic.eu) platform — tracing, prompt optimization, and experiment management.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install promptic-sdk
33
+ ```
34
+
35
+ ### Optional LLM instrumentation
36
+
37
+ Install extras to auto-instrument specific LLM providers:
38
+
39
+ ```bash
40
+ pip install promptic-sdk[openai] # OpenAI
41
+ pip install promptic-sdk[anthropic] # Anthropic
42
+ pip install promptic-sdk[langchain] # LangChain
43
+ pip install promptic-sdk[all] # All providers
44
+ ```
45
+
46
+ ## Quick start
47
+
48
+ ### 1. Authenticate
49
+
50
+ Log in via browser (recommended for local development):
51
+
52
+ ```bash
53
+ promptic login
54
+ ```
55
+
56
+ This opens your browser for authentication, then auto-selects your workspace. Credentials are saved to `~/.promptic/config.toml`.
57
+
58
+ For CI/CD or headless environments, use an API key instead:
59
+
60
+ ```bash
61
+ promptic configure
62
+ # or set the environment variable:
63
+ export PROMPTIC_API_KEY="pk_..."
64
+ ```
65
+
66
+ ### 2. Send traces
67
+
68
+ ```python
69
+ import promptic_sdk
70
+ from openai import OpenAI
71
+
72
+ # Initialize tracing (auto-instruments installed LLM libraries)
73
+ promptic_sdk.init()
74
+
75
+ client = OpenAI()
76
+
77
+ # Tag traces with an AI Component name
78
+ with promptic_sdk.ai_component("customer-support-agent"):
79
+ response = client.chat.completions.create(
80
+ model="gpt-4.1-nano",
81
+ messages=[{"role": "user", "content": "Hello!"}],
82
+ )
83
+ ```
84
+
85
+ ### 3. Use the API client
86
+
87
+ ```python
88
+ from promptic_sdk import PrompticClient
89
+
90
+ with PrompticClient() as client:
91
+ # List traces
92
+ traces = client.list_traces(limit=10)
93
+
94
+ # Get workspace info
95
+ workspace = client.get_workspace()
96
+
97
+ # Manage experiments
98
+ experiment = client.create_experiment(
99
+ ai_component_id="comp_...",
100
+ target_model="gpt-4.1-nano",
101
+ task_type="classification",
102
+ initial_prompt="Classify the following text.",
103
+ )
104
+
105
+ # Deploy the best prompt
106
+ client.deploy(component_id="comp_...", experiment_id="exp_...")
107
+
108
+ # Fetch a deployed prompt at runtime
109
+ prompt = client.get_deployed_prompt("comp_...")
110
+ ```
111
+
112
+ ## Tracing
113
+
114
+ `promptic_sdk.init()` sets up OpenTelemetry to export spans to the Promptic platform.
115
+
116
+ | Parameter | Description | Default |
117
+ | ------------------ | --------------------------------------------------- | ---------------------------- |
118
+ | `api_key` | Promptic API key (falls back to `PROMPTIC_API_KEY`) | — |
119
+ | `endpoint` | Platform URL (falls back to `PROMPTIC_ENDPOINT`) | `https://promptic.eu` |
120
+ | `auto_instrument` | Auto-detect and instrument LLM client libraries | `True` |
121
+ | `service_name` | OpenTelemetry `service.name` resource attribute | — |
122
+
123
+ Auto-detected instrumentors: OpenAI, Anthropic, Google Generative AI, LangChain, Cohere.
124
+
125
+ ### Using other OpenTelemetry instrumentors
126
+
127
+ Since Promptic uses standard OpenTelemetry under the hood, you can add any OTel-compatible instrumentor alongside the auto-detected ones. Just call `promptic_sdk.init()` first, then instrument manually:
128
+
129
+ ```python
130
+ import promptic_sdk
131
+ from opentelemetry.instrumentation.requests import RequestsInstrumentor
132
+ from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
133
+
134
+ promptic_sdk.init()
135
+
136
+ # Add any OpenTelemetry instrumentor — spans will be exported to Promptic
137
+ RequestsInstrumentor().instrument()
138
+ SQLAlchemyInstrumentor().instrument(engine=engine)
139
+ ```
140
+
141
+ This works with any package from the [opentelemetry-python-contrib](https://github.com/open-telemetry/opentelemetry-python-contrib) ecosystem (HTTP clients, databases, web frameworks, etc.). All spans are exported to the Promptic platform as long as `init()` has been called.
142
+
143
+ ### AI Components
144
+
145
+ Use `ai_component()` to tag spans with a component name. The platform links traces to the matching AI Component in your workspace:
146
+
147
+ ```python
148
+ with promptic_sdk.ai_component("my-component"):
149
+ # All LLM calls here are tagged
150
+ ...
151
+ ```
152
+
153
+ ## API client
154
+
155
+ Both a sync (`PrompticClient`) and async (`AsyncPrompticClient`) client are available. They share the same method signatures and return types.
156
+
157
+ ```python
158
+ from promptic_sdk import PrompticClient
159
+
160
+ with PrompticClient() as client:
161
+ traces = client.list_traces(limit=10)
162
+ ```
163
+
164
+ ```python
165
+ from promptic_sdk import AsyncPrompticClient
166
+
167
+ async with AsyncPrompticClient() as client:
168
+ traces = await client.list_traces(limit=10)
169
+ ```
170
+
171
+ Both clients provide typed methods for the full Promptic REST API:
172
+
173
+ | Resource | Methods |
174
+ | -------------- | ----------------------------------------------------------------------- |
175
+ | Workspace | `get_workspace` |
176
+ | Traces | `list_traces`, `get_trace`, `get_stats` |
177
+ | Components | `list_components`, `get_component`, `create_component`, `delete_component` |
178
+ | Experiments | `list_experiments`, `get_experiment`, `create_experiment`, `update_experiment`, `delete_experiment`, `start_experiment` |
179
+ | Observations | `list_observations`, `create_observations`, `update_observation`, `delete_observation` |
180
+ | Evaluators | `list_evaluators`, `create_evaluators`, `update_evaluator`, `delete_evaluator` |
181
+ | Iterations | `list_iterations`, `get_iteration`, `get_best_iteration` |
182
+ | Deployments | `get_deployment`, `deploy`, `undeploy`, `get_deployed_prompt` |
183
+
184
+ The client reads `PROMPTIC_API_KEY` and `PROMPTIC_ENDPOINT` from the environment, or accepts them as constructor arguments.
185
+
186
+ ## CLI
187
+
188
+ The `promptic` CLI mirrors the API client and supports both human-readable tables and `--json` output.
189
+
190
+ ```
191
+ promptic [command] [subcommand] [options]
192
+ ```
193
+
194
+ ### Commands
195
+
196
+ | Command | Description |
197
+ | -------------------------------- | ------------------------------------ |
198
+ | `promptic login` | Authenticate via browser (device flow) |
199
+ | `promptic logout` | Clear saved credentials |
200
+ | `promptic configure` | Save API key and endpoint (CI/CD) |
201
+ | `promptic workspace list` | List accessible workspaces |
202
+ | `promptic workspace select <id>` | Select a workspace |
203
+ | `promptic workspace show` | Show workspace info |
204
+ | `promptic traces list` | List recent traces |
205
+ | `promptic traces get <id>` | Get a trace with spans |
206
+ | `promptic traces stats` | Show aggregated tracing stats |
207
+ | `promptic components list` | List AI components |
208
+ | `promptic components create` | Create a component |
209
+ | `promptic components get <id>` | Get component details |
210
+ | `promptic components delete <id>`| Delete a component |
211
+ | `promptic experiments list` | List experiments |
212
+ | `promptic experiments create` | Create an experiment (interactive) |
213
+ | `promptic experiments get <id>` | Get experiment details |
214
+ | `promptic experiments start <id>`| Start an experiment |
215
+ | `promptic observations list` | List observations for an experiment |
216
+ | `promptic evaluators list` | List evaluators for an experiment |
217
+ | `promptic iterations list` | List iterations for an experiment |
218
+ | `promptic deployments show` | Show deployment for a component |
219
+ | `promptic deployments deploy` | Deploy an experiment |
220
+ | `promptic deployments undeploy` | Remove a deployment |
221
+
222
+ All list commands support `--json` for machine-readable output.
223
+
224
+ ## Configuration
225
+
226
+ The SDK and CLI resolve configuration in this order:
227
+
228
+ 1. Explicit arguments (`api_key=`, `endpoint=`)
229
+ 2. Environment variables (`PROMPTIC_API_KEY`, `PROMPTIC_ENDPOINT`)
230
+ 3. Config file (`~/.promptic/config.toml`, written by `promptic login` or `promptic configure`)
231
+
232
+ | Variable | Description | Default |
233
+ | ------------------- | ---------------------------- | ------------------------- |
234
+ | `PROMPTIC_API_KEY` | API key (for tracing & CI/CD)| — |
235
+ | `PROMPTIC_ENDPOINT` | Platform URL | `https://promptic.eu` |
236
+
237
+ ## Development
238
+
239
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
240
+
241
+ ```bash
242
+ # Install dependencies
243
+ uv sync
244
+
245
+ # Run tests
246
+ uv run pytest
247
+
248
+ # Lint
249
+ uv run ruff check .
250
+ uv run ruff format .
251
+ ```
252
+
253
+ ## License
254
+
255
+ MIT — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,231 @@
1
+ # Promptic Python SDK
2
+
3
+ Python SDK and CLI for the [Promptic](https://promptic.eu) platform — tracing, prompt optimization, and experiment management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install promptic-sdk
9
+ ```
10
+
11
+ ### Optional LLM instrumentation
12
+
13
+ Install extras to auto-instrument specific LLM providers:
14
+
15
+ ```bash
16
+ pip install promptic-sdk[openai] # OpenAI
17
+ pip install promptic-sdk[anthropic] # Anthropic
18
+ pip install promptic-sdk[langchain] # LangChain
19
+ pip install promptic-sdk[all] # All providers
20
+ ```
21
+
22
+ ## Quick start
23
+
24
+ ### 1. Authenticate
25
+
26
+ Log in via browser (recommended for local development):
27
+
28
+ ```bash
29
+ promptic login
30
+ ```
31
+
32
+ This opens your browser for authentication, then auto-selects your workspace. Credentials are saved to `~/.promptic/config.toml`.
33
+
34
+ For CI/CD or headless environments, use an API key instead:
35
+
36
+ ```bash
37
+ promptic configure
38
+ # or set the environment variable:
39
+ export PROMPTIC_API_KEY="pk_..."
40
+ ```
41
+
42
+ ### 2. Send traces
43
+
44
+ ```python
45
+ import promptic_sdk
46
+ from openai import OpenAI
47
+
48
+ # Initialize tracing (auto-instruments installed LLM libraries)
49
+ promptic_sdk.init()
50
+
51
+ client = OpenAI()
52
+
53
+ # Tag traces with an AI Component name
54
+ with promptic_sdk.ai_component("customer-support-agent"):
55
+ response = client.chat.completions.create(
56
+ model="gpt-4.1-nano",
57
+ messages=[{"role": "user", "content": "Hello!"}],
58
+ )
59
+ ```
60
+
61
+ ### 3. Use the API client
62
+
63
+ ```python
64
+ from promptic_sdk import PrompticClient
65
+
66
+ with PrompticClient() as client:
67
+ # List traces
68
+ traces = client.list_traces(limit=10)
69
+
70
+ # Get workspace info
71
+ workspace = client.get_workspace()
72
+
73
+ # Manage experiments
74
+ experiment = client.create_experiment(
75
+ ai_component_id="comp_...",
76
+ target_model="gpt-4.1-nano",
77
+ task_type="classification",
78
+ initial_prompt="Classify the following text.",
79
+ )
80
+
81
+ # Deploy the best prompt
82
+ client.deploy(component_id="comp_...", experiment_id="exp_...")
83
+
84
+ # Fetch a deployed prompt at runtime
85
+ prompt = client.get_deployed_prompt("comp_...")
86
+ ```
87
+
88
+ ## Tracing
89
+
90
+ `promptic_sdk.init()` sets up OpenTelemetry to export spans to the Promptic platform.
91
+
92
+ | Parameter | Description | Default |
93
+ | ------------------ | --------------------------------------------------- | ---------------------------- |
94
+ | `api_key` | Promptic API key (falls back to `PROMPTIC_API_KEY`) | — |
95
+ | `endpoint` | Platform URL (falls back to `PROMPTIC_ENDPOINT`) | `https://promptic.eu` |
96
+ | `auto_instrument` | Auto-detect and instrument LLM client libraries | `True` |
97
+ | `service_name` | OpenTelemetry `service.name` resource attribute | — |
98
+
99
+ Auto-detected instrumentors: OpenAI, Anthropic, Google Generative AI, LangChain, Cohere.
100
+
101
+ ### Using other OpenTelemetry instrumentors
102
+
103
+ Since Promptic uses standard OpenTelemetry under the hood, you can add any OTel-compatible instrumentor alongside the auto-detected ones. Just call `promptic_sdk.init()` first, then instrument manually:
104
+
105
+ ```python
106
+ import promptic_sdk
107
+ from opentelemetry.instrumentation.requests import RequestsInstrumentor
108
+ from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
109
+
110
+ promptic_sdk.init()
111
+
112
+ # Add any OpenTelemetry instrumentor — spans will be exported to Promptic
113
+ RequestsInstrumentor().instrument()
114
+ SQLAlchemyInstrumentor().instrument(engine=engine)
115
+ ```
116
+
117
+ This works with any package from the [opentelemetry-python-contrib](https://github.com/open-telemetry/opentelemetry-python-contrib) ecosystem (HTTP clients, databases, web frameworks, etc.). All spans are exported to the Promptic platform as long as `init()` has been called.
118
+
119
+ ### AI Components
120
+
121
+ Use `ai_component()` to tag spans with a component name. The platform links traces to the matching AI Component in your workspace:
122
+
123
+ ```python
124
+ with promptic_sdk.ai_component("my-component"):
125
+ # All LLM calls here are tagged
126
+ ...
127
+ ```
128
+
129
+ ## API client
130
+
131
+ Both a sync (`PrompticClient`) and async (`AsyncPrompticClient`) client are available. They share the same method signatures and return types.
132
+
133
+ ```python
134
+ from promptic_sdk import PrompticClient
135
+
136
+ with PrompticClient() as client:
137
+ traces = client.list_traces(limit=10)
138
+ ```
139
+
140
+ ```python
141
+ from promptic_sdk import AsyncPrompticClient
142
+
143
+ async with AsyncPrompticClient() as client:
144
+ traces = await client.list_traces(limit=10)
145
+ ```
146
+
147
+ Both clients provide typed methods for the full Promptic REST API:
148
+
149
+ | Resource | Methods |
150
+ | -------------- | ----------------------------------------------------------------------- |
151
+ | Workspace | `get_workspace` |
152
+ | Traces | `list_traces`, `get_trace`, `get_stats` |
153
+ | Components | `list_components`, `get_component`, `create_component`, `delete_component` |
154
+ | Experiments | `list_experiments`, `get_experiment`, `create_experiment`, `update_experiment`, `delete_experiment`, `start_experiment` |
155
+ | Observations | `list_observations`, `create_observations`, `update_observation`, `delete_observation` |
156
+ | Evaluators | `list_evaluators`, `create_evaluators`, `update_evaluator`, `delete_evaluator` |
157
+ | Iterations | `list_iterations`, `get_iteration`, `get_best_iteration` |
158
+ | Deployments | `get_deployment`, `deploy`, `undeploy`, `get_deployed_prompt` |
159
+
160
+ The client reads `PROMPTIC_API_KEY` and `PROMPTIC_ENDPOINT` from the environment, or accepts them as constructor arguments.
161
+
162
+ ## CLI
163
+
164
+ The `promptic` CLI mirrors the API client and supports both human-readable tables and `--json` output.
165
+
166
+ ```
167
+ promptic [command] [subcommand] [options]
168
+ ```
169
+
170
+ ### Commands
171
+
172
+ | Command | Description |
173
+ | -------------------------------- | ------------------------------------ |
174
+ | `promptic login` | Authenticate via browser (device flow) |
175
+ | `promptic logout` | Clear saved credentials |
176
+ | `promptic configure` | Save API key and endpoint (CI/CD) |
177
+ | `promptic workspace list` | List accessible workspaces |
178
+ | `promptic workspace select <id>` | Select a workspace |
179
+ | `promptic workspace show` | Show workspace info |
180
+ | `promptic traces list` | List recent traces |
181
+ | `promptic traces get <id>` | Get a trace with spans |
182
+ | `promptic traces stats` | Show aggregated tracing stats |
183
+ | `promptic components list` | List AI components |
184
+ | `promptic components create` | Create a component |
185
+ | `promptic components get <id>` | Get component details |
186
+ | `promptic components delete <id>`| Delete a component |
187
+ | `promptic experiments list` | List experiments |
188
+ | `promptic experiments create` | Create an experiment (interactive) |
189
+ | `promptic experiments get <id>` | Get experiment details |
190
+ | `promptic experiments start <id>`| Start an experiment |
191
+ | `promptic observations list` | List observations for an experiment |
192
+ | `promptic evaluators list` | List evaluators for an experiment |
193
+ | `promptic iterations list` | List iterations for an experiment |
194
+ | `promptic deployments show` | Show deployment for a component |
195
+ | `promptic deployments deploy` | Deploy an experiment |
196
+ | `promptic deployments undeploy` | Remove a deployment |
197
+
198
+ All list commands support `--json` for machine-readable output.
199
+
200
+ ## Configuration
201
+
202
+ The SDK and CLI resolve configuration in this order:
203
+
204
+ 1. Explicit arguments (`api_key=`, `endpoint=`)
205
+ 2. Environment variables (`PROMPTIC_API_KEY`, `PROMPTIC_ENDPOINT`)
206
+ 3. Config file (`~/.promptic/config.toml`, written by `promptic login` or `promptic configure`)
207
+
208
+ | Variable | Description | Default |
209
+ | ------------------- | ---------------------------- | ------------------------- |
210
+ | `PROMPTIC_API_KEY` | API key (for tracing & CI/CD)| — |
211
+ | `PROMPTIC_ENDPOINT` | Platform URL | `https://promptic.eu` |
212
+
213
+ ## Development
214
+
215
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
216
+
217
+ ```bash
218
+ # Install dependencies
219
+ uv sync
220
+
221
+ # Run tests
222
+ uv run pytest
223
+
224
+ # Lint
225
+ uv run ruff check .
226
+ uv run ruff format .
227
+ ```
228
+
229
+ ## License
230
+
231
+ MIT — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,137 @@
1
+ [project]
2
+ requires-python = ">=3.11"
3
+ name = "promptic-sdk"
4
+ version = "0.2.0"
5
+ description = "Python SDK for the Promptic platform — tracing, API client, and CLI."
6
+ readme = "README.md"
7
+ authors = [
8
+ { name = "Promptic GmbH" },
9
+ ]
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ dependencies = [
13
+ "opentelemetry-sdk>=1.20.0",
14
+ "opentelemetry-exporter-otlp-proto-http>=1.20.0",
15
+ "httpx>=0.27.0",
16
+ "typer>=0.15.0",
17
+ "rich>=13.0.0",
18
+ "tomli>=2.0.0;python_version<'3.11'",
19
+ ]
20
+
21
+ [project.optional-dependencies]
22
+ openai = ["opentelemetry-instrumentation-openai>=0.30b0"]
23
+ anthropic = ["opentelemetry-instrumentation-anthropic>=0.30b0"]
24
+ langchain = [
25
+ "opentelemetry-instrumentation-langchain>=0.30b0,!=0.53.0",
26
+ ]
27
+ all = ["promptic-sdk[openai,anthropic,langchain]"]
28
+
29
+ [project.scripts]
30
+ promptic = "promptic_sdk.cli.main:main"
31
+
32
+ [dependency-groups]
33
+ dev = []
34
+ test = [
35
+ "pytest>=7.1.0",
36
+ "pytest-asyncio>=0.26.0",
37
+ "pytest-cov>=4.0",
38
+ ]
39
+ lint = [
40
+ "commitizen>=2.39.1",
41
+ "ruff>=0.6.0",
42
+ "ty>=0.0.1a1",
43
+ ]
44
+
45
+ [tool.uv]
46
+ default-groups = ["dev", "test", "lint"]
47
+ required-version = ">=0.5.23"
48
+
49
+ [tool.commitizen]
50
+ name = "cz_conventional_commits"
51
+ version_provider = "pep621"
52
+ version_files = ["src/promptic_sdk/__init__.py", "pyproject.toml:version"]
53
+ update_changelog_on_bump = true
54
+ changelog_file = "CHANGELOG.md"
55
+ tag_format = "v$version"
56
+
57
+ [build-system]
58
+ requires = ["uv_build>=0.10.0,<0.11.0"]
59
+ build-backend = "uv_build"
60
+
61
+ [tool.ruff]
62
+ line-length = 100
63
+ fix = true
64
+
65
+ [tool.ruff.lint]
66
+ select = [
67
+ "E", # pycodestyle errors
68
+ "W", # pycodestyle warnings
69
+ "F", # pyflake
70
+ "I", # isort
71
+ "D", # pydocstyle
72
+ "C901", # complexity
73
+ "N", # pep8 naming convention
74
+ "UP", # pyupgrade
75
+ "NPY", # NumPy-specific rules
76
+ "ASYNC", # flake8-async
77
+ "S105", # flake8-bandit: hardcoded-password-string
78
+ "S106", # flake8-bandit: hardcoded-password-func-arg
79
+ "S107", # flake8-bandit: hardcoded-password-default
80
+ "C4", # flake8-comprehensions
81
+ "ICN", # flake8-import-conventions
82
+ "PIE", # flake8-pie
83
+ "RET", # flake8-return
84
+ "SIM", # flake8-simplify
85
+ ]
86
+ ignore = [
87
+ "D100", # ignore missing docstring on module level
88
+ "D104", # ignore missing docstring on package level
89
+ "D206", # indent with spaces, may get conflicts with ruff formatter
90
+ "D417", # On top of the Google convention, disable `D417`, which requires documentation for every function parameter.
91
+ "E501", # line too long, handled by ruff formatter if possible
92
+ "RET504", # unnecessary-assign to maintain debuggability
93
+ "RET505", # unnecessary-branch no autofix
94
+ ]
95
+
96
+ [tool.ruff.lint.per-file-ignores]
97
+ "__init__.py" = ["F401"] # ignore unused imports in __init__ file
98
+ "tests/*" = ["D101", "D102", "D103", "D107"] # ignore missing docstring in tests
99
+
100
+ [tool.ruff.lint.pydocstyle]
101
+ convention = "google"
102
+
103
+ [tool.ruff.lint.mccabe]
104
+ max-complexity = 18
105
+
106
+ [tool.ty.environment]
107
+ python-version = "3.11"
108
+
109
+ [tool.ty.rules]
110
+ unresolved-import = "ignore"
111
+
112
+ [tool.pytest.ini_options]
113
+ testpaths = ["tests"]
114
+ addopts = """
115
+ --cov-report html \
116
+ --cov src/promptic_sdk -ra"""
117
+ asyncio_default_fixture_loop_scope = "function"
118
+ asyncio_mode = "auto"
119
+
120
+ [tool.coverage.paths]
121
+ source = ["src/promptic_sdk"]
122
+
123
+ [tool.coverage.run]
124
+ branch = true
125
+ source = ["src/promptic_sdk"]
126
+
127
+ [tool.coverage.report]
128
+ show_missing = true
129
+ exclude_lines = [
130
+ # Have to re-enable the standard pragma
131
+ "pragma: no cover",
132
+ # Don't complain if tests don't hit defensive assertion code:
133
+ "raise NotImplementedError",
134
+ "raise AssertionError",
135
+ # Don't complain about abstract methods, they aren't run:
136
+ "@(abc\\.)?abstractmethod",
137
+ ]