Skip to content

Commit 744eccd

Browse files
authored
feat(api): generate and migrate Prompt REST resources (#750)
### AI Summary Implements the Prompt slice of #683 by publishing all six operations tagged Prompts and moving `load_prompt()` retrieval onto the public REST resources. Prompt request and response models are also exported through the public API. ### Migration flow ```text Before load_prompt(id=...) ------> raw GET /v1/prompt/{id} load_prompt(slug=...) ----> raw GET /v1/prompt After load_prompt(id=...) ------> generated GET /v1/prompt/{id} load_prompt(slug=...) ----> generated GET /v1/prompt ``` | SDK workflow | Previous wire call | Public REST call | | --- | --- | --- | | Load by ID | Raw `GET /v1/prompt/{id}` | Generated `GET /v1/prompt/{id}` | | Load by project and slug | Raw `GET /v1/prompt` | Generated `GET /v1/prompt` | | Prompt CRUD | No generated resource | `client.openapi.prompts` | | Behavior | Result | | --- | --- | | Explicit credentials | Use isolated, cached generated clients without mutating global login | | Active global login | Reuse the existing generated API client | | Version and environment | Explicit version continues to take precedence over environment | | Cache fallback | Preserve local prompt cache fallback for retryable server failures | | Lazy and async loading | Continue deferring retrieval until the prompt is used | | Prompt lookup by ID | Consume the direct response without a synthetic `objects` envelope | | Retry behavior | GET operations are safe reads; version-producing writes are not retried | Refs #683
1 parent f6ef55a commit 744eccd

16 files changed

Lines changed: 2519 additions & 103 deletions

‎openapi/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ make check-api-client-codegen
1616
```
1717

1818
The check regenerates in a temporary directory and reports drift without changing the worktree.
19-
Currently selected tags are Projects, Experiments, and Datasets. Each tag produces one resource and
19+
Currently selected tags are Projects, Experiments, Datasets, and Prompts. Each tag produces one resource and
2020
operation registry. Models used by one resource stay in that resource's model module; shared models
2121
live in `models/common.py`; unreachable models are omitted.
2222

‎openapi/config.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"generated_tags": [
3333
"Projects",
3434
"Experiments",
35-
"Datasets"
35+
"Datasets",
36+
"Prompts"
3637
],
3738
"safe_reads": [
3839
"postExperimentIdFetch",

‎py/src/braintrust/api/_generated/models/__init__.py‎

Lines changed: 133 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)