diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 753e601..92657be 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -26,14 +26,14 @@ jobs:
github.repository == 'stainless-sdks/sapient-go' &&
(github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get GitHub OIDC Token
if: |-
github.repository == 'stainless-sdks/sapient-go' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
- uses: actions/github-script@v8
+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());
@@ -53,10 +53,10 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup go
- uses: actions/setup-go@v5
+ uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: ./go.mod
@@ -68,10 +68,10 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/sapient-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup go
- uses: actions/setup-go@v5
+ uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: ./go.mod
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
new file mode 100644
index 0000000..3d2ac0b
--- /dev/null
+++ b/.release-please-manifest.json
@@ -0,0 +1,3 @@
+{
+ ".": "0.1.0"
+}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 3caa22e..fce9f8a 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 17
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sapient/sapient-908ede43a8944686476822ee14a7f1b1ae3999071a43582a6f88e5d4bff26b33.yml
-openapi_spec_hash: d786bf9a6956b2e85340b6869646ee38
-config_hash: ab4e633d60f3a8815964154998be703c
+configured_endpoints: 34
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sapient/sapient-19772e79be7e030ebf8bd823aae76ff7e366c8f873aab056487dcc912ea5a6b4.yml
+openapi_spec_hash: 92ead540a4d8d32f4411acf9de7fba21
+config_hash: 67f1164874b1569a9845b46e7bfcc132
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..1eb8b79
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,25 @@
+# Changelog
+
+## 0.1.0 (2026-05-15)
+
+Full Changelog: [v0.0.1...v0.1.0](https://github.com/usesapient/go-sdk/compare/v0.0.1...v0.1.0)
+
+### Features
+
+* **api:** api update ([81040ca](https://github.com/usesapient/go-sdk/commit/81040cae143638e659bd7f46e915834389621b73))
+* **api:** manual updates ([9006fc3](https://github.com/usesapient/go-sdk/commit/9006fc392d874ccb73467b5af2c8a604b137264d))
+* **api:** manual updates ([1244e4f](https://github.com/usesapient/go-sdk/commit/1244e4fa9f72055fe47d674631447eecbd6de491))
+* **client:** optimize json encoder for internal types ([c4a2fe9](https://github.com/usesapient/go-sdk/commit/c4a2fe9b93fcbd3a913cfd6d1063629d5151967d))
+* Update Sapient public OpenAPI spec ([08e2481](https://github.com/usesapient/go-sdk/commit/08e2481a51e0c9078c6116ec07a2808a97d854f2))
+
+
+### Bug Fixes
+
+* **go:** avoid panic when http.DefaultTransport is wrapped ([2e82dd9](https://github.com/usesapient/go-sdk/commit/2e82dd9138032133a11d34e1aa61fd3ac76b2c65))
+
+
+### Chores
+
+* configure new SDK language ([7e6c8d5](https://github.com/usesapient/go-sdk/commit/7e6c8d56898948fc5d8f4c96122d67a6fd9cae64))
+* redact api-key headers in debug logs ([70c3559](https://github.com/usesapient/go-sdk/commit/70c3559c6f6ee137cbae449697f3f165d4e3b610))
+* update SDK settings ([aaa249d](https://github.com/usesapient/go-sdk/commit/aaa249d20e8fb643d66f48bf567af669ded55b14))
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3498b09..5366dd3 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,7 +41,7 @@ To use a local version of this library from source in another project, edit the
directive. This can be done through the CLI with the following:
```sh
-$ go mod edit -replace github.com/stainless-sdks/sapient-go=/path/to/sapient-go
+$ go mod edit -replace github.com/usesapient/go-sdk=/path/to/go-sdk
```
## Running tests
diff --git a/README.md b/README.md
index 77072ac..7e17d80 100644
--- a/README.md
+++ b/README.md
@@ -2,29 +2,37 @@
-
+
-The Sapient Go library provides convenient access to the Sapient REST API
+The Sapient Go library provides convenient access to the [Sapient REST API](https://docs.usesapient.com)
from applications written in Go.
It is generated with [Stainless](https://www.stainless.com/).
## Installation
+
+
```go
import (
- "github.com/stainless-sdks/sapient-go" // imported as sapient
+ "github.com/usesapient/go-sdk" // imported as githubcomusesapientgosdk
)
```
+
+
Or to pin the version:
+
+
```sh
-go get -u 'github.com/stainless-sdks/sapient-go@v0.0.1'
+go get -u 'github.com/usesapient/go-sdk@v0.1.0'
```
+
+
## Requirements
This library requires Go 1.22+.
@@ -40,12 +48,12 @@ import (
"context"
"fmt"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/option"
)
func main() {
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("SAPIENT_API_KEY")
)
status, err := client.Status.Get(context.TODO())
@@ -59,13 +67,13 @@ func main() {
### Request fields
-The sapient library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson)
+The githubcomusesapientgosdk library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson)
semantics from the Go 1.24+ `encoding/json` release for request fields.
Required primitive fields (`int64`, `string`, etc.) feature the tag \`api:"required"\`. These
fields are always serialized, even their zero values.
-Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be set with the provided constructors, `sapient.String(string)`, `sapient.Int(int64)`, etc.
+Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be set with the provided constructors, `githubcomusesapientgosdk.String(string)`, `githubcomusesapientgosdk.Int(int64)`, etc.
Any `param.Opt[T]`, map, slice, struct or string enum uses the
tag \`json:"...,omitzero"\`. Its zero value is considered omitted.
@@ -73,17 +81,17 @@ tag \`json:"...,omitzero"\`. Its zero value is considered omitted.
The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.
```go
-p := sapient.ExampleParams{
- ID: "id_xxx", // required property
- Name: sapient.String("..."), // optional property
+p := githubcomusesapientgosdk.ExampleParams{
+ ID: "id_xxx", // required property
+ Name: githubcomusesapientgosdk.String("..."), // optional property
- Point: sapient.Point{
- X: 0, // required field will serialize as 0
- Y: sapient.Int(1), // optional field will serialize as 1
+ Point: githubcomusesapientgosdk.Point{
+ X: 0, // required field will serialize as 0
+ Y: githubcomusesapientgosdk.Int(1), // optional field will serialize as 1
// ... omitted non-required fields will not be serialized
},
- Origin: sapient.Origin{}, // the zero value of [Origin] is considered omitted
+ Origin: githubcomusesapientgosdk.Origin{}, // the zero value of [Origin] is considered omitted
}
```
@@ -112,7 +120,7 @@ p.SetExtraFields(map[string]any{
})
// Send a number instead of an object
-custom := param.Override[sapient.FooParams](12)
+custom := param.Override[githubcomusesapientgosdk.FooParams](12)
```
### Request unions
@@ -253,7 +261,7 @@ This library uses the functional options pattern. Functions defined in the
requests. For example:
```go
-client := sapient.NewClient(
+client := githubcomusesapientgosdk.NewClient(
// Adds a header to every request made by the client
option.WithHeader("X-Some-Header", "custom_header_info"),
)
@@ -268,7 +276,7 @@ client.Status.Get(context.TODO(), ...,
The request option `option.WithDebugLog(nil)` may be helpful while debugging.
-See the [full list of request options](https://pkg.go.dev/github.com/stainless-sdks/sapient-go/option).
+See the [full list of request options](https://pkg.go.dev/github.com/usesapient/go-sdk/option).
### Pagination
@@ -282,7 +290,7 @@ with additional helper methods like `.GetNextPage()`, e.g.:
### Errors
When the API returns a non-success status code, we return an error with type
-`*sapient.Error`. This contains the `StatusCode`, `*http.Request`, and
+`*githubcomusesapientgosdk.Error`. This contains the `StatusCode`, `*http.Request`, and
`*http.Response` values of the request, as well as the JSON of the error body
(much like other response objects in the SDK).
@@ -291,7 +299,7 @@ To handle errors, we recommend that you use the `errors.As` pattern:
```go
_, err := client.Status.Get(context.TODO())
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
@@ -331,7 +339,7 @@ The file name and content-type can be customized by implementing `Name() string`
string` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a
file returned by `os.Open` will be sent with the file name on disk.
-We also provide a helper `sapient.File(reader io.Reader, filename string, contentType string)`
+We also provide a helper `githubcomusesapientgosdk.File(reader io.Reader, filename string, contentType string)`
which can be used to wrap any `io.Reader` with the appropriate file name and content type.
### Retries
@@ -344,7 +352,7 @@ You can use the `WithMaxRetries` option to configure or disable this:
```go
// Configure the default for all requests:
-client := sapient.NewClient(
+client := githubcomusesapientgosdk.NewClient(
option.WithMaxRetries(0), // default is 2
)
@@ -405,7 +413,7 @@ or the `option.WithJSONSet()` methods.
params := FooNewParams{
ID: "id_xxxx",
Data: FooNewParamsData{
- FirstName: sapient.String("John"),
+ FirstName: githubcomusesapientgosdk.String("John"),
},
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
@@ -440,7 +448,7 @@ func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response,
return res, err
}
-client := sapient.NewClient(
+client := githubcomusesapientgosdk.NewClient(
option.WithMiddleware(Logger),
)
```
@@ -465,7 +473,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
-We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/sapient-go/issues) with questions, bugs, or suggestions.
+We are keen for your feedback; please open an [issue](https://www.github.com/usesapient/go-sdk/issues) with questions, bugs, or suggestions.
## Contributing
diff --git a/SECURITY.md b/SECURITY.md
index e9c1ae4..1970fe7 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -18,6 +18,10 @@ before making any information public.
If you encounter security issues that are not directly related to SDKs but pertain to the services
or products provided by Sapient, please follow the respective company's security reporting guidelines.
+### Sapient Terms and Policies
+
+Please contact support@usesapient.com for any questions or concerns regarding the security of our services.
+
---
Thank you for helping us keep the SDKs and systems they interact with secure.
diff --git a/aliases.go b/aliases.go
index d546547..4d65e5c 100644
--- a/aliases.go
+++ b/aliases.go
@@ -1,10 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient
+package githubcomusesapientgosdk
import (
- "github.com/stainless-sdks/sapient-go/internal/apierror"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/internal/apierror"
+ "github.com/usesapient/go-sdk/packages/param"
)
// aliased to make [param.APIUnion] private when embedding
diff --git a/api.go b/api.go
deleted file mode 100644
index 4ffb834..0000000
--- a/api.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "github.com/stainless-sdks/sapient-go/option"
-)
-
-// APIService contains methods and other services that help with interacting with
-// the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewAPIService] method instead.
-type APIService struct {
- options []option.RequestOption
- Leaderboard APILeaderboardService
- APIPerformance APIAPIPerformanceService
- Prompts APIPromptService
- Jobs APIJobService
-}
-
-// NewAPIService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewAPIService(opts ...option.RequestOption) (r APIService) {
- r = APIService{}
- r.options = opts
- r.Leaderboard = NewAPILeaderboardService(opts...)
- r.APIPerformance = NewAPIAPIPerformanceService(opts...)
- r.Prompts = NewAPIPromptService(opts...)
- r.Jobs = NewAPIJobService(opts...)
- return
-}
diff --git a/api.md b/api.md
index 12b77f4..1bbdd67 100644
--- a/api.md
+++ b/api.md
@@ -2,146 +2,172 @@
Response Types:
-- sapient.StatusGetResponse
-- sapient.StatusGetResponse
+- githubcomusesapientgosdk.StatusGetResponse
Methods:
-- client.Status.Get(ctx context.Context) (\*sapient.StatusGetResponse, error)
-- client.Status.Get(ctx context.Context) (\*sapient.StatusGetResponse, error)
+- client.Status.Get(ctx context.Context) (\*githubcomusesapientgosdk.StatusGetResponse, error)
# Auth
Response Types:
-- sapient.AuthGetStatusResponse
-- sapient.AuthStatusResponse
+- githubcomusesapientgosdk.AuthStatusResponse
Methods:
-- client.Auth.GetStatus(ctx context.Context) (\*sapient.AuthGetStatusResponse, error)
-- client.Auth.Status(ctx context.Context) (\*sapient.AuthStatusResponse, error)
+- client.Auth.Status(ctx context.Context) (\*githubcomusesapientgosdk.AuthStatusResponse, error)
-# Context
+# Prompts
Response Types:
-- sapient.EvalRunSummary
-- sapient.PublicCompany
-- sapient.PublicEndpoint
-- sapient.ContextGetCompanyResponse
-- sapient.ContextCompanyResponse
+- githubcomusesapientgosdk.PromptNewResponse
+- githubcomusesapientgosdk.PromptGetResponse
+- githubcomusesapientgosdk.PromptUpdateResponse
+- githubcomusesapientgosdk.PromptListResponse
+- githubcomusesapientgosdk.PromptDeleteResponse
Methods:
-- client.Context.GetCompany(ctx context.Context, company string, query sapient.ContextGetCompanyParams) (\*sapient.ContextGetCompanyResponse, error)
-- client.Context.Company(ctx context.Context, company string, query sapient.ContextCompanyParams) (\*sapient.ContextCompanyResponse, error)
+- client.Prompts.New(ctx context.Context, body githubcomusesapientgosdk.PromptNewParams) (\*githubcomusesapientgosdk.PromptNewResponse, error)
+- client.Prompts.Get(ctx context.Context, promptID string) (\*githubcomusesapientgosdk.PromptGetResponse, error)
+- client.Prompts.Update(ctx context.Context, promptID string, body githubcomusesapientgosdk.PromptUpdateParams) (\*githubcomusesapientgosdk.PromptUpdateResponse, error)
+- client.Prompts.List(ctx context.Context, query githubcomusesapientgosdk.PromptListParams) (\*githubcomusesapientgosdk.PromptListResponse, error)
+- client.Prompts.Delete(ctx context.Context, promptID string) (\*githubcomusesapientgosdk.PromptDeleteResponse, error)
-# EvalRuns
+## Topics
Response Types:
-- sapient.EvalRunDetail
-- sapient.PublicListMeta
-- sapient.EvalRunGetResponse
-- sapient.EvalRunListResponse
-- sapient.EvalRunDiagnoseResponse
+- githubcomusesapientgosdk.PromptTopicNewResponse
+- githubcomusesapientgosdk.PromptTopicUpdateResponse
+- githubcomusesapientgosdk.PromptTopicListResponse
+- githubcomusesapientgosdk.PromptTopicDeleteResponse
Methods:
-- client.EvalRuns.Get(ctx context.Context, runID string) (\*sapient.EvalRunGetResponse, error)
-- client.EvalRuns.List(ctx context.Context, query sapient.EvalRunListParams) (\*sapient.EvalRunListResponse, error)
-- client.EvalRuns.Diagnose(ctx context.Context, body sapient.EvalRunDiagnoseParams) (\*sapient.EvalRunDiagnoseResponse, error)
+- client.Prompts.Topics.New(ctx context.Context, body githubcomusesapientgosdk.PromptTopicNewParams) (\*githubcomusesapientgosdk.PromptTopicNewResponse, error)
+- client.Prompts.Topics.Update(ctx context.Context, topicID string, body githubcomusesapientgosdk.PromptTopicUpdateParams) (\*githubcomusesapientgosdk.PromptTopicUpdateResponse, error)
+- client.Prompts.Topics.List(ctx context.Context) (\*[]githubcomusesapientgosdk.PromptTopicListResponse, error)
+- client.Prompts.Topics.Delete(ctx context.Context, topicID string) (\*githubcomusesapientgosdk.PromptTopicDeleteResponse, error)
-# Prompts
+## Platforms
Response Types:
-- sapient.PromptGenerateFromListResponse
+- githubcomusesapientgosdk.PromptPlatformListResponse
Methods:
-- client.Prompts.GenerateFromList(ctx context.Context, body sapient.PromptGenerateFromListParams) (\*sapient.PromptGenerateFromListResponse, error)
+- client.Prompts.Platforms.List(ctx context.Context) (\*githubcomusesapientgosdk.PromptPlatformListResponse, error)
+
+# APIPerformance
-# Workflows
+## Platforms
Response Types:
-- sapient.WorkflowResponse
-- sapient.WorkflowRunResponse
+- githubcomusesapientgosdk.APIPerformancePlatformListResponse
+- githubcomusesapientgosdk.APIPerformancePlatformEstimateCostResponse
Methods:
-- client.Workflows.New(ctx context.Context, body sapient.WorkflowNewParams) (\*sapient.WorkflowResponse, error)
-- client.Workflows.Get(ctx context.Context, workflowID string) (\*sapient.WorkflowResponse, error)
-- client.Workflows.Run(ctx context.Context, workflowID string, body sapient.WorkflowRunParams) (\*sapient.WorkflowRunResponse, error)
+- client.APIPerformance.Platforms.List(ctx context.Context) (\*githubcomusesapientgosdk.APIPerformancePlatformListResponse, error)
+- client.APIPerformance.Platforms.EstimateCost(ctx context.Context, body githubcomusesapientgosdk.APIPerformancePlatformEstimateCostParams) (\*githubcomusesapientgosdk.APIPerformancePlatformEstimateCostResponse, error)
-# WorkflowRuns
+## Interfaces
Response Types:
-- sapient.PublicJob
+- githubcomusesapientgosdk.APIPerformanceInterfaceListResponse
Methods:
-- client.WorkflowRuns.Get(ctx context.Context, runID string) (\*sapient.PublicJob, error)
+- client.APIPerformance.Interfaces.List(ctx context.Context) (\*githubcomusesapientgosdk.APIPerformanceInterfaceListResponse, error)
+
+## EvaluationConfig
+
+Response Types:
+
+- githubcomusesapientgosdk.APIPerformanceEvaluationConfigGetResponse
+- githubcomusesapientgosdk.APIPerformanceEvaluationConfigUpdateResponse
+
+Methods:
-# API
+- client.APIPerformance.EvaluationConfig.Get(ctx context.Context, query githubcomusesapientgosdk.APIPerformanceEvaluationConfigGetParams) (\*githubcomusesapientgosdk.APIPerformanceEvaluationConfigGetResponse, error)
+- client.APIPerformance.EvaluationConfig.Update(ctx context.Context, body githubcomusesapientgosdk.APIPerformanceEvaluationConfigUpdateParams) (\*githubcomusesapientgosdk.APIPerformanceEvaluationConfigUpdateResponse, error)
-## Leaderboard
+## Operations
Response Types:
-- sapient.APILeaderboardListCompaniesResponse
+- githubcomusesapientgosdk.APIPerformanceOperationNewResponse
+- githubcomusesapientgosdk.APIPerformanceOperationGetResponse
+- githubcomusesapientgosdk.APIPerformanceOperationUpdateResponse
+- githubcomusesapientgosdk.APIPerformanceOperationListResponse
+- githubcomusesapientgosdk.APIPerformanceOperationDeleteResponse
Methods:
-- client.API.Leaderboard.ListCompanies(ctx context.Context, query sapient.APILeaderboardListCompaniesParams) (\*sapient.APILeaderboardListCompaniesResponse, error)
+- client.APIPerformance.Operations.New(ctx context.Context, body githubcomusesapientgosdk.APIPerformanceOperationNewParams) (\*githubcomusesapientgosdk.APIPerformanceOperationNewResponse, error)
+- client.APIPerformance.Operations.Get(ctx context.Context, operationID string) (\*githubcomusesapientgosdk.APIPerformanceOperationGetResponse, error)
+- client.APIPerformance.Operations.Update(ctx context.Context, operationID string, body githubcomusesapientgosdk.APIPerformanceOperationUpdateParams) (\*githubcomusesapientgosdk.APIPerformanceOperationUpdateResponse, error)
+- client.APIPerformance.Operations.List(ctx context.Context, query githubcomusesapientgosdk.APIPerformanceOperationListParams) (\*[]githubcomusesapientgosdk.APIPerformanceOperationListResponse, error)
+- client.APIPerformance.Operations.Delete(ctx context.Context, operationID string) (\*githubcomusesapientgosdk.APIPerformanceOperationDeleteResponse, error)
-### Companies
+## OperationPrompts
Response Types:
-- sapient.APILeaderboardCompanyListResponse
+- githubcomusesapientgosdk.APIPerformanceOperationPromptNewResponse
+- githubcomusesapientgosdk.APIPerformanceOperationPromptListResponse
Methods:
-- client.API.Leaderboard.Companies.List(ctx context.Context, query sapient.APILeaderboardCompanyListParams) (\*sapient.APILeaderboardCompanyListResponse, error)
+- client.APIPerformance.OperationPrompts.New(ctx context.Context, operationID string, body githubcomusesapientgosdk.APIPerformanceOperationPromptNewParams) (\*githubcomusesapientgosdk.APIPerformanceOperationPromptNewResponse, error)
+- client.APIPerformance.OperationPrompts.List(ctx context.Context, operationID string) (\*[]githubcomusesapientgosdk.APIPerformanceOperationPromptListResponse, error)
-## APIPerformance
+## Runs
Response Types:
-- sapient.FailureAnalysisSnapshot
-- sapient.ApiapiPerformanceLatestRunsResponse
+- githubcomusesapientgosdk.APIPerformanceRunGetResponse
+- githubcomusesapientgosdk.APIPerformanceRunListResponse
Methods:
-- client.API.APIPerformance.FailureAnalysis(ctx context.Context, brandID string, query sapient.APIAPIPerformanceFailureAnalysisParams) (\*sapient.FailureAnalysisSnapshot, error)
-- client.API.APIPerformance.LatestRuns(ctx context.Context, brandID string, query sapient.APIAPIPerformanceLatestRunsParams) (\*sapient.ApiapiPerformanceLatestRunsResponse, error)
+- client.APIPerformance.Runs.Get(ctx context.Context, runID string) (\*githubcomusesapientgosdk.APIPerformanceRunGetResponse, error)
+- client.APIPerformance.Runs.List(ctx context.Context, query githubcomusesapientgosdk.APIPerformanceRunListParams) (\*githubcomusesapientgosdk.APIPerformanceRunListResponse, error)
## Prompts
Response Types:
-- sapient.APIPromptNewBatchResponse
-- sapient.APIPromptBatchResponse
+- githubcomusesapientgosdk.APIPerformancePromptGetResponse
+- githubcomusesapientgosdk.APIPerformancePromptUpdateResponse
+- githubcomusesapientgosdk.APIPerformancePromptDeleteResponse
Methods:
-- client.API.Prompts.NewBatch(ctx context.Context, body sapient.APIPromptNewBatchParams) (\*sapient.APIPromptNewBatchResponse, error)
-- client.API.Prompts.Batch(ctx context.Context, body sapient.APIPromptBatchParams) (\*sapient.APIPromptBatchResponse, error)
+- client.APIPerformance.Prompts.Get(ctx context.Context, promptID string) (\*githubcomusesapientgosdk.APIPerformancePromptGetResponse, error)
+- client.APIPerformance.Prompts.Update(ctx context.Context, promptID string, body githubcomusesapientgosdk.APIPerformancePromptUpdateParams) (\*githubcomusesapientgosdk.APIPerformancePromptUpdateResponse, error)
+- client.APIPerformance.Prompts.Delete(ctx context.Context, promptID string) (\*githubcomusesapientgosdk.APIPerformancePromptDeleteResponse, error)
-## Jobs
+## UseCases
Response Types:
-- sapient.APIJobListJobsResponse
-- sapient.APIJobListResponse
+- githubcomusesapientgosdk.APIPerformanceUseCaseNewResponse
+- githubcomusesapientgosdk.APIPerformanceUseCaseGetResponse
+- githubcomusesapientgosdk.APIPerformanceUseCaseUpdateResponse
+- githubcomusesapientgosdk.APIPerformanceUseCaseListResponse
+- githubcomusesapientgosdk.APIPerformanceUseCaseDeleteResponse
Methods:
-- client.API.Jobs.ListJobs(ctx context.Context, query sapient.APIJobListJobsParams) (\*sapient.APIJobListJobsResponse, error)
-- client.API.Jobs.GetJob(ctx context.Context, jobID string) (\*sapient.PublicJob, error)
-- client.API.Jobs.List(ctx context.Context, query sapient.APIJobListParams) (\*sapient.APIJobListResponse, error)
-- client.API.Jobs.Get(ctx context.Context, jobID string) (\*sapient.PublicJob, error)
+- client.APIPerformance.UseCases.New(ctx context.Context, body githubcomusesapientgosdk.APIPerformanceUseCaseNewParams) (\*githubcomusesapientgosdk.APIPerformanceUseCaseNewResponse, error)
+- client.APIPerformance.UseCases.Get(ctx context.Context, useCaseID string) (\*githubcomusesapientgosdk.APIPerformanceUseCaseGetResponse, error)
+- client.APIPerformance.UseCases.Update(ctx context.Context, useCaseID string, body githubcomusesapientgosdk.APIPerformanceUseCaseUpdateParams) (\*githubcomusesapientgosdk.APIPerformanceUseCaseUpdateResponse, error)
+- client.APIPerformance.UseCases.List(ctx context.Context) (\*[]githubcomusesapientgosdk.APIPerformanceUseCaseListResponse, error)
+- client.APIPerformance.UseCases.Delete(ctx context.Context, useCaseID string) (\*githubcomusesapientgosdk.APIPerformanceUseCaseDeleteResponse, error)
diff --git a/apiapiperformance.go b/apiapiperformance.go
deleted file mode 100644
index 801ac53..0000000
--- a/apiapiperformance.go
+++ /dev/null
@@ -1,168 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
-)
-
-// APIAPIPerformanceService contains methods and other services that help with
-// interacting with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewAPIAPIPerformanceService] method instead.
-type APIAPIPerformanceService struct {
- options []option.RequestOption
-}
-
-// NewAPIAPIPerformanceService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewAPIAPIPerformanceService(opts ...option.RequestOption) (r APIAPIPerformanceService) {
- r = APIAPIPerformanceService{}
- r.options = opts
- return
-}
-
-// Failure Analysis
-func (r *APIAPIPerformanceService) FailureAnalysis(ctx context.Context, brandID string, query APIAPIPerformanceFailureAnalysisParams, opts ...option.RequestOption) (res *FailureAnalysisSnapshot, err error) {
- opts = slices.Concat(r.options, opts)
- if brandID == "" {
- err = errors.New("missing required brand_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/api/api-performance/failure-analysis/%s", url.PathEscape(brandID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// Latest Runs
-func (r *APIAPIPerformanceService) LatestRuns(ctx context.Context, brandID string, query APIAPIPerformanceLatestRunsParams, opts ...option.RequestOption) (res *ApiapiPerformanceLatestRunsResponse, err error) {
- opts = slices.Concat(r.options, opts)
- if brandID == "" {
- err = errors.New("missing required brand_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/api/api-performance/latest-runs/%s", url.PathEscape(brandID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type FailureAnalysisSnapshot struct {
- EndpointsByFailureCount []map[string]any `json:"endpoints_by_failure_count"`
- FailedRuns int64 `json:"failed_runs"`
- FailureRate float64 `json:"failure_rate" api:"nullable"`
- Patterns []FailureAnalysisSnapshotPattern `json:"patterns"`
- TopFailureReasons []map[string]any `json:"top_failure_reasons"`
- TotalRuns int64 `json:"total_runs"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- EndpointsByFailureCount respjson.Field
- FailedRuns respjson.Field
- FailureRate respjson.Field
- Patterns respjson.Field
- TopFailureReasons respjson.Field
- TotalRuns respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r FailureAnalysisSnapshot) RawJSON() string { return r.JSON.raw }
-func (r *FailureAnalysisSnapshot) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type FailureAnalysisSnapshotPattern struct {
- Count int64 `json:"count" api:"required"`
- Label string `json:"label" api:"required"`
- Pattern string `json:"pattern" api:"required"`
- AffectedEndpoints []map[string]any `json:"affected_endpoints"`
- AffectedModels []string `json:"affected_models"`
- Description string `json:"description" api:"nullable"`
- ExampleReasons []string `json:"example_reasons"`
- Percentage float64 `json:"percentage" api:"nullable"`
- RunIDs []string `json:"run_ids"`
- Severity string `json:"severity" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Count respjson.Field
- Label respjson.Field
- Pattern respjson.Field
- AffectedEndpoints respjson.Field
- AffectedModels respjson.Field
- Description respjson.Field
- ExampleReasons respjson.Field
- Percentage respjson.Field
- RunIDs respjson.Field
- Severity respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r FailureAnalysisSnapshotPattern) RawJSON() string { return r.JSON.raw }
-func (r *FailureAnalysisSnapshotPattern) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type ApiapiPerformanceLatestRunsResponse struct {
- Data []EvalRunSummary `json:"data" api:"required"`
- Meta PublicListMeta `json:"meta" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Data respjson.Field
- Meta respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r ApiapiPerformanceLatestRunsResponse) RawJSON() string { return r.JSON.raw }
-func (r *ApiapiPerformanceLatestRunsResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type APIAPIPerformanceFailureAnalysisParams struct {
- IntegrationID param.Opt[string] `query:"integration_id,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [APIAPIPerformanceFailureAnalysisParams]'s query parameters
-// as `url.Values`.
-func (r APIAPIPerformanceFailureAnalysisParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type APIAPIPerformanceLatestRunsParams struct {
- Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [APIAPIPerformanceLatestRunsParams]'s query parameters as
-// `url.Values`.
-func (r APIAPIPerformanceLatestRunsParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/apijob.go b/apijob.go
deleted file mode 100644
index b39fdb3..0000000
--- a/apijob.go
+++ /dev/null
@@ -1,110 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
-)
-
-// APIJobService contains methods and other services that help with interacting
-// with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewAPIJobService] method instead.
-type APIJobService struct {
- options []option.RequestOption
-}
-
-// NewAPIJobService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewAPIJobService(opts ...option.RequestOption) (r APIJobService) {
- r = APIJobService{}
- r.options = opts
- return
-}
-
-// List Jobs
-func (r *APIJobService) ListJobs(ctx context.Context, query APIJobListJobsParams, opts ...option.RequestOption) (res *APIJobListJobsResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/api/jobs"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// Retrieve Job
-func (r *APIJobService) GetJob(ctx context.Context, jobID string, opts ...option.RequestOption) (res *PublicJob, err error) {
- opts = slices.Concat(r.options, opts)
- if jobID == "" {
- err = errors.New("missing required job_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/api/jobs/%s", url.PathEscape(jobID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-// List Jobs
-func (r *APIJobService) List(ctx context.Context, query APIJobListParams, opts ...option.RequestOption) (res *APIJobListResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/api/jobs"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// Retrieve Job
-func (r *APIJobService) Get(ctx context.Context, jobID string, opts ...option.RequestOption) (res *PublicJob, err error) {
- opts = slices.Concat(r.options, opts)
- if jobID == "" {
- err = errors.New("missing required job_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/api/jobs/%s", url.PathEscape(jobID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type APIJobListJobsResponse = any
-
-type APIJobListResponse = any
-
-type APIJobListJobsParams struct {
- Status param.Opt[string] `query:"status,omitzero" json:"-"`
- Type param.Opt[string] `query:"type,omitzero" json:"-"`
- Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [APIJobListJobsParams]'s query parameters as `url.Values`.
-func (r APIJobListJobsParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type APIJobListParams struct {
- Status param.Opt[string] `query:"status,omitzero" json:"-"`
- Type param.Opt[string] `query:"type,omitzero" json:"-"`
- Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [APIJobListParams]'s query parameters as `url.Values`.
-func (r APIJobListParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/apileaderboard.go b/apileaderboard.go
deleted file mode 100644
index 8966de8..0000000
--- a/apileaderboard.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
-)
-
-// APILeaderboardService contains methods and other services that help with
-// interacting with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewAPILeaderboardService] method instead.
-type APILeaderboardService struct {
- options []option.RequestOption
- Companies APILeaderboardCompanyService
-}
-
-// NewAPILeaderboardService generates a new service that applies the given options
-// to each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewAPILeaderboardService(opts ...option.RequestOption) (r APILeaderboardService) {
- r = APILeaderboardService{}
- r.options = opts
- r.Companies = NewAPILeaderboardCompanyService(opts...)
- return
-}
-
-// List Companies
-func (r *APILeaderboardService) ListCompanies(ctx context.Context, query APILeaderboardListCompaniesParams, opts ...option.RequestOption) (res *APILeaderboardListCompaniesResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/api/leaderboard/companies"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type APILeaderboardListCompaniesResponse = any
-
-type APILeaderboardListCompaniesParams struct {
- Category param.Opt[string] `query:"category,omitzero" json:"-"`
- Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [APILeaderboardListCompaniesParams]'s query parameters as
-// `url.Values`.
-func (r APILeaderboardListCompaniesParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/apileaderboard_test.go b/apileaderboard_test.go
deleted file mode 100644
index 66bf980..0000000
--- a/apileaderboard_test.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
-)
-
-func TestAPILeaderboardListCompaniesWithOptionalParams(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.API.Leaderboard.ListCompanies(context.TODO(), sapient.APILeaderboardListCompaniesParams{
- Category: sapient.String("category"),
- Limit: sapient.Int(1),
- })
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/apileaderboardcompany.go b/apileaderboardcompany.go
deleted file mode 100644
index 6155297..0000000
--- a/apileaderboardcompany.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
-)
-
-// APILeaderboardCompanyService contains methods and other services that help with
-// interacting with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewAPILeaderboardCompanyService] method instead.
-type APILeaderboardCompanyService struct {
- options []option.RequestOption
-}
-
-// NewAPILeaderboardCompanyService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewAPILeaderboardCompanyService(opts ...option.RequestOption) (r APILeaderboardCompanyService) {
- r = APILeaderboardCompanyService{}
- r.options = opts
- return
-}
-
-// List Companies
-func (r *APILeaderboardCompanyService) List(ctx context.Context, query APILeaderboardCompanyListParams, opts ...option.RequestOption) (res *APILeaderboardCompanyListResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/api/leaderboard/companies"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type APILeaderboardCompanyListResponse = any
-
-type APILeaderboardCompanyListParams struct {
- Category param.Opt[string] `query:"category,omitzero" json:"-"`
- Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [APILeaderboardCompanyListParams]'s query parameters as
-// `url.Values`.
-func (r APILeaderboardCompanyListParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/apiperformance.go b/apiperformance.go
new file mode 100644
index 0000000..66302f1
--- /dev/null
+++ b/apiperformance.go
@@ -0,0 +1,42 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "github.com/usesapient/go-sdk/option"
+)
+
+// APIPerformanceService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceService] method instead.
+type APIPerformanceService struct {
+ Options []option.RequestOption
+ Platforms APIPerformancePlatformService
+ Interfaces APIPerformanceInterfaceService
+ EvaluationConfig APIPerformanceEvaluationConfigService
+ Operations APIPerformanceOperationService
+ OperationPrompts APIPerformanceOperationPromptService
+ Runs APIPerformanceRunService
+ Prompts APIPerformancePromptService
+ UseCases APIPerformanceUseCaseService
+}
+
+// NewAPIPerformanceService generates a new service that applies the given options
+// to each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewAPIPerformanceService(opts ...option.RequestOption) (r APIPerformanceService) {
+ r = APIPerformanceService{}
+ r.Options = opts
+ r.Platforms = NewAPIPerformancePlatformService(opts...)
+ r.Interfaces = NewAPIPerformanceInterfaceService(opts...)
+ r.EvaluationConfig = NewAPIPerformanceEvaluationConfigService(opts...)
+ r.Operations = NewAPIPerformanceOperationService(opts...)
+ r.OperationPrompts = NewAPIPerformanceOperationPromptService(opts...)
+ r.Runs = NewAPIPerformanceRunService(opts...)
+ r.Prompts = NewAPIPerformancePromptService(opts...)
+ r.UseCases = NewAPIPerformanceUseCaseService(opts...)
+ return
+}
diff --git a/apiperformanceevaluationconfig.go b/apiperformanceevaluationconfig.go
new file mode 100644
index 0000000..beaee04
--- /dev/null
+++ b/apiperformanceevaluationconfig.go
@@ -0,0 +1,142 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/apiquery"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformanceEvaluationConfigService contains methods and other services that
+// help with interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceEvaluationConfigService] method instead.
+type APIPerformanceEvaluationConfigService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformanceEvaluationConfigService generates a new service that applies
+// the given options to each request. These options are applied after the parent
+// client's options (if there is one), and before any request-specific options.
+func NewAPIPerformanceEvaluationConfigService(opts ...option.RequestOption) (r APIPerformanceEvaluationConfigService) {
+ r = APIPerformanceEvaluationConfigService{}
+ r.Options = opts
+ return
+}
+
+// Retrieve Evaluation Config
+func (r *APIPerformanceEvaluationConfigService) Get(ctx context.Context, query APIPerformanceEvaluationConfigGetParams, opts ...option.RequestOption) (res *APIPerformanceEvaluationConfigGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/evaluation-config"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ return res, err
+}
+
+// Update Evaluation Config
+func (r *APIPerformanceEvaluationConfigService) Update(ctx context.Context, body APIPerformanceEvaluationConfigUpdateParams, opts ...option.RequestOption) (res *APIPerformanceEvaluationConfigUpdateResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/evaluation-config"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+type APIPerformanceEvaluationConfigGetResponse struct {
+ OperationIDs []string `json:"operation_ids" api:"required"`
+ APIBaseURL string `json:"api_base_url" api:"nullable"`
+ EnvVarKeys []string `json:"env_var_keys"`
+ EvalTypes []string `json:"eval_types"`
+ Framework string `json:"framework" api:"nullable"`
+ Platforms []string `json:"platforms"`
+ UseCaseIDs []string `json:"use_case_ids"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ OperationIDs respjson.Field
+ APIBaseURL respjson.Field
+ EnvVarKeys respjson.Field
+ EvalTypes respjson.Field
+ Framework respjson.Field
+ Platforms respjson.Field
+ UseCaseIDs respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceEvaluationConfigGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceEvaluationConfigGetResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceEvaluationConfigUpdateResponse struct {
+ OperationIDs []string `json:"operation_ids" api:"required"`
+ APIBaseURL string `json:"api_base_url" api:"nullable"`
+ EnvVarKeys []string `json:"env_var_keys"`
+ EvalTypes []string `json:"eval_types"`
+ Framework string `json:"framework" api:"nullable"`
+ Platforms []string `json:"platforms"`
+ UseCaseIDs []string `json:"use_case_ids"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ OperationIDs respjson.Field
+ APIBaseURL respjson.Field
+ EnvVarKeys respjson.Field
+ EvalTypes respjson.Field
+ Framework respjson.Field
+ Platforms respjson.Field
+ UseCaseIDs respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceEvaluationConfigUpdateResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceEvaluationConfigUpdateResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceEvaluationConfigGetParams struct {
+ InterfaceID param.Opt[string] `query:"interface_id,omitzero" json:"-"`
+ paramObj
+}
+
+// URLQuery serializes [APIPerformanceEvaluationConfigGetParams]'s query parameters
+// as `url.Values`.
+func (r APIPerformanceEvaluationConfigGetParams) URLQuery() (v url.Values, err error) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type APIPerformanceEvaluationConfigUpdateParams struct {
+ APIBaseURL param.Opt[string] `json:"api_base_url,omitzero"`
+ Framework param.Opt[string] `json:"framework,omitzero"`
+ InterfaceID param.Opt[string] `json:"interface_id,omitzero"`
+ EnvVars map[string]string `json:"env_vars,omitzero"`
+ EvalTypes []string `json:"eval_types,omitzero"`
+ OperationIDs []string `json:"operation_ids,omitzero"`
+ Platforms []string `json:"platforms,omitzero"`
+ UseCaseIDs []string `json:"use_case_ids,omitzero"`
+ paramObj
+}
+
+func (r APIPerformanceEvaluationConfigUpdateParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformanceEvaluationConfigUpdateParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformanceEvaluationConfigUpdateParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/apiperformanceevaluationconfig_test.go b/apiperformanceevaluationconfig_test.go
new file mode 100644
index 0000000..73b93f7
--- /dev/null
+++ b/apiperformanceevaluationconfig_test.go
@@ -0,0 +1,73 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
+)
+
+func TestAPIPerformanceEvaluationConfigGetWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.EvaluationConfig.Get(context.TODO(), githubcomusesapientgosdk.APIPerformanceEvaluationConfigGetParams{
+ InterfaceID: githubcomusesapientgosdk.String("interface_id"),
+ })
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceEvaluationConfigUpdateWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.EvaluationConfig.Update(context.TODO(), githubcomusesapientgosdk.APIPerformanceEvaluationConfigUpdateParams{
+ APIBaseURL: githubcomusesapientgosdk.String("api_base_url"),
+ EnvVars: map[string]string{
+ "foo": "string",
+ },
+ EvalTypes: []string{"string"},
+ Framework: githubcomusesapientgosdk.String("framework"),
+ InterfaceID: githubcomusesapientgosdk.String("interface_id"),
+ OperationIDs: []string{"string"},
+ Platforms: []string{"string"},
+ UseCaseIDs: []string{"string"},
+ })
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/apiperformanceinterface.go b/apiperformanceinterface.go
new file mode 100644
index 0000000..cdd7df8
--- /dev/null
+++ b/apiperformanceinterface.go
@@ -0,0 +1,81 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformanceInterfaceService contains methods and other services that help
+// with interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceInterfaceService] method instead.
+type APIPerformanceInterfaceService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformanceInterfaceService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewAPIPerformanceInterfaceService(opts ...option.RequestOption) (r APIPerformanceInterfaceService) {
+ r = APIPerformanceInterfaceService{}
+ r.Options = opts
+ return
+}
+
+// List Interfaces
+func (r *APIPerformanceInterfaceService) List(ctx context.Context, opts ...option.RequestOption) (res *APIPerformanceInterfaceListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/interfaces"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+type APIPerformanceInterfaceListResponse struct {
+ Interfaces []APIPerformanceInterfaceListResponseInterface `json:"interfaces" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Interfaces respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceInterfaceListResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceInterfaceListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceInterfaceListResponseInterface struct {
+ ID string `json:"id" api:"required"`
+ Label string `json:"label" api:"required"`
+ Type string `json:"type" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ OperationCount int64 `json:"operation_count"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Label respjson.Field
+ Type respjson.Field
+ CreatedAt respjson.Field
+ OperationCount respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceInterfaceListResponseInterface) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceInterfaceListResponseInterface) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/workflowrun_test.go b/apiperformanceinterface_test.go
similarity index 60%
rename from workflowrun_test.go
rename to apiperformanceinterface_test.go
index cc63054..bc4daa1 100644
--- a/workflowrun_test.go
+++ b/apiperformanceinterface_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestWorkflowRunGet(t *testing.T) {
+func TestAPIPerformanceInterfaceList(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,14 +22,13 @@ func TestWorkflowRunGet(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.WorkflowRuns.Get(context.TODO(), "run_id")
+ _, err := client.APIPerformance.Interfaces.List(context.TODO())
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/apiperformanceoperation.go b/apiperformanceoperation.go
new file mode 100644
index 0000000..46b0984
--- /dev/null
+++ b/apiperformanceoperation.go
@@ -0,0 +1,353 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/apiquery"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformanceOperationService contains methods and other services that help
+// with interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceOperationService] method instead.
+type APIPerformanceOperationService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformanceOperationService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewAPIPerformanceOperationService(opts ...option.RequestOption) (r APIPerformanceOperationService) {
+ r = APIPerformanceOperationService{}
+ r.Options = opts
+ return
+}
+
+// Create Operation
+func (r *APIPerformanceOperationService) New(ctx context.Context, body APIPerformanceOperationNewParams, opts ...option.RequestOption) (res *APIPerformanceOperationNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/operations"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// Retrieve Operation
+func (r *APIPerformanceOperationService) Get(ctx context.Context, operationID string, opts ...option.RequestOption) (res *APIPerformanceOperationGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if operationID == "" {
+ err = errors.New("missing required operation_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/operations/%s", operationID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Update Operation
+func (r *APIPerformanceOperationService) Update(ctx context.Context, operationID string, body APIPerformanceOperationUpdateParams, opts ...option.RequestOption) (res *APIPerformanceOperationUpdateResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if operationID == "" {
+ err = errors.New("missing required operation_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/operations/%s", operationID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
+ return res, err
+}
+
+// List Operations
+func (r *APIPerformanceOperationService) List(ctx context.Context, query APIPerformanceOperationListParams, opts ...option.RequestOption) (res *[]APIPerformanceOperationListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/operations"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ return res, err
+}
+
+// Delete Operation
+func (r *APIPerformanceOperationService) Delete(ctx context.Context, operationID string, opts ...option.RequestOption) (res *APIPerformanceOperationDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if operationID == "" {
+ err = errors.New("missing required operation_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/operations/%s", operationID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+type APIPerformanceOperationNewResponse struct {
+ ID string `json:"id" api:"required"`
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ Category APIPerformanceOperationNewResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ InterfaceID string `json:"interface_id" api:"nullable"`
+ OpenAPIOperationID string `json:"openapi_operation_id" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Method respjson.Field
+ Path respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ InterfaceID respjson.Field
+ OpenAPIOperationID respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationNewResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationNewResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationNewResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationNewResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationGetResponse struct {
+ ID string `json:"id" api:"required"`
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ Category APIPerformanceOperationGetResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ InterfaceID string `json:"interface_id" api:"nullable"`
+ OpenAPIOperationID string `json:"openapi_operation_id" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Method respjson.Field
+ Path respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ InterfaceID respjson.Field
+ OpenAPIOperationID respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationGetResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationGetResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationGetResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationGetResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationUpdateResponse struct {
+ ID string `json:"id" api:"required"`
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ Category APIPerformanceOperationUpdateResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ InterfaceID string `json:"interface_id" api:"nullable"`
+ OpenAPIOperationID string `json:"openapi_operation_id" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Method respjson.Field
+ Path respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ InterfaceID respjson.Field
+ OpenAPIOperationID respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationUpdateResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationUpdateResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationUpdateResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationUpdateResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationUpdateResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationListResponse struct {
+ ID string `json:"id" api:"required"`
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ Category APIPerformanceOperationListResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ InterfaceID string `json:"interface_id" api:"nullable"`
+ OpenAPIOperationID string `json:"openapi_operation_id" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Method respjson.Field
+ Path respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ InterfaceID respjson.Field
+ OpenAPIOperationID respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationListResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationListResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationListResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationListResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationDeleteResponse = any
+
+type APIPerformanceOperationNewParams struct {
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ CategoryName param.Opt[string] `json:"category_name,omitzero"`
+ CategorySlug param.Opt[string] `json:"category_slug,omitzero"`
+ Description param.Opt[string] `json:"description,omitzero"`
+ InterfaceID param.Opt[string] `json:"interface_id,omitzero"`
+ OpenAPIOperationID param.Opt[string] `json:"openapi_operation_id,omitzero"`
+ paramObj
+}
+
+func (r APIPerformanceOperationNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformanceOperationNewParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformanceOperationNewParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationUpdateParams struct {
+ CategoryName param.Opt[string] `json:"category_name,omitzero"`
+ CategorySlug param.Opt[string] `json:"category_slug,omitzero"`
+ Description param.Opt[string] `json:"description,omitzero"`
+ InterfaceID param.Opt[string] `json:"interface_id,omitzero"`
+ Method param.Opt[string] `json:"method,omitzero"`
+ OpenAPIOperationID param.Opt[string] `json:"openapi_operation_id,omitzero"`
+ Path param.Opt[string] `json:"path,omitzero"`
+ paramObj
+}
+
+func (r APIPerformanceOperationUpdateParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformanceOperationUpdateParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformanceOperationUpdateParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationListParams struct {
+ CategoryID param.Opt[string] `query:"category_id,omitzero" json:"-"`
+ InterfaceID param.Opt[string] `query:"interface_id,omitzero" json:"-"`
+ paramObj
+}
+
+// URLQuery serializes [APIPerformanceOperationListParams]'s query parameters as
+// `url.Values`.
+func (r APIPerformanceOperationListParams) URLQuery() (v url.Values, err error) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/apiperformanceoperation_test.go b/apiperformanceoperation_test.go
new file mode 100644
index 0000000..e533f81
--- /dev/null
+++ b/apiperformanceoperation_test.go
@@ -0,0 +1,152 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
+)
+
+func TestAPIPerformanceOperationNewWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.Operations.New(context.TODO(), githubcomusesapientgosdk.APIPerformanceOperationNewParams{
+ Method: "x",
+ Path: "x",
+ CategoryName: githubcomusesapientgosdk.String("category_name"),
+ CategorySlug: githubcomusesapientgosdk.String("category_slug"),
+ Description: githubcomusesapientgosdk.String("description"),
+ InterfaceID: githubcomusesapientgosdk.String("interface_id"),
+ OpenAPIOperationID: githubcomusesapientgosdk.String("openapi_operation_id"),
+ })
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceOperationGet(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.Operations.Get(context.TODO(), "operation_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceOperationUpdateWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.Operations.Update(
+ context.TODO(),
+ "operation_id",
+ githubcomusesapientgosdk.APIPerformanceOperationUpdateParams{
+ CategoryName: githubcomusesapientgosdk.String("category_name"),
+ CategorySlug: githubcomusesapientgosdk.String("category_slug"),
+ Description: githubcomusesapientgosdk.String("description"),
+ InterfaceID: githubcomusesapientgosdk.String("interface_id"),
+ Method: githubcomusesapientgosdk.String("x"),
+ OpenAPIOperationID: githubcomusesapientgosdk.String("openapi_operation_id"),
+ Path: githubcomusesapientgosdk.String("x"),
+ },
+ )
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceOperationListWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.Operations.List(context.TODO(), githubcomusesapientgosdk.APIPerformanceOperationListParams{
+ CategoryID: githubcomusesapientgosdk.String("category_id"),
+ InterfaceID: githubcomusesapientgosdk.String("interface_id"),
+ })
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceOperationDelete(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.Operations.Delete(context.TODO(), "operation_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/apiperformanceoperationprompt.go b/apiperformanceoperationprompt.go
new file mode 100644
index 0000000..02fb1dc
--- /dev/null
+++ b/apiperformanceoperationprompt.go
@@ -0,0 +1,141 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformanceOperationPromptService contains methods and other services that
+// help with interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceOperationPromptService] method instead.
+type APIPerformanceOperationPromptService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformanceOperationPromptService generates a new service that applies the
+// given options to each request. These options are applied after the parent
+// client's options (if there is one), and before any request-specific options.
+func NewAPIPerformanceOperationPromptService(opts ...option.RequestOption) (r APIPerformanceOperationPromptService) {
+ r = APIPerformanceOperationPromptService{}
+ r.Options = opts
+ return
+}
+
+// Create Operation Prompt
+func (r *APIPerformanceOperationPromptService) New(ctx context.Context, operationID string, body APIPerformanceOperationPromptNewParams, opts ...option.RequestOption) (res *APIPerformanceOperationPromptNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if operationID == "" {
+ err = errors.New("missing required operation_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/operations/%s/prompts", operationID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// List Operation Prompts
+func (r *APIPerformanceOperationPromptService) List(ctx context.Context, operationID string, opts ...option.RequestOption) (res *[]APIPerformanceOperationPromptListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if operationID == "" {
+ err = errors.New("missing required operation_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/operations/%s/prompts", operationID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+type APIPerformanceOperationPromptNewResponse struct {
+ ID string `json:"id" api:"required"`
+ EvalType string `json:"eval_type" api:"required"`
+ OperationID string `json:"operation_id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Enabled bool `json:"enabled"`
+ ExpectedBehavior string `json:"expected_behavior" api:"nullable"`
+ Graders []map[string]any `json:"graders"`
+ ReferenceAnswer string `json:"reference_answer" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ EvalType respjson.Field
+ OperationID respjson.Field
+ Prompt respjson.Field
+ CreatedAt respjson.Field
+ Enabled respjson.Field
+ ExpectedBehavior respjson.Field
+ Graders respjson.Field
+ ReferenceAnswer respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationPromptNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationPromptNewResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationPromptListResponse struct {
+ ID string `json:"id" api:"required"`
+ EvalType string `json:"eval_type" api:"required"`
+ OperationID string `json:"operation_id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Enabled bool `json:"enabled"`
+ ExpectedBehavior string `json:"expected_behavior" api:"nullable"`
+ Graders []map[string]any `json:"graders"`
+ ReferenceAnswer string `json:"reference_answer" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ EvalType respjson.Field
+ OperationID respjson.Field
+ Prompt respjson.Field
+ CreatedAt respjson.Field
+ Enabled respjson.Field
+ ExpectedBehavior respjson.Field
+ Graders respjson.Field
+ ReferenceAnswer respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceOperationPromptListResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceOperationPromptListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceOperationPromptNewParams struct {
+ Prompt string `json:"prompt" api:"required"`
+ ExpectedBehavior param.Opt[string] `json:"expected_behavior,omitzero"`
+ ReferenceAnswer param.Opt[string] `json:"reference_answer,omitzero"`
+ EvalType param.Opt[string] `json:"eval_type,omitzero"`
+ Graders []map[string]any `json:"graders,omitzero"`
+ paramObj
+}
+
+func (r APIPerformanceOperationPromptNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformanceOperationPromptNewParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformanceOperationPromptNewParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/apiperformanceoperationprompt_test.go b/apiperformanceoperationprompt_test.go
new file mode 100644
index 0000000..2bad2f2
--- /dev/null
+++ b/apiperformanceoperationprompt_test.go
@@ -0,0 +1,72 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
+)
+
+func TestAPIPerformanceOperationPromptNewWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.OperationPrompts.New(
+ context.TODO(),
+ "operation_id",
+ githubcomusesapientgosdk.APIPerformanceOperationPromptNewParams{
+ Prompt: "x",
+ EvalType: githubcomusesapientgosdk.String("x"),
+ ExpectedBehavior: githubcomusesapientgosdk.String("expected_behavior"),
+ Graders: []map[string]any{{
+ "foo": "bar",
+ }},
+ ReferenceAnswer: githubcomusesapientgosdk.String("reference_answer"),
+ },
+ )
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceOperationPromptList(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.OperationPrompts.List(context.TODO(), "operation_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/apiperformanceplatform.go b/apiperformanceplatform.go
new file mode 100644
index 0000000..5cb2159
--- /dev/null
+++ b/apiperformanceplatform.go
@@ -0,0 +1,158 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformancePlatformService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformancePlatformService] method instead.
+type APIPerformancePlatformService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformancePlatformService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewAPIPerformancePlatformService(opts ...option.RequestOption) (r APIPerformancePlatformService) {
+ r = APIPerformancePlatformService{}
+ r.Options = opts
+ return
+}
+
+// List Platforms
+func (r *APIPerformancePlatformService) List(ctx context.Context, opts ...option.RequestOption) (res *APIPerformancePlatformListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/platforms"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Estimate Platform Cost
+func (r *APIPerformancePlatformService) EstimateCost(ctx context.Context, body APIPerformancePlatformEstimateCostParams, opts ...option.RequestOption) (res *APIPerformancePlatformEstimateCostResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/platforms/estimate-cost"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+type APIPerformancePlatformListResponse struct {
+ AgentPlatforms []APIPerformancePlatformListResponseAgentPlatform `json:"agent_platforms" api:"required"`
+ TextPlatforms []APIPerformancePlatformListResponseTextPlatform `json:"text_platforms" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ AgentPlatforms respjson.Field
+ TextPlatforms respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformancePlatformListResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformancePlatformListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformancePlatformListResponseAgentPlatform struct {
+ ID string `json:"id" api:"required"`
+ Label string `json:"label" api:"required"`
+ Provider string `json:"provider" api:"required"`
+ Type string `json:"type" api:"required"`
+ CostEstimatePerEval float64 `json:"cost_estimate_per_eval" api:"nullable"`
+ CostPer1mInput float64 `json:"cost_per_1m_input" api:"nullable"`
+ CostPer1mOutput float64 `json:"cost_per_1m_output" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Label respjson.Field
+ Provider respjson.Field
+ Type respjson.Field
+ CostEstimatePerEval respjson.Field
+ CostPer1mInput respjson.Field
+ CostPer1mOutput respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformancePlatformListResponseAgentPlatform) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformancePlatformListResponseAgentPlatform) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformancePlatformListResponseTextPlatform struct {
+ ID string `json:"id" api:"required"`
+ Label string `json:"label" api:"required"`
+ Provider string `json:"provider" api:"required"`
+ Type string `json:"type" api:"required"`
+ CostEstimatePerEval float64 `json:"cost_estimate_per_eval" api:"nullable"`
+ CostPer1mInput float64 `json:"cost_per_1m_input" api:"nullable"`
+ CostPer1mOutput float64 `json:"cost_per_1m_output" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Label respjson.Field
+ Provider respjson.Field
+ Type respjson.Field
+ CostEstimatePerEval respjson.Field
+ CostPer1mInput respjson.Field
+ CostPer1mOutput respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformancePlatformListResponseTextPlatform) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformancePlatformListResponseTextPlatform) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformancePlatformEstimateCostResponse struct {
+ Costs map[string]float64 `json:"costs" api:"required"`
+ EvalCount int64 `json:"eval_count" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Costs respjson.Field
+ EvalCount respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformancePlatformEstimateCostResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformancePlatformEstimateCostResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformancePlatformEstimateCostParams struct {
+ EvalCount int64 `json:"eval_count" api:"required"`
+ PlatformIDs []string `json:"platform_ids,omitzero" api:"required"`
+ InputTokens param.Opt[int64] `json:"input_tokens,omitzero"`
+ OutputTokens param.Opt[int64] `json:"output_tokens,omitzero"`
+ paramObj
+}
+
+func (r APIPerformancePlatformEstimateCostParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformancePlatformEstimateCostParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformancePlatformEstimateCostParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/apiapiperformance_test.go b/apiperformanceplatform_test.go
similarity index 53%
rename from apiapiperformance_test.go
rename to apiperformanceplatform_test.go
index 412b59d..909ce8b 100644
--- a/apiapiperformance_test.go
+++ b/apiperformanceplatform_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestAPIAPIPerformanceFailureAnalysisWithOptionalParams(t *testing.T) {
+func TestAPIPerformancePlatformList(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,20 +22,13 @@ func TestAPIAPIPerformanceFailureAnalysisWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.APIPerformance.FailureAnalysis(
- context.TODO(),
- "brand_id",
- sapient.APIAPIPerformanceFailureAnalysisParams{
- IntegrationID: sapient.String("integration_id"),
- },
- )
+ _, err := client.APIPerformance.Platforms.List(context.TODO())
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -43,7 +36,7 @@ func TestAPIAPIPerformanceFailureAnalysisWithOptionalParams(t *testing.T) {
}
}
-func TestAPIAPIPerformanceLatestRunsWithOptionalParams(t *testing.T) {
+func TestAPIPerformancePlatformEstimateCostWithOptionalParams(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -52,20 +45,18 @@ func TestAPIAPIPerformanceLatestRunsWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.APIPerformance.LatestRuns(
- context.TODO(),
- "brand_id",
- sapient.APIAPIPerformanceLatestRunsParams{
- Limit: sapient.Int(1),
- },
- )
+ _, err := client.APIPerformance.Platforms.EstimateCost(context.TODO(), githubcomusesapientgosdk.APIPerformancePlatformEstimateCostParams{
+ EvalCount: 1,
+ PlatformIDs: []string{"string"},
+ InputTokens: githubcomusesapientgosdk.Int(0),
+ OutputTokens: githubcomusesapientgosdk.Int(0),
+ })
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/apiperformanceprompt.go b/apiperformanceprompt.go
new file mode 100644
index 0000000..9f554bc
--- /dev/null
+++ b/apiperformanceprompt.go
@@ -0,0 +1,155 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformancePromptService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformancePromptService] method instead.
+type APIPerformancePromptService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformancePromptService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewAPIPerformancePromptService(opts ...option.RequestOption) (r APIPerformancePromptService) {
+ r = APIPerformancePromptService{}
+ r.Options = opts
+ return
+}
+
+// Retrieve Operation Prompt
+func (r *APIPerformancePromptService) Get(ctx context.Context, promptID string, opts ...option.RequestOption) (res *APIPerformancePromptGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if promptID == "" {
+ err = errors.New("missing required prompt_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/prompts/%s", promptID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Update Operation Prompt
+func (r *APIPerformancePromptService) Update(ctx context.Context, promptID string, body APIPerformancePromptUpdateParams, opts ...option.RequestOption) (res *APIPerformancePromptUpdateResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if promptID == "" {
+ err = errors.New("missing required prompt_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/prompts/%s", promptID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
+ return res, err
+}
+
+// Delete Operation Prompt
+func (r *APIPerformancePromptService) Delete(ctx context.Context, promptID string, opts ...option.RequestOption) (res *APIPerformancePromptDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if promptID == "" {
+ err = errors.New("missing required prompt_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/prompts/%s", promptID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+type APIPerformancePromptGetResponse struct {
+ ID string `json:"id" api:"required"`
+ EvalType string `json:"eval_type" api:"required"`
+ OperationID string `json:"operation_id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Enabled bool `json:"enabled"`
+ ExpectedBehavior string `json:"expected_behavior" api:"nullable"`
+ Graders []map[string]any `json:"graders"`
+ ReferenceAnswer string `json:"reference_answer" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ EvalType respjson.Field
+ OperationID respjson.Field
+ Prompt respjson.Field
+ CreatedAt respjson.Field
+ Enabled respjson.Field
+ ExpectedBehavior respjson.Field
+ Graders respjson.Field
+ ReferenceAnswer respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformancePromptGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformancePromptGetResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformancePromptUpdateResponse struct {
+ ID string `json:"id" api:"required"`
+ EvalType string `json:"eval_type" api:"required"`
+ OperationID string `json:"operation_id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Enabled bool `json:"enabled"`
+ ExpectedBehavior string `json:"expected_behavior" api:"nullable"`
+ Graders []map[string]any `json:"graders"`
+ ReferenceAnswer string `json:"reference_answer" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ EvalType respjson.Field
+ OperationID respjson.Field
+ Prompt respjson.Field
+ CreatedAt respjson.Field
+ Enabled respjson.Field
+ ExpectedBehavior respjson.Field
+ Graders respjson.Field
+ ReferenceAnswer respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformancePromptUpdateResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformancePromptUpdateResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformancePromptDeleteResponse = any
+
+type APIPerformancePromptUpdateParams struct {
+ Enabled param.Opt[bool] `json:"enabled,omitzero"`
+ ExpectedBehavior param.Opt[string] `json:"expected_behavior,omitzero"`
+ Prompt param.Opt[string] `json:"prompt,omitzero"`
+ ReferenceAnswer param.Opt[string] `json:"reference_answer,omitzero"`
+ Graders []map[string]any `json:"graders,omitzero"`
+ paramObj
+}
+
+func (r APIPerformancePromptUpdateParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformancePromptUpdateParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformancePromptUpdateParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/workflow_test.go b/apiperformanceprompt_test.go
similarity index 55%
rename from workflow_test.go
rename to apiperformanceprompt_test.go
index c031d62..bb97b21 100644
--- a/workflow_test.go
+++ b/apiperformanceprompt_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestWorkflowNewWithOptionalParams(t *testing.T) {
+func TestAPIPerformancePromptGet(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,23 +22,13 @@ func TestWorkflowNewWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.Workflows.New(context.TODO(), sapient.WorkflowNewParams{
- Name: "name",
- Description: sapient.String("description"),
- Metadata: map[string]any{
- "foo": "bar",
- },
- Steps: []map[string]any{{
- "foo": "bar",
- }},
- })
+ _, err := client.APIPerformance.Prompts.Get(context.TODO(), "prompt_id")
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -46,7 +36,7 @@ func TestWorkflowNewWithOptionalParams(t *testing.T) {
}
}
-func TestWorkflowGet(t *testing.T) {
+func TestAPIPerformancePromptUpdateWithOptionalParams(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -55,14 +45,25 @@ func TestWorkflowGet(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.Workflows.Get(context.TODO(), "workflow_id")
+ _, err := client.APIPerformance.Prompts.Update(
+ context.TODO(),
+ "prompt_id",
+ githubcomusesapientgosdk.APIPerformancePromptUpdateParams{
+ Enabled: githubcomusesapientgosdk.Bool(true),
+ ExpectedBehavior: githubcomusesapientgosdk.String("expected_behavior"),
+ Graders: []map[string]any{{
+ "foo": "bar",
+ }},
+ Prompt: githubcomusesapientgosdk.String("x"),
+ ReferenceAnswer: githubcomusesapientgosdk.String("reference_answer"),
+ },
+ )
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -70,7 +71,7 @@ func TestWorkflowGet(t *testing.T) {
}
}
-func TestWorkflowRunWithOptionalParams(t *testing.T) {
+func TestAPIPerformancePromptDelete(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -79,24 +80,13 @@ func TestWorkflowRunWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.Workflows.Run(
- context.TODO(),
- "workflow_id",
- sapient.WorkflowRunParams{
- Input: map[string]any{
- "foo": "bar",
- },
- Watch: sapient.Bool(true),
- WorkflowID: sapient.String("workflow_id"),
- },
- )
+ _, err := client.APIPerformance.Prompts.Delete(context.TODO(), "prompt_id")
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/apiperformancerun.go b/apiperformancerun.go
new file mode 100644
index 0000000..9619376
--- /dev/null
+++ b/apiperformancerun.go
@@ -0,0 +1,346 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/apiquery"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformanceRunService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceRunService] method instead.
+type APIPerformanceRunService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformanceRunService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewAPIPerformanceRunService(opts ...option.RequestOption) (r APIPerformanceRunService) {
+ r = APIPerformanceRunService{}
+ r.Options = opts
+ return
+}
+
+// Retrieve Run
+func (r *APIPerformanceRunService) Get(ctx context.Context, runID string, opts ...option.RequestOption) (res *APIPerformanceRunGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if runID == "" {
+ err = errors.New("missing required run_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/runs/%s", runID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// List Operation Runs
+func (r *APIPerformanceRunService) List(ctx context.Context, query APIPerformanceRunListParams, opts ...option.RequestOption) (res *APIPerformanceRunListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/runs"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ return res, err
+}
+
+type APIPerformanceRunGetResponse struct {
+ Data APIPerformanceRunGetResponseData `json:"data" api:"required"`
+ Operation APIPerformanceRunGetResponseOperation `json:"operation" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Data respjson.Field
+ Operation respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunGetResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunGetResponseData struct {
+ ID string `json:"id" api:"required"`
+ APICallLog map[string]any `json:"api_call_log" api:"nullable"`
+ ConversationTurns []map[string]any `json:"conversation_turns" api:"nullable"`
+ CostUsd float64 `json:"cost_usd" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ ErrorMessage string `json:"error_message" api:"nullable"`
+ EvalID string `json:"eval_id" api:"nullable"`
+ EvalType string `json:"eval_type" api:"nullable"`
+ ExecutionStderr string `json:"execution_stderr" api:"nullable"`
+ ExecutionStdout string `json:"execution_stdout" api:"nullable"`
+ ExitCode int64 `json:"exit_code" api:"nullable"`
+ FailureReasons []string `json:"failure_reasons" api:"nullable"`
+ GeneratedFiles map[string]any `json:"generated_files" api:"nullable"`
+ GraderResults map[string]any `json:"grader_results" api:"nullable"`
+ LatencyMs int64 `json:"latency_ms" api:"nullable"`
+ Model string `json:"model" api:"nullable"`
+ ModelType string `json:"model_type" api:"nullable"`
+ Passed bool `json:"passed" api:"nullable"`
+ Platform string `json:"platform" api:"nullable"`
+ Prompt string `json:"prompt" api:"nullable"`
+ RawResponse string `json:"raw_response" api:"nullable"`
+ RunDate string `json:"run_date" api:"nullable"`
+ Score float64 `json:"score" api:"nullable"`
+ TokensUsed int64 `json:"tokens_used" api:"nullable"`
+ ToolCalls []map[string]any `json:"tool_calls" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ APICallLog respjson.Field
+ ConversationTurns respjson.Field
+ CostUsd respjson.Field
+ CreatedAt respjson.Field
+ ErrorMessage respjson.Field
+ EvalID respjson.Field
+ EvalType respjson.Field
+ ExecutionStderr respjson.Field
+ ExecutionStdout respjson.Field
+ ExitCode respjson.Field
+ FailureReasons respjson.Field
+ GeneratedFiles respjson.Field
+ GraderResults respjson.Field
+ LatencyMs respjson.Field
+ Model respjson.Field
+ ModelType respjson.Field
+ Passed respjson.Field
+ Platform respjson.Field
+ Prompt respjson.Field
+ RawResponse respjson.Field
+ RunDate respjson.Field
+ Score respjson.Field
+ TokensUsed respjson.Field
+ ToolCalls respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunGetResponseData) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunGetResponseData) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunGetResponseOperation struct {
+ ID string `json:"id" api:"required"`
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ Category APIPerformanceRunGetResponseOperationCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ InterfaceID string `json:"interface_id" api:"nullable"`
+ OpenAPIOperationID string `json:"openapi_operation_id" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Method respjson.Field
+ Path respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ InterfaceID respjson.Field
+ OpenAPIOperationID respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunGetResponseOperation) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunGetResponseOperation) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunGetResponseOperationCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunGetResponseOperationCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunGetResponseOperationCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunListResponse struct {
+ Data []APIPerformanceRunListResponseData `json:"data" api:"required"`
+ Meta APIPerformanceRunListResponseMeta `json:"meta" api:"required"`
+ Operation APIPerformanceRunListResponseOperation `json:"operation" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Data respjson.Field
+ Meta respjson.Field
+ Operation respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunListResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunListResponseData struct {
+ ID string `json:"id" api:"required"`
+ CostUsd float64 `json:"cost_usd" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ ErrorMessage string `json:"error_message" api:"nullable"`
+ EvalID string `json:"eval_id" api:"nullable"`
+ EvalType string `json:"eval_type" api:"nullable"`
+ FailureReasons []string `json:"failure_reasons" api:"nullable"`
+ LatencyMs int64 `json:"latency_ms" api:"nullable"`
+ Model string `json:"model" api:"nullable"`
+ ModelType string `json:"model_type" api:"nullable"`
+ Passed bool `json:"passed" api:"nullable"`
+ Platform string `json:"platform" api:"nullable"`
+ Prompt string `json:"prompt" api:"nullable"`
+ RawResponse string `json:"raw_response" api:"nullable"`
+ RunDate string `json:"run_date" api:"nullable"`
+ Score float64 `json:"score" api:"nullable"`
+ TokensUsed int64 `json:"tokens_used" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ CostUsd respjson.Field
+ CreatedAt respjson.Field
+ ErrorMessage respjson.Field
+ EvalID respjson.Field
+ EvalType respjson.Field
+ FailureReasons respjson.Field
+ LatencyMs respjson.Field
+ Model respjson.Field
+ ModelType respjson.Field
+ Passed respjson.Field
+ Platform respjson.Field
+ Prompt respjson.Field
+ RawResponse respjson.Field
+ RunDate respjson.Field
+ Score respjson.Field
+ TokensUsed respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunListResponseData) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunListResponseData) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunListResponseMeta struct {
+ Count int64 `json:"count" api:"required"`
+ Limit int64 `json:"limit" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Count respjson.Field
+ Limit respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunListResponseMeta) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunListResponseMeta) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunListResponseOperation struct {
+ ID string `json:"id" api:"required"`
+ Method string `json:"method" api:"required"`
+ Path string `json:"path" api:"required"`
+ Category APIPerformanceRunListResponseOperationCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ InterfaceID string `json:"interface_id" api:"nullable"`
+ OpenAPIOperationID string `json:"openapi_operation_id" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Method respjson.Field
+ Path respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ InterfaceID respjson.Field
+ OpenAPIOperationID respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunListResponseOperation) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunListResponseOperation) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunListResponseOperationCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceRunListResponseOperationCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceRunListResponseOperationCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceRunListParams struct {
+ OperationID string `query:"operation_id" api:"required" json:"-"`
+ IncludeRaw param.Opt[bool] `query:"include_raw,omitzero" json:"-"`
+ Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
+ paramObj
+}
+
+// URLQuery serializes [APIPerformanceRunListParams]'s query parameters as
+// `url.Values`.
+func (r APIPerformanceRunListParams) URLQuery() (v url.Values, err error) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/context_test.go b/apiperformancerun_test.go
similarity index 51%
rename from context_test.go
rename to apiperformancerun_test.go
index d0b2dc1..16241fb 100644
--- a/context_test.go
+++ b/apiperformancerun_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestContextGetCompanyWithOptionalParams(t *testing.T) {
+func TestAPIPerformanceRunGet(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,22 +22,13 @@ func TestContextGetCompanyWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.Context.GetCompany(
- context.TODO(),
- "company",
- sapient.ContextGetCompanyParams{
- For: sapient.String("for"),
- Format: sapient.ContextGetCompanyParamsFormatJson,
- Since: sapient.String("since"),
- },
- )
+ _, err := client.APIPerformance.Runs.Get(context.TODO(), "run_id")
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -45,7 +36,7 @@ func TestContextGetCompanyWithOptionalParams(t *testing.T) {
}
}
-func TestContextCompanyWithOptionalParams(t *testing.T) {
+func TestAPIPerformanceRunListWithOptionalParams(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -54,22 +45,17 @@ func TestContextCompanyWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.Context.Company(
- context.TODO(),
- "company",
- sapient.ContextCompanyParams{
- For: sapient.String("for"),
- Format: sapient.ContextCompanyParamsFormatJson,
- Since: sapient.String("since"),
- },
- )
+ _, err := client.APIPerformance.Runs.List(context.TODO(), githubcomusesapientgosdk.APIPerformanceRunListParams{
+ OperationID: "x",
+ IncludeRaw: githubcomusesapientgosdk.Bool(true),
+ Limit: githubcomusesapientgosdk.Int(1),
+ })
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/apiperformanceusecase.go b/apiperformanceusecase.go
new file mode 100644
index 0000000..e8027d2
--- /dev/null
+++ b/apiperformanceusecase.go
@@ -0,0 +1,304 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// APIPerformanceUseCaseService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAPIPerformanceUseCaseService] method instead.
+type APIPerformanceUseCaseService struct {
+ Options []option.RequestOption
+}
+
+// NewAPIPerformanceUseCaseService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewAPIPerformanceUseCaseService(opts ...option.RequestOption) (r APIPerformanceUseCaseService) {
+ r = APIPerformanceUseCaseService{}
+ r.Options = opts
+ return
+}
+
+// Create Use Case
+func (r *APIPerformanceUseCaseService) New(ctx context.Context, body APIPerformanceUseCaseNewParams, opts ...option.RequestOption) (res *APIPerformanceUseCaseNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/use-cases"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// Retrieve Use Case
+func (r *APIPerformanceUseCaseService) Get(ctx context.Context, useCaseID string, opts ...option.RequestOption) (res *APIPerformanceUseCaseGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if useCaseID == "" {
+ err = errors.New("missing required use_case_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/use-cases/%s", useCaseID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Update Use Case
+func (r *APIPerformanceUseCaseService) Update(ctx context.Context, useCaseID string, body APIPerformanceUseCaseUpdateParams, opts ...option.RequestOption) (res *APIPerformanceUseCaseUpdateResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if useCaseID == "" {
+ err = errors.New("missing required use_case_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/use-cases/%s", useCaseID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
+ return res, err
+}
+
+// List Use Cases
+func (r *APIPerformanceUseCaseService) List(ctx context.Context, opts ...option.RequestOption) (res *[]APIPerformanceUseCaseListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/api-performance/use-cases"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Delete Use Case
+func (r *APIPerformanceUseCaseService) Delete(ctx context.Context, useCaseID string, opts ...option.RequestOption) (res *APIPerformanceUseCaseDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if useCaseID == "" {
+ err = errors.New("missing required use_case_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/api-performance/use-cases/%s", useCaseID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+type APIPerformanceUseCaseNewResponse struct {
+ ID string `json:"id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ Category APIPerformanceUseCaseNewResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Prompt respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseNewResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseNewResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseNewResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseNewResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseGetResponse struct {
+ ID string `json:"id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ Category APIPerformanceUseCaseGetResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Prompt respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseGetResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseGetResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseGetResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseGetResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseUpdateResponse struct {
+ ID string `json:"id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ Category APIPerformanceUseCaseUpdateResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Prompt respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseUpdateResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseUpdateResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseUpdateResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseUpdateResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseUpdateResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseListResponse struct {
+ ID string `json:"id" api:"required"`
+ Prompt string `json:"prompt" api:"required"`
+ Category APIPerformanceUseCaseListResponseCategory `json:"category" api:"nullable"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ Description string `json:"description" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Prompt respjson.Field
+ Category respjson.Field
+ CreatedAt respjson.Field
+ Description respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseListResponse) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseListResponseCategory struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ Slug string `json:"slug" api:"required"`
+ SortOrder int64 `json:"sort_order"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ Slug respjson.Field
+ SortOrder respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r APIPerformanceUseCaseListResponseCategory) RawJSON() string { return r.JSON.raw }
+func (r *APIPerformanceUseCaseListResponseCategory) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseDeleteResponse = any
+
+type APIPerformanceUseCaseNewParams struct {
+ Prompt string `json:"prompt" api:"required"`
+ CategoryName param.Opt[string] `json:"category_name,omitzero"`
+ Description param.Opt[string] `json:"description,omitzero"`
+ paramObj
+}
+
+func (r APIPerformanceUseCaseNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformanceUseCaseNewParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformanceUseCaseNewParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type APIPerformanceUseCaseUpdateParams struct {
+ CategoryName param.Opt[string] `json:"category_name,omitzero"`
+ Description param.Opt[string] `json:"description,omitzero"`
+ Prompt param.Opt[string] `json:"prompt,omitzero"`
+ paramObj
+}
+
+func (r APIPerformanceUseCaseUpdateParams) MarshalJSON() (data []byte, err error) {
+ type shadow APIPerformanceUseCaseUpdateParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *APIPerformanceUseCaseUpdateParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/apiperformanceusecase_test.go b/apiperformanceusecase_test.go
new file mode 100644
index 0000000..0c0493c
--- /dev/null
+++ b/apiperformanceusecase_test.go
@@ -0,0 +1,141 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
+)
+
+func TestAPIPerformanceUseCaseNewWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.UseCases.New(context.TODO(), githubcomusesapientgosdk.APIPerformanceUseCaseNewParams{
+ Prompt: "x",
+ CategoryName: githubcomusesapientgosdk.String("category_name"),
+ Description: githubcomusesapientgosdk.String("description"),
+ })
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceUseCaseGet(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.UseCases.Get(context.TODO(), "use_case_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceUseCaseUpdateWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.UseCases.Update(
+ context.TODO(),
+ "use_case_id",
+ githubcomusesapientgosdk.APIPerformanceUseCaseUpdateParams{
+ CategoryName: githubcomusesapientgosdk.String("category_name"),
+ Description: githubcomusesapientgosdk.String("description"),
+ Prompt: githubcomusesapientgosdk.String("x"),
+ },
+ )
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceUseCaseList(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.UseCases.List(context.TODO())
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAPIPerformanceUseCaseDelete(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.APIPerformance.UseCases.Delete(context.TODO(), "use_case_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/apiprompt.go b/apiprompt.go
deleted file mode 100644
index 7facd5c..0000000
--- a/apiprompt.go
+++ /dev/null
@@ -1,148 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "net/http"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
-)
-
-// APIPromptService contains methods and other services that help with interacting
-// with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewAPIPromptService] method instead.
-type APIPromptService struct {
- options []option.RequestOption
-}
-
-// NewAPIPromptService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewAPIPromptService(opts ...option.RequestOption) (r APIPromptService) {
- r = APIPromptService{}
- r.options = opts
- return
-}
-
-// Create Prompt Batch
-func (r *APIPromptService) NewBatch(ctx context.Context, body APIPromptNewBatchParams, opts ...option.RequestOption) (res *APIPromptNewBatchResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/api/prompts/batch"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-// Create Prompt Batch
-func (r *APIPromptService) Batch(ctx context.Context, body APIPromptBatchParams, opts ...option.RequestOption) (res *APIPromptBatchResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/api/prompts/batch"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type APIPromptNewBatchResponse struct {
- Count int64 `json:"count" api:"required"`
- Created []map[string]any `json:"created" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Count respjson.Field
- Created respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r APIPromptNewBatchResponse) RawJSON() string { return r.JSON.raw }
-func (r *APIPromptNewBatchResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type APIPromptBatchResponse struct {
- Count int64 `json:"count" api:"required"`
- Created []map[string]any `json:"created" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Count respjson.Field
- Created respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r APIPromptBatchResponse) RawJSON() string { return r.JSON.raw }
-func (r *APIPromptBatchResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type APIPromptNewBatchParams struct {
- Prompts []APIPromptNewBatchParamsPrompt `json:"prompts,omitzero" api:"required"`
- paramObj
-}
-
-func (r APIPromptNewBatchParams) MarshalJSON() (data []byte, err error) {
- type shadow APIPromptNewBatchParams
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *APIPromptNewBatchParams) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-// The properties LanguageID, RegionID, Text, TopicID are required.
-type APIPromptNewBatchParamsPrompt struct {
- LanguageID string `json:"language_id" api:"required"`
- RegionID string `json:"region_id" api:"required"`
- Text string `json:"text" api:"required"`
- TopicID string `json:"topic_id" api:"required"`
- PlatformIDs []string `json:"platform_ids,omitzero"`
- paramObj
-}
-
-func (r APIPromptNewBatchParamsPrompt) MarshalJSON() (data []byte, err error) {
- type shadow APIPromptNewBatchParamsPrompt
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *APIPromptNewBatchParamsPrompt) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type APIPromptBatchParams struct {
- Prompts []APIPromptBatchParamsPrompt `json:"prompts,omitzero" api:"required"`
- paramObj
-}
-
-func (r APIPromptBatchParams) MarshalJSON() (data []byte, err error) {
- type shadow APIPromptBatchParams
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *APIPromptBatchParams) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-// The properties LanguageID, RegionID, Text, TopicID are required.
-type APIPromptBatchParamsPrompt struct {
- LanguageID string `json:"language_id" api:"required"`
- RegionID string `json:"region_id" api:"required"`
- Text string `json:"text" api:"required"`
- TopicID string `json:"topic_id" api:"required"`
- PlatformIDs []string `json:"platform_ids,omitzero"`
- paramObj
-}
-
-func (r APIPromptBatchParamsPrompt) MarshalJSON() (data []byte, err error) {
- type shadow APIPromptBatchParamsPrompt
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *APIPromptBatchParamsPrompt) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
diff --git a/apiprompt_test.go b/apiprompt_test.go
deleted file mode 100644
index 73bc8e5..0000000
--- a/apiprompt_test.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
-)
-
-func TestAPIPromptNewBatch(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.API.Prompts.NewBatch(context.TODO(), sapient.APIPromptNewBatchParams{
- Prompts: []sapient.APIPromptNewBatchParamsPrompt{{
- LanguageID: "language_id",
- RegionID: "region_id",
- Text: "text",
- TopicID: "topic_id",
- PlatformIDs: []string{"string"},
- }},
- })
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestAPIPromptBatch(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.API.Prompts.Batch(context.TODO(), sapient.APIPromptBatchParams{
- Prompts: []sapient.APIPromptBatchParamsPrompt{{
- LanguageID: "language_id",
- RegionID: "region_id",
- Text: "text",
- TopicID: "topic_id",
- PlatformIDs: []string{"string"},
- }},
- })
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/auth.go b/auth.go
index 0a90365..4c71b21 100644
--- a/auth.go
+++ b/auth.go
@@ -1,24 +1,24 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient
+package githubcomusesapientgosdk
import (
"context"
"net/http"
"slices"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
)
// AuthService contains methods and other services that help with interacting with
-// the sapient API.
+// the Sapient API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewAuthService] method instead.
type AuthService struct {
- options []option.RequestOption
+ Options []option.RequestOption
}
// NewAuthService generates a new service that applies the given options to each
@@ -26,26 +26,16 @@ type AuthService struct {
// is one), and before any request-specific options.
func NewAuthService(opts ...option.RequestOption) (r AuthService) {
r = AuthService{}
- r.options = opts
+ r.Options = opts
return
}
-// Get Auth Status
-func (r *AuthService) GetStatus(ctx context.Context, opts ...option.RequestOption) (res *AuthGetStatusResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/auth/status"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
// Get Auth Status
func (r *AuthService) Status(ctx context.Context, opts ...option.RequestOption) (res *AuthStatusResponse, err error) {
- opts = slices.Concat(r.options, opts)
+ opts = slices.Concat(r.Options, opts)
path := "v1/auth/status"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
-type AuthGetStatusResponse = any
-
type AuthStatusResponse = any
diff --git a/auth_test.go b/auth_test.go
index 79ea940..c91ffa4 100644
--- a/auth_test.go
+++ b/auth_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,35 +8,11 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestAuthGetStatus(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Auth.GetStatus(context.TODO())
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
func TestAuthStatus(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
@@ -46,14 +22,13 @@ func TestAuthStatus(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
_, err := client.Auth.Status(context.TODO())
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/client.go b/client.go
index d8bb014..b05c933 100644
--- a/client.go
+++ b/client.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient
+package githubcomusesapientgosdk
import (
"context"
@@ -9,36 +9,28 @@ import (
"slices"
"strings"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
)
// Client creates a struct with services and top level methods that help with
-// interacting with the sapient API. You should not instantiate this client
+// interacting with the Sapient API. You should not instantiate this client
// directly, and instead use the [NewClient] method instead.
type Client struct {
- options []option.RequestOption
- Status StatusService
- Auth AuthService
- Context ContextService
- EvalRuns EvalRunService
- Prompts PromptService
- Workflows WorkflowService
- WorkflowRuns WorkflowRunService
- API APIService
+ Options []option.RequestOption
+ Status StatusService
+ Auth AuthService
+ Prompts PromptService
+ APIPerformance APIPerformanceService
}
// DefaultClientOptions read from the environment (SAPIENT_API_KEY,
-// SAPIENT_BEARER_TOKEN, SAPIENT_BASE_URL). This should be used to initialize new
-// clients.
+// SAPIENT_BASE_URL). This should be used to initialize new clients.
func DefaultClientOptions() []option.RequestOption {
defaults := []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()}
if o, ok := os.LookupEnv("SAPIENT_BASE_URL"); ok {
defaults = append(defaults, option.WithBaseURL(o))
}
- if o, ok := os.LookupEnv("SAPIENT_BEARER_TOKEN"); ok {
- defaults = append(defaults, option.WithBearerToken(o))
- }
if o, ok := os.LookupEnv("SAPIENT_API_KEY"); ok {
defaults = append(defaults, option.WithAPIKey(o))
}
@@ -54,22 +46,18 @@ func DefaultClientOptions() []option.RequestOption {
}
// NewClient generates a new client with the default option read from the
-// environment (SAPIENT_API_KEY, SAPIENT_BEARER_TOKEN, SAPIENT_BASE_URL). The
-// option passed in as arguments are applied after these default arguments, and all
-// option will be passed down to the services and requests that this client makes.
+// environment (SAPIENT_API_KEY, SAPIENT_BASE_URL). The option passed in as
+// arguments are applied after these default arguments, and all option will be
+// passed down to the services and requests that this client makes.
func NewClient(opts ...option.RequestOption) (r Client) {
opts = append(DefaultClientOptions(), opts...)
- r = Client{options: opts}
+ r = Client{Options: opts}
r.Status = NewStatusService(opts...)
r.Auth = NewAuthService(opts...)
- r.Context = NewContextService(opts...)
- r.EvalRuns = NewEvalRunService(opts...)
r.Prompts = NewPromptService(opts...)
- r.Workflows = NewWorkflowService(opts...)
- r.WorkflowRuns = NewWorkflowRunService(opts...)
- r.API = NewAPIService(opts...)
+ r.APIPerformance = NewAPIPerformanceService(opts...)
return
}
@@ -106,7 +94,7 @@ func NewClient(opts ...option.RequestOption) (r Client) {
// For even greater flexibility, see [option.WithResponseInto] and
// [option.WithResponseBodyInto].
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error {
- opts = slices.Concat(r.options, opts)
+ opts = slices.Concat(r.Options, opts)
return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...)
}
diff --git a/client_test.go b/client_test.go
index 8e7f0c1..a93667b 100644
--- a/client_test.go
+++ b/client_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -10,9 +10,9 @@ import (
"testing"
"time"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal"
+ "github.com/usesapient/go-sdk/option"
)
type closureTransport struct {
@@ -25,7 +25,7 @@ func (t *closureTransport) RoundTrip(req *http.Request) (*http.Response, error)
func TestUserAgentHeader(t *testing.T) {
var userAgent string
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -46,7 +46,7 @@ func TestUserAgentHeader(t *testing.T) {
func TestRetryAfter(t *testing.T) {
retryCountHeaders := make([]string, 0)
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -80,7 +80,7 @@ func TestRetryAfter(t *testing.T) {
func TestDeleteRetryCountHeader(t *testing.T) {
retryCountHeaders := make([]string, 0)
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -110,7 +110,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
func TestOverwriteRetryCountHeader(t *testing.T) {
retryCountHeaders := make([]string, 0)
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -140,7 +140,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
func TestRetryAfterMs(t *testing.T) {
attempts := 0
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -166,7 +166,7 @@ func TestRetryAfterMs(t *testing.T) {
}
func TestContextCancel(t *testing.T) {
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -186,7 +186,7 @@ func TestContextCancel(t *testing.T) {
}
func TestContextCancelDelay(t *testing.T) {
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
@@ -214,7 +214,7 @@ func TestContextDeadline(t *testing.T) {
defer cancel()
go func() {
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"),
option.WithHTTPClient(&http.Client{
Transport: &closureTransport{
diff --git a/context.go b/context.go
deleted file mode 100644
index 82077bf..0000000
--- a/context.go
+++ /dev/null
@@ -1,312 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
-)
-
-// ContextService contains methods and other services that help with interacting
-// with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewContextService] method instead.
-type ContextService struct {
- options []option.RequestOption
-}
-
-// NewContextService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewContextService(opts ...option.RequestOption) (r ContextService) {
- r = ContextService{}
- r.options = opts
- return
-}
-
-// Get Company Context
-func (r *ContextService) GetCompany(ctx context.Context, company string, query ContextGetCompanyParams, opts ...option.RequestOption) (res *ContextGetCompanyResponse, err error) {
- opts = slices.Concat(r.options, opts)
- if company == "" {
- err = errors.New("missing required company parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/context/company/%s", url.PathEscape(company))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// Get Company Context
-func (r *ContextService) Company(ctx context.Context, company string, query ContextCompanyParams, opts ...option.RequestOption) (res *ContextCompanyResponse, err error) {
- opts = slices.Concat(r.options, opts)
- if company == "" {
- err = errors.New("missing required company parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/context/company/%s", url.PathEscape(company))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type EvalRunSummary struct {
- ID string `json:"id" api:"required"`
- Endpoint EvalRunSummaryEndpointUnion `json:"endpoint" api:"nullable"`
- EvalType string `json:"eval_type" api:"nullable"`
- FailureReasons []string `json:"failure_reasons" api:"nullable"`
- LatencyMs int64 `json:"latency_ms" api:"nullable"`
- Model string `json:"model" api:"nullable"`
- ModelType string `json:"model_type" api:"nullable"`
- Passed bool `json:"passed" api:"nullable"`
- Platform string `json:"platform" api:"nullable"`
- RunAt string `json:"run_at" api:"nullable"`
- Score float64 `json:"score" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- ID respjson.Field
- Endpoint respjson.Field
- EvalType respjson.Field
- FailureReasons respjson.Field
- LatencyMs respjson.Field
- Model respjson.Field
- ModelType respjson.Field
- Passed respjson.Field
- Platform respjson.Field
- RunAt respjson.Field
- Score respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r EvalRunSummary) RawJSON() string { return r.JSON.raw }
-func (r *EvalRunSummary) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-// EvalRunSummaryEndpointUnion contains all possible properties and values from
-// [PublicEndpoint], [map[string]any].
-//
-// Use the methods beginning with 'As' to cast the union to one of its variants.
-//
-// If the underlying value is not a json object, one of the following properties
-// will be valid: OfEvalRunSummaryEndpointMapItem]
-type EvalRunSummaryEndpointUnion struct {
- // This field will be present if the value is a [any] instead of an object.
- OfEvalRunSummaryEndpointMapItem any `json:",inline"`
- // This field is from variant [PublicEndpoint].
- ID string `json:"id"`
- // This field is from variant [PublicEndpoint].
- Category map[string]any `json:"category"`
- // This field is from variant [PublicEndpoint].
- Description string `json:"description"`
- // This field is from variant [PublicEndpoint].
- Method string `json:"method"`
- // This field is from variant [PublicEndpoint].
- Path string `json:"path"`
- JSON struct {
- OfEvalRunSummaryEndpointMapItem respjson.Field
- ID respjson.Field
- Category respjson.Field
- Description respjson.Field
- Method respjson.Field
- Path respjson.Field
- raw string
- } `json:"-"`
-}
-
-func (u EvalRunSummaryEndpointUnion) AsPublicEndpoint() (v PublicEndpoint) {
- apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
- return
-}
-
-func (u EvalRunSummaryEndpointUnion) AsAnyMap() (v map[string]any) {
- apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
- return
-}
-
-// Returns the unmodified JSON received from the API
-func (u EvalRunSummaryEndpointUnion) RawJSON() string { return u.JSON.raw }
-
-func (r *EvalRunSummaryEndpointUnion) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type PublicCompany struct {
- // Sapient brand ID.
- BrandID string `json:"brand_id" api:"required"`
- Name string `json:"name" api:"required"`
- Domain string `json:"domain" api:"nullable"`
- LogoURL string `json:"logo_url" api:"nullable"`
- // Organization-scoped brand relationship ID.
- OrgBrandID string `json:"org_brand_id" api:"nullable"`
- Relationship string `json:"relationship" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- BrandID respjson.Field
- Name respjson.Field
- Domain respjson.Field
- LogoURL respjson.Field
- OrgBrandID respjson.Field
- Relationship respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r PublicCompany) RawJSON() string { return r.JSON.raw }
-func (r *PublicCompany) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type PublicEndpoint struct {
- ID string `json:"id" api:"required"`
- Category map[string]any `json:"category" api:"nullable"`
- Description string `json:"description" api:"nullable"`
- Method string `json:"method" api:"nullable"`
- Path string `json:"path" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- ID respjson.Field
- Category respjson.Field
- Description respjson.Field
- Method respjson.Field
- Path respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r PublicEndpoint) RawJSON() string { return r.JSON.raw }
-func (r *PublicEndpoint) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type ContextGetCompanyResponse struct {
- Company PublicCompany `json:"company" api:"required"`
- Endpoints []PublicEndpoint `json:"endpoints"`
- FailureAnalysis FailureAnalysisSnapshot `json:"failure_analysis" api:"nullable"`
- LatestRuns []EvalRunSummary `json:"latest_runs"`
- Markdown string `json:"markdown" api:"nullable"`
- // Requested context use case.
- Purpose string `json:"purpose" api:"nullable"`
- // Requested lookback window.
- Since string `json:"since" api:"nullable"`
- Summary map[string]any `json:"summary"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Company respjson.Field
- Endpoints respjson.Field
- FailureAnalysis respjson.Field
- LatestRuns respjson.Field
- Markdown respjson.Field
- Purpose respjson.Field
- Since respjson.Field
- Summary respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r ContextGetCompanyResponse) RawJSON() string { return r.JSON.raw }
-func (r *ContextGetCompanyResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type ContextCompanyResponse struct {
- Company PublicCompany `json:"company" api:"required"`
- Endpoints []PublicEndpoint `json:"endpoints"`
- FailureAnalysis FailureAnalysisSnapshot `json:"failure_analysis" api:"nullable"`
- LatestRuns []EvalRunSummary `json:"latest_runs"`
- Markdown string `json:"markdown" api:"nullable"`
- // Requested context use case.
- Purpose string `json:"purpose" api:"nullable"`
- // Requested lookback window.
- Since string `json:"since" api:"nullable"`
- Summary map[string]any `json:"summary"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Company respjson.Field
- Endpoints respjson.Field
- FailureAnalysis respjson.Field
- LatestRuns respjson.Field
- Markdown respjson.Field
- Purpose respjson.Field
- Since respjson.Field
- Summary respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r ContextCompanyResponse) RawJSON() string { return r.JSON.raw }
-func (r *ContextCompanyResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type ContextGetCompanyParams struct {
- For param.Opt[string] `query:"for,omitzero" json:"-"`
- Since param.Opt[string] `query:"since,omitzero" json:"-"`
- // Any of "json", "markdown", "md".
- Format ContextGetCompanyParamsFormat `query:"format,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [ContextGetCompanyParams]'s query parameters as
-// `url.Values`.
-func (r ContextGetCompanyParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type ContextGetCompanyParamsFormat string
-
-const (
- ContextGetCompanyParamsFormatJson ContextGetCompanyParamsFormat = "json"
- ContextGetCompanyParamsFormatMarkdown ContextGetCompanyParamsFormat = "markdown"
- ContextGetCompanyParamsFormatMd ContextGetCompanyParamsFormat = "md"
-)
-
-type ContextCompanyParams struct {
- For param.Opt[string] `query:"for,omitzero" json:"-"`
- Since param.Opt[string] `query:"since,omitzero" json:"-"`
- // Any of "json", "markdown", "md".
- Format ContextCompanyParamsFormat `query:"format,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [ContextCompanyParams]'s query parameters as `url.Values`.
-func (r ContextCompanyParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type ContextCompanyParamsFormat string
-
-const (
- ContextCompanyParamsFormatJson ContextCompanyParamsFormat = "json"
- ContextCompanyParamsFormatMarkdown ContextCompanyParamsFormat = "markdown"
- ContextCompanyParamsFormatMd ContextCompanyParamsFormat = "md"
-)
diff --git a/default_http_client.go b/default_http_client.go
index 86056ef..e519c0c 100644
--- a/default_http_client.go
+++ b/default_http_client.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient
+package githubcomusesapientgosdk
import (
"net/http"
@@ -14,11 +14,17 @@ import (
const defaultResponseHeaderTimeout = 10 * time.Minute
// defaultHTTPClient returns an [*http.Client] used when the caller does not
-// supply one via [option.WithHTTPClient]. It clones [http.DefaultTransport]
-// and adds a [http.Transport.ResponseHeaderTimeout] so stuck connections
-// fail fast instead of compounding across retries.
+// supply one via [option.WithHTTPClient]. When [http.DefaultTransport] is the
+// stdlib [*http.Transport], it is cloned and a [http.Transport.ResponseHeaderTimeout]
+// is set so stuck connections fail fast instead of compounding across retries.
+// If [http.DefaultTransport] has been wrapped (for example by otelhttp for
+// distributed tracing), the wrapping is preserved and the header timeout is
+// skipped.
func defaultHTTPClient() *http.Client {
- transport := http.DefaultTransport.(*http.Transport).Clone()
- transport.ResponseHeaderTimeout = defaultResponseHeaderTimeout
- return &http.Client{Transport: transport}
+ if t, ok := http.DefaultTransport.(*http.Transport); ok {
+ t = t.Clone()
+ t.ResponseHeaderTimeout = defaultResponseHeaderTimeout
+ return &http.Client{Transport: t}
+ }
+ return &http.Client{Transport: http.DefaultTransport}
}
diff --git a/evalrun.go b/evalrun.go
deleted file mode 100644
index e1b4b93..0000000
--- a/evalrun.go
+++ /dev/null
@@ -1,319 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
-)
-
-// EvalRunService contains methods and other services that help with interacting
-// with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewEvalRunService] method instead.
-type EvalRunService struct {
- options []option.RequestOption
-}
-
-// NewEvalRunService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewEvalRunService(opts ...option.RequestOption) (r EvalRunService) {
- r = EvalRunService{}
- r.options = opts
- return
-}
-
-// Retrieve Eval Run
-func (r *EvalRunService) Get(ctx context.Context, runID string, opts ...option.RequestOption) (res *EvalRunGetResponse, err error) {
- opts = slices.Concat(r.options, opts)
- if runID == "" {
- err = errors.New("missing required run_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/eval-runs/%s", url.PathEscape(runID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-// List Eval Runs
-func (r *EvalRunService) List(ctx context.Context, query EvalRunListParams, opts ...option.RequestOption) (res *EvalRunListResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/eval-runs"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// Diagnose Eval Runs
-func (r *EvalRunService) Diagnose(ctx context.Context, body EvalRunDiagnoseParams, opts ...option.RequestOption) (res *EvalRunDiagnoseResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/eval-runs/diagnose"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type EvalRunDetail struct {
- ID string `json:"id" api:"required"`
- Endpoint EvalRunDetailEndpointUnion `json:"endpoint" api:"nullable"`
- EvalType string `json:"eval_type" api:"nullable"`
- ExecutionStderr string `json:"execution_stderr" api:"nullable"`
- ExecutionStdout string `json:"execution_stdout" api:"nullable"`
- ExitCode int64 `json:"exit_code" api:"nullable"`
- FailureReasons []string `json:"failure_reasons" api:"nullable"`
- LatencyMs int64 `json:"latency_ms" api:"nullable"`
- Model string `json:"model" api:"nullable"`
- ModelType string `json:"model_type" api:"nullable"`
- Passed bool `json:"passed" api:"nullable"`
- Platform string `json:"platform" api:"nullable"`
- PromptSent string `json:"prompt_sent" api:"nullable"`
- Raw map[string]any `json:"raw" api:"nullable"`
- ResponseText string `json:"response_text" api:"nullable"`
- RunAt string `json:"run_at" api:"nullable"`
- Score float64 `json:"score" api:"nullable"`
- ToolCalls []map[string]any `json:"tool_calls" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- ID respjson.Field
- Endpoint respjson.Field
- EvalType respjson.Field
- ExecutionStderr respjson.Field
- ExecutionStdout respjson.Field
- ExitCode respjson.Field
- FailureReasons respjson.Field
- LatencyMs respjson.Field
- Model respjson.Field
- ModelType respjson.Field
- Passed respjson.Field
- Platform respjson.Field
- PromptSent respjson.Field
- Raw respjson.Field
- ResponseText respjson.Field
- RunAt respjson.Field
- Score respjson.Field
- ToolCalls respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r EvalRunDetail) RawJSON() string { return r.JSON.raw }
-func (r *EvalRunDetail) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-// EvalRunDetailEndpointUnion contains all possible properties and values from
-// [PublicEndpoint], [map[string]any].
-//
-// Use the methods beginning with 'As' to cast the union to one of its variants.
-//
-// If the underlying value is not a json object, one of the following properties
-// will be valid: OfEvalRunDetailEndpointMapItem]
-type EvalRunDetailEndpointUnion struct {
- // This field will be present if the value is a [any] instead of an object.
- OfEvalRunDetailEndpointMapItem any `json:",inline"`
- // This field is from variant [PublicEndpoint].
- ID string `json:"id"`
- // This field is from variant [PublicEndpoint].
- Category map[string]any `json:"category"`
- // This field is from variant [PublicEndpoint].
- Description string `json:"description"`
- // This field is from variant [PublicEndpoint].
- Method string `json:"method"`
- // This field is from variant [PublicEndpoint].
- Path string `json:"path"`
- JSON struct {
- OfEvalRunDetailEndpointMapItem respjson.Field
- ID respjson.Field
- Category respjson.Field
- Description respjson.Field
- Method respjson.Field
- Path respjson.Field
- raw string
- } `json:"-"`
-}
-
-func (u EvalRunDetailEndpointUnion) AsPublicEndpoint() (v PublicEndpoint) {
- apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
- return
-}
-
-func (u EvalRunDetailEndpointUnion) AsAnyMap() (v map[string]any) {
- apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
- return
-}
-
-// Returns the unmodified JSON received from the API
-func (u EvalRunDetailEndpointUnion) RawJSON() string { return u.JSON.raw }
-
-func (r *EvalRunDetailEndpointUnion) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type PublicListMeta struct {
- Count int64 `json:"count" api:"required"`
- Limit int64 `json:"limit" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Count respjson.Field
- Limit respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r PublicListMeta) RawJSON() string { return r.JSON.raw }
-func (r *PublicListMeta) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type EvalRunGetResponse struct {
- Data EvalRunDetail `json:"data" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Data respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r EvalRunGetResponse) RawJSON() string { return r.JSON.raw }
-func (r *EvalRunGetResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type EvalRunListResponse struct {
- Company PublicCompany `json:"company" api:"required"`
- Data []EvalRunSummary `json:"data" api:"required"`
- Meta PublicListMeta `json:"meta" api:"required"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Company respjson.Field
- Data respjson.Field
- Meta respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r EvalRunListResponse) RawJSON() string { return r.JSON.raw }
-func (r *EvalRunListResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type EvalRunDiagnoseResponse struct {
- Company PublicCompany `json:"company" api:"required"`
- FailureAnalysis FailureAnalysisSnapshot `json:"failure_analysis" api:"required"`
- Since string `json:"since" api:"required"`
- Summary EvalRunDiagnoseResponseSummary `json:"summary" api:"required"`
- Examples []EvalRunDetail `json:"examples"`
- Markdown string `json:"markdown" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- Company respjson.Field
- FailureAnalysis respjson.Field
- Since respjson.Field
- Summary respjson.Field
- Examples respjson.Field
- Markdown respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r EvalRunDiagnoseResponse) RawJSON() string { return r.JSON.raw }
-func (r *EvalRunDiagnoseResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type EvalRunDiagnoseResponseSummary struct {
- FailedRuns int64 `json:"failed_runs"`
- FailureRate float64 `json:"failure_rate" api:"nullable"`
- PassedRuns int64 `json:"passed_runs"`
- TopFailedEndpoints []map[string]any `json:"top_failed_endpoints"`
- TopFailedModels []map[string]any `json:"top_failed_models"`
- TopFailureReasons []map[string]any `json:"top_failure_reasons"`
- TotalRuns int64 `json:"total_runs"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- FailedRuns respjson.Field
- FailureRate respjson.Field
- PassedRuns respjson.Field
- TopFailedEndpoints respjson.Field
- TopFailedModels respjson.Field
- TopFailureReasons respjson.Field
- TotalRuns respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r EvalRunDiagnoseResponseSummary) RawJSON() string { return r.JSON.raw }
-func (r *EvalRunDiagnoseResponseSummary) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type EvalRunListParams struct {
- Company string `query:"company" api:"required" json:"-"`
- Since param.Opt[string] `query:"since,omitzero" json:"-"`
- Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
- paramObj
-}
-
-// URLQuery serializes [EvalRunListParams]'s query parameters as `url.Values`.
-func (r EvalRunListParams) URLQuery() (v url.Values, err error) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type EvalRunDiagnoseParams struct {
- // Company name, domain, brand ID, or org brand ID.
- Company string `json:"company" api:"required"`
- IncludeExamples param.Opt[bool] `json:"include_examples,omitzero"`
- MaxExamples param.Opt[int64] `json:"max_examples,omitzero"`
- // Lookback window, such as 20d, 72h, or an ISO timestamp.
- Since param.Opt[string] `json:"since,omitzero"`
- // Report format to include in the response.
- //
- // Any of "json", "markdown", "md".
- Format EvalRunDiagnoseParamsFormat `json:"format,omitzero"`
- paramObj
-}
-
-func (r EvalRunDiagnoseParams) MarshalJSON() (data []byte, err error) {
- type shadow EvalRunDiagnoseParams
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *EvalRunDiagnoseParams) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-// Report format to include in the response.
-type EvalRunDiagnoseParamsFormat string
-
-const (
- EvalRunDiagnoseParamsFormatJson EvalRunDiagnoseParamsFormat = "json"
- EvalRunDiagnoseParamsFormatMarkdown EvalRunDiagnoseParamsFormat = "markdown"
- EvalRunDiagnoseParamsFormatMd EvalRunDiagnoseParamsFormat = "md"
-)
diff --git a/evalrun_test.go b/evalrun_test.go
deleted file mode 100644
index 142d414..0000000
--- a/evalrun_test.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
-)
-
-func TestEvalRunGet(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.EvalRuns.Get(context.TODO(), "run_id")
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestEvalRunListWithOptionalParams(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.EvalRuns.List(context.TODO(), sapient.EvalRunListParams{
- Company: "company",
- Limit: sapient.Int(1),
- Since: sapient.String("since"),
- })
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestEvalRunDiagnoseWithOptionalParams(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.EvalRuns.Diagnose(context.TODO(), sapient.EvalRunDiagnoseParams{
- Company: "company",
- Format: sapient.EvalRunDiagnoseParamsFormatJson,
- IncludeExamples: sapient.Bool(true),
- MaxExamples: sapient.Int(1),
- Since: sapient.String("since"),
- })
- if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/field.go b/field.go
index 4dd7bcd..5ca907f 100644
--- a/field.go
+++ b/field.go
@@ -1,7 +1,7 @@
-package sapient
+package githubcomusesapientgosdk
import (
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"io"
"time"
)
diff --git a/go.mod b/go.mod
index a8debe4..8f220aa 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/stainless-sdks/sapient-go
+module github.com/usesapient/go-sdk
go 1.22
diff --git a/internal/apierror/apierror.go b/internal/apierror/apierror.go
index bcccb8f..f1a4b77 100644
--- a/internal/apierror/apierror.go
+++ b/internal/apierror/apierror.go
@@ -7,8 +7,8 @@ import (
"net/http"
"net/http/httputil"
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/packages/respjson"
)
// Error represents an error that originates from the API, i.e. when a request is
diff --git a/internal/apiform/encoder.go b/internal/apiform/encoder.go
index f47ed6d..cd09845 100644
--- a/internal/apiform/encoder.go
+++ b/internal/apiform/encoder.go
@@ -13,7 +13,7 @@ import (
"sync"
"time"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
)
var encoders sync.Map // map[encoderEntry]encoderFunc
diff --git a/internal/apiform/form_test.go b/internal/apiform/form_test.go
index 77d3ec9..4f8b635 100644
--- a/internal/apiform/form_test.go
+++ b/internal/apiform/form_test.go
@@ -2,7 +2,7 @@ package apiform
import (
"bytes"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"io"
"mime/multipart"
"strings"
diff --git a/internal/apiform/richparam.go b/internal/apiform/richparam.go
index df4c9f9..97940be 100644
--- a/internal/apiform/richparam.go
+++ b/internal/apiform/richparam.go
@@ -1,7 +1,7 @@
package apiform
import (
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"mime/multipart"
"reflect"
)
diff --git a/internal/apijson/decodeparam_test.go b/internal/apijson/decodeparam_test.go
index 2672c0d..32d5c0f 100644
--- a/internal/apijson/decodeparam_test.go
+++ b/internal/apijson/decodeparam_test.go
@@ -3,8 +3,8 @@ package apijson_test
import (
"encoding/json"
"fmt"
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/packages/param"
"reflect"
"testing"
)
diff --git a/internal/apijson/decoder.go b/internal/apijson/decoder.go
index 9db8e70..41d0c12 100644
--- a/internal/apijson/decoder.go
+++ b/internal/apijson/decoder.go
@@ -7,7 +7,7 @@ package apijson
import (
"encoding/json"
"fmt"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"reflect"
"strconv"
"sync"
diff --git a/internal/apijson/decoderesp_test.go b/internal/apijson/decoderesp_test.go
index 737896c..049c728 100644
--- a/internal/apijson/decoderesp_test.go
+++ b/internal/apijson/decoderesp_test.go
@@ -2,8 +2,8 @@ package apijson_test
import (
"encoding/json"
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/packages/respjson"
"testing"
)
diff --git a/internal/apijson/encoder.go b/internal/apijson/encoder.go
index 4ecddf8..9d7be51 100644
--- a/internal/apijson/encoder.go
+++ b/internal/apijson/encoder.go
@@ -13,7 +13,7 @@ import (
"github.com/tidwall/sjson"
- shimjson "github.com/stainless-sdks/sapient-go/internal/encoding/json"
+ shimjson "github.com/usesapient/go-sdk/internal/encoding/json"
)
var encoders sync.Map // map[encoderEntry]encoderFunc
diff --git a/internal/apijson/subfield.go b/internal/apijson/subfield.go
index 34c50b2..7a47855 100644
--- a/internal/apijson/subfield.go
+++ b/internal/apijson/subfield.go
@@ -1,7 +1,7 @@
package apijson
import (
- "github.com/stainless-sdks/sapient-go/packages/respjson"
+ "github.com/usesapient/go-sdk/packages/respjson"
"reflect"
)
diff --git a/internal/apijson/union.go b/internal/apijson/union.go
index 8c79187..7fa44a9 100644
--- a/internal/apijson/union.go
+++ b/internal/apijson/union.go
@@ -2,7 +2,7 @@ package apijson
import (
"errors"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"reflect"
"github.com/tidwall/gjson"
diff --git a/internal/apiquery/encoder.go b/internal/apiquery/encoder.go
index cd8b56d..53e38f4 100644
--- a/internal/apiquery/encoder.go
+++ b/internal/apiquery/encoder.go
@@ -9,7 +9,7 @@ import (
"sync"
"time"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
)
var encoders sync.Map // map[reflect.Type]encoderFunc
diff --git a/internal/apiquery/query_test.go b/internal/apiquery/query_test.go
index d52df61..dc1f112 100644
--- a/internal/apiquery/query_test.go
+++ b/internal/apiquery/query_test.go
@@ -1,7 +1,7 @@
package apiquery
import (
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"net/url"
"testing"
"time"
diff --git a/internal/apiquery/richparam.go b/internal/apiquery/richparam.go
index 531a207..c13f24e 100644
--- a/internal/apiquery/richparam.go
+++ b/internal/apiquery/richparam.go
@@ -1,7 +1,7 @@
package apiquery
import (
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"reflect"
)
diff --git a/internal/encoding/json/decode.go b/internal/encoding/json/decode.go
index ca57617..a8640c8 100644
--- a/internal/encoding/json/decode.go
+++ b/internal/encoding/json/decode.go
@@ -14,7 +14,7 @@ import (
"encoding"
"encoding/base64"
"fmt"
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/shims"
+ "github.com/usesapient/go-sdk/internal/encoding/json/shims"
"reflect"
"strconv"
"strings"
diff --git a/internal/encoding/json/encode.go b/internal/encoding/json/encode.go
index 89f513a..b3b969c 100644
--- a/internal/encoding/json/encode.go
+++ b/internal/encoding/json/encode.go
@@ -19,8 +19,8 @@ import (
"encoding"
"encoding/base64"
"fmt"
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/sentinel"
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/shims"
+ "github.com/usesapient/go-sdk/internal/encoding/json/sentinel"
+ "github.com/usesapient/go-sdk/internal/encoding/json/shims"
"math"
"reflect"
"slices"
@@ -173,15 +173,21 @@ import (
// JSON cannot represent cyclic data structures and Marshal does not
// handle them. Passing cyclic structures to Marshal will result in
// an error.
-func Marshal(v any) ([]byte, error) {
+// EDIT(begin): add optimization options
+func Marshal(v any, opts ...Option) ([]byte, error) {
+ // EDIT(end): add optimization options
e := newEncodeState()
defer encodeStatePool.Put(e)
- // SHIM(begin): don't escape HTML by default
- err := e.marshal(v, encOpts{escapeHTML: shims.EscapeHTMLByDefault})
+ // EDIT(begin): don't escape HTML by default, and apply options
+ encOpts := encOpts{escapeHTML: shims.EscapeHTMLByDefault}
+ if opts != nil {
+ encOpts = encOpts.apply(opts...)
+ }
+ err := e.marshal(v, encOpts)
// ORIGINAL:
// err := e.marshal(v, encOpts{escapeHTML: true})
- // SHIM(end)
+ // EDIT(end)
if err != nil {
return nil, err
}
@@ -352,6 +358,9 @@ type encOpts struct {
// EDIT(begin): save the timefmt
timefmt string
// EDIT(end)
+ // EDIT(begin): add optimization to skip compaction
+ skipCompaction bool
+ // EDIT(end)
}
type encoderFunc func(e *encodeState, v reflect.Value, opts encOpts)
@@ -483,7 +492,7 @@ func marshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {
if err == nil {
e.Grow(len(b))
out := e.AvailableBuffer()
- out, err = appendCompact(out, b, opts.escapeHTML)
+ out, err = appendCompact(out, b, opts)
e.Buffer.Write(out)
}
if err != nil {
@@ -509,7 +518,7 @@ func addrMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {
if err == nil {
e.Grow(len(b))
out := e.AvailableBuffer()
- out, err = appendCompact(out, b, opts.escapeHTML)
+ out, err = appendCompact(out, b, opts)
e.Buffer.Write(out)
}
if err != nil {
diff --git a/internal/encoding/json/indent.go b/internal/encoding/json/indent.go
index 01bfdf6..c9d6ca5 100644
--- a/internal/encoding/json/indent.go
+++ b/internal/encoding/json/indent.go
@@ -4,7 +4,9 @@
package json
-import "bytes"
+import (
+ "bytes"
+)
// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029
// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029
@@ -41,12 +43,21 @@ func appendHTMLEscape(dst, src []byte) []byte {
func Compact(dst *bytes.Buffer, src []byte) error {
dst.Grow(len(src))
b := dst.AvailableBuffer()
- b, err := appendCompact(b, src, false)
+ b, err := appendCompact(b, src, encOpts{})
dst.Write(b)
return err
}
-func appendCompact(dst, src []byte, escape bool) ([]byte, error) {
+func appendCompact(dst, src []byte, opts encOpts) ([]byte, error) {
+ // EDIT(begin): optimize for skipCompaction
+ if opts.skipCompaction {
+ dst = append(dst, src...)
+ return dst, nil
+ }
+
+ escape := opts.escapeHTML
+ // EDIT(end)
+
origLen := len(dst)
scan := newScanner()
defer freeScanner(scan)
diff --git a/internal/encoding/json/opt.go b/internal/encoding/json/opt.go
new file mode 100644
index 0000000..fd6f8d2
--- /dev/null
+++ b/internal/encoding/json/opt.go
@@ -0,0 +1,24 @@
+// EDIT(begin): add custom options for JSON encoding
+package json
+
+type Option func(*encOpts)
+
+// Every time a sub-type of [json.Marshaler] is encountered,
+// skip a redundant and costly compaction step, trust it to self-compact.
+//
+// This is a divergence from the standard library behavior, and is only guaranteed
+// safe with SDK types.
+func WithSkipCompaction(b bool) Option {
+ return func(eos *encOpts) {
+ eos.skipCompaction = true
+ }
+}
+
+func (eos encOpts) apply(opts ...Option) encOpts {
+ for _, opt := range opts {
+ opt(&eos)
+ }
+ return eos
+}
+
+// EDIT(end)
diff --git a/internal/encoding/json/sentinel/null.go b/internal/encoding/json/sentinel/null.go
index 63013aa..cf5c0d0 100644
--- a/internal/encoding/json/sentinel/null.go
+++ b/internal/encoding/json/sentinel/null.go
@@ -1,7 +1,7 @@
package sentinel
import (
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/shims"
+ "github.com/usesapient/go-sdk/internal/encoding/json/shims"
"reflect"
"sync"
)
diff --git a/internal/encoding/json/sentinel/sentinel_test.go b/internal/encoding/json/sentinel/sentinel_test.go
index 3213c5c..ea694cb 100644
--- a/internal/encoding/json/sentinel/sentinel_test.go
+++ b/internal/encoding/json/sentinel/sentinel_test.go
@@ -1,8 +1,8 @@
package sentinel_test
import (
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/sentinel"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/internal/encoding/json/sentinel"
+ "github.com/usesapient/go-sdk/packages/param"
"reflect"
"slices"
"testing"
diff --git a/internal/encoding/json/stream.go b/internal/encoding/json/stream.go
index e2d9470..652522c 100644
--- a/internal/encoding/json/stream.go
+++ b/internal/encoding/json/stream.go
@@ -6,7 +6,6 @@ package json
import (
"bytes"
- "errors"
"io"
)
@@ -253,30 +252,34 @@ func (enc *Encoder) SetEscapeHTML(on bool) {
enc.escapeHTML = on
}
-// RawMessage is a raw encoded JSON value.
-// It implements [Marshaler] and [Unmarshaler] and can
-// be used to delay JSON decoding or precompute a JSON encoding.
-type RawMessage []byte
-
-// MarshalJSON returns m as the JSON encoding of m.
-func (m RawMessage) MarshalJSON() ([]byte, error) {
- if m == nil {
- return []byte("null"), nil
- }
- return m, nil
-}
-
-// UnmarshalJSON sets *m to a copy of data.
-func (m *RawMessage) UnmarshalJSON(data []byte) error {
- if m == nil {
- return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
- }
- *m = append((*m)[0:0], data...)
- return nil
-}
-
-var _ Marshaler = (*RawMessage)(nil)
-var _ Unmarshaler = (*RawMessage)(nil)
+// EDIT(begin): remove RawMessage
+//
+// // RawMessage is a raw encoded JSON value.
+// // It implements [Marshaler] and [Unmarshaler] and can
+// // be used to delay JSON decoding or precompute a JSON encoding.
+// type RawMessage []byte
+//
+// // MarshalJSON returns m as the JSON encoding of m.
+// func (m RawMessage) MarshalJSON() ([]byte, error) {
+// if m == nil {
+// return []byte("null"), nil
+// }
+// return m, nil
+// }
+//
+// // UnmarshalJSON sets *m to a copy of data.
+// func (m *RawMessage) UnmarshalJSON(data []byte) error {
+// if m == nil {
+// return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
+// }
+// *m = append((*m)[0:0], data...)
+// return nil
+// }
+//
+// var _ Marshaler = (*RawMessage)(nil)
+// var _ Unmarshaler = (*RawMessage)(nil)
+//
+// EDIT(end)
// A Token holds a value of one of these types:
//
diff --git a/internal/encoding/json/time.go b/internal/encoding/json/time.go
index 24af40f..d7a542a 100644
--- a/internal/encoding/json/time.go
+++ b/internal/encoding/json/time.go
@@ -2,7 +2,7 @@
package json
import (
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/shims"
+ "github.com/usesapient/go-sdk/internal/encoding/json/shims"
"reflect"
"time"
)
@@ -50,7 +50,7 @@ func timeMarshalEncoder(e *encodeState, v reflect.Value, opts encOpts) bool {
if b != nil {
e.Grow(len(b))
out := e.AvailableBuffer()
- out, _ = appendCompact(out, b, opts.escapeHTML)
+ out, _ = appendCompact(out, b, opts)
e.Buffer.Write(out)
return true
}
diff --git a/internal/paramutil/field.go b/internal/paramutil/field.go
index 08404f2..39ec16a 100644
--- a/internal/paramutil/field.go
+++ b/internal/paramutil/field.go
@@ -1,8 +1,8 @@
package paramutil
import (
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
)
func AddrIfPresent[T comparable](v param.Opt[T]) *T {
diff --git a/internal/paramutil/union.go b/internal/paramutil/union.go
index c5c2678..e1ff458 100644
--- a/internal/paramutil/union.go
+++ b/internal/paramutil/union.go
@@ -2,7 +2,7 @@ package paramutil
import (
"fmt"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"reflect"
)
diff --git a/internal/requestconfig/requestconfig.go b/internal/requestconfig/requestconfig.go
index dc7c425..4862048 100644
--- a/internal/requestconfig/requestconfig.go
+++ b/internal/requestconfig/requestconfig.go
@@ -18,10 +18,10 @@ import (
"strings"
"time"
- "github.com/stainless-sdks/sapient-go/internal"
- "github.com/stainless-sdks/sapient-go/internal/apierror"
- "github.com/stainless-sdks/sapient-go/internal/apiform"
- "github.com/stainless-sdks/sapient-go/internal/apiquery"
+ "github.com/usesapient/go-sdk/internal"
+ "github.com/usesapient/go-sdk/internal/apierror"
+ "github.com/usesapient/go-sdk/internal/apiform"
+ "github.com/usesapient/go-sdk/internal/apiquery"
)
func getDefaultHeaders() map[string]string {
@@ -218,7 +218,6 @@ type RequestConfig struct {
CustomHTTPDoer HTTPDoer
HTTPClient *http.Client
Middlewares []middleware
- BearerToken string
APIKey string
// If ResponseBodyInto not nil, then we will attempt to deserialize into
// ResponseBodyInto. If Destination is a []byte, then it will return the body as
@@ -593,7 +592,6 @@ func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig {
BaseURL: cfg.BaseURL,
HTTPClient: cfg.HTTPClient,
Middlewares: cfg.Middlewares,
- BearerToken: cfg.BearerToken,
APIKey: cfg.APIKey,
}
diff --git a/internal/version.go b/internal/version.go
index 989c168..02eac73 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -2,4 +2,4 @@
package internal
-const PackageVersion = "0.0.1"
+const PackageVersion = "0.1.0" // x-release-please-version
diff --git a/option/middleware.go b/option/middleware.go
index 8ec9dd6..3b5213c 100644
--- a/option/middleware.go
+++ b/option/middleware.go
@@ -8,6 +8,10 @@ import (
"net/http/httputil"
)
+// sensitiveLogHeaders are redacted before request and response content is
+// written to the debug logger.
+var sensitiveLogHeaders = []string{"authorization", "api-key", "x-api-key", "cookie", "set-cookie", "x-sapient-api-key"}
+
// WithDebugLog logs the HTTP request and response content.
// If the logger parameter is nil, it uses the default logger.
//
@@ -20,7 +24,7 @@ func WithDebugLog(logger *log.Logger) RequestOption {
logger = log.Default()
}
- if reqBytes, err := httputil.DumpRequest(req, true); err == nil {
+ if reqBytes, err := dumpRedactedRequest(req); err == nil {
logger.Printf("Request Content:\n%s\n", reqBytes)
}
@@ -29,10 +33,48 @@ func WithDebugLog(logger *log.Logger) RequestOption {
return resp, err
}
- if respBytes, err := httputil.DumpResponse(resp, true); err == nil {
+ if respBytes, err := dumpRedactedResponse(resp); err == nil {
logger.Printf("Response Content:\n%s\n", respBytes)
}
return resp, err
})
}
+
+// dumpRedactedRequest dumps req with sensitive headers replaced. The
+// original headers are restored via defer so a panic in DumpRequest cannot
+// leak the placeholder map into the live request sent downstream.
+func dumpRedactedRequest(req *http.Request) ([]byte, error) {
+ origHeaders := req.Header
+ req.Header = redactDebugHeaders(origHeaders)
+ defer func() { req.Header = origHeaders }()
+ return httputil.DumpRequest(req, true)
+}
+
+func dumpRedactedResponse(resp *http.Response) ([]byte, error) {
+ origHeaders := resp.Header
+ resp.Header = redactDebugHeaders(origHeaders)
+ defer func() { resp.Header = origHeaders }()
+ return httputil.DumpResponse(resp, true)
+}
+
+func redactDebugHeaders(headers http.Header) http.Header {
+ var redacted http.Header
+ for _, name := range sensitiveLogHeaders {
+ values := headers.Values(name)
+ if len(values) == 0 {
+ continue
+ }
+ if redacted == nil {
+ redacted = headers.Clone()
+ }
+ redacted.Del(name)
+ for range values {
+ redacted.Add(name, "***")
+ }
+ }
+ if redacted == nil {
+ return headers
+ }
+ return redacted
+}
diff --git a/option/requestoption.go b/option/requestoption.go
index 2505cb2..55a179a 100644
--- a/option/requestoption.go
+++ b/option/requestoption.go
@@ -11,15 +11,15 @@ import (
"strings"
"time"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
"github.com/tidwall/sjson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
)
-// RequestOption is an option for the requests made by the sapient API Client
+// RequestOption is an option for the requests made by the Sapient API Client
// which can be supplied to clients, services, and methods. You can read more about this functional
// options pattern in our [README].
//
-// [README]: https://pkg.go.dev/github.com/stainless-sdks/sapient-go#readme-requestoptions
+// [README]: https://pkg.go.dev/github.com/usesapient/go-sdk#readme-requestoptions
type RequestOption = requestconfig.RequestOption
// WithBaseURL returns a RequestOption that sets the BaseURL for the client.
@@ -263,15 +263,7 @@ func WithRequestTimeout(dur time.Duration) RequestOption {
// environment to be the "production" environment. An environment specifies which base URL
// to use by default.
func WithEnvironmentProduction() RequestOption {
- return requestconfig.WithDefaultBaseURL("https://api.example.com/")
-}
-
-// WithBearerToken returns a RequestOption that sets the client setting "bearer_token".
-func WithBearerToken(value string) RequestOption {
- return requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {
- r.BearerToken = value
- return r.Apply(WithHeader("authorization", fmt.Sprintf("Bearer %s", r.BearerToken)))
- })
+ return requestconfig.WithDefaultBaseURL("https://api-public.usesapient.com/")
}
// WithAPIKey returns a RequestOption that sets the client setting "api_key".
diff --git a/packages/param/encoder.go b/packages/param/encoder.go
index 0f128ed..2074d2b 100644
--- a/packages/param/encoder.go
+++ b/packages/param/encoder.go
@@ -7,7 +7,7 @@ import (
"strings"
"time"
- shimjson "github.com/stainless-sdks/sapient-go/internal/encoding/json"
+ shimjson "github.com/usesapient/go-sdk/internal/encoding/json"
"github.com/tidwall/sjson"
)
@@ -66,7 +66,7 @@ func MarshalWithExtras[T ParamStruct, R any](f T, underlying any, extras map[str
} else if ovr, ok := f.Overrides(); ok {
return shimjson.Marshal(ovr)
} else {
- return shimjson.Marshal(underlying)
+ return shimjson.Marshal(underlying, shimjson.WithSkipCompaction(true))
}
}
@@ -96,7 +96,7 @@ func MarshalUnion[T ParamStruct](metadata T, variants ...any) ([]byte, error) {
Err: fmt.Errorf("expected union to have only one present variant, got %d", nPresent),
}
}
- return shimjson.Marshal(variants[presentIdx])
+ return shimjson.Marshal(variants[presentIdx], shimjson.WithSkipCompaction(true))
}
// typeFor is shimmed from Go 1.23 "reflect" package
diff --git a/packages/param/encoder_test.go b/packages/param/encoder_test.go
index b469f14..8bb6f3f 100644
--- a/packages/param/encoder_test.go
+++ b/packages/param/encoder_test.go
@@ -1,11 +1,14 @@
package param_test
import (
+ "bytes"
"encoding/json"
+ "reflect"
"testing"
"time"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ shimjson "github.com/usesapient/go-sdk/internal/encoding/json"
+ "github.com/usesapient/go-sdk/packages/param"
)
type Struct struct {
@@ -375,3 +378,176 @@ func TestNullStructUnion(t *testing.T) {
t.Fatalf("expected null, received %s", string(b))
}
}
+
+//
+// Compaction optimization
+//
+
+type NonCompactedDoubleParent struct {
+ Prop string `json:"prop"`
+ Parent NonCompactedParent `json:"parent"`
+
+ param.APIObject
+}
+
+type NonCompactedParent struct {
+ BadChild NonCompacted `json:"bad_child"`
+
+ param.APIObject
+}
+
+type NonCompacted struct {
+ Raw string
+
+ param.APIObject
+}
+
+func (a NonCompactedDoubleParent) MarshalJSON() ([]byte, error) {
+ type shadow NonCompactedDoubleParent
+ return param.MarshalObject(a, (*shadow)(&a))
+}
+
+func (a NonCompactedParent) MarshalJSON() ([]byte, error) {
+ type shadow NonCompactedParent
+ return param.MarshalObject(a, (*shadow)(&a))
+}
+
+func (a NonCompacted) MarshalJSON() ([]byte, error) {
+ if a.Raw == "" {
+ a.Raw = nonCompactedRaw
+ }
+ return []byte(a.Raw), nil
+}
+
+var nonCompactedRaw string = ` { "foo": "bar" } `
+
+func TestAppendCompactBroken(t *testing.T) {
+ tests := map[string]struct {
+ value json.Marshaler
+ }{
+ "red/illegal-json": {
+ NonCompacted{Raw: `{ "broken": "json" `},
+ },
+ "red/nested-with-illegal-json": {
+ NonCompactedParent{BadChild: NonCompacted{
+ Raw: `{ "broken": "json" `,
+ }},
+ },
+ }
+
+ for name, test := range tests {
+ t.Run(name, func(t *testing.T) {
+ v, err := json.Marshal(test.value)
+ if err == nil {
+ t.Fatal("expected error got", v)
+ }
+ })
+ }
+}
+
+// TestAppendCompact validates an optimization for internal SDK types to
+// avoid O(keys^2) iteration over each JSON object.
+//
+// It's possible to intentionally trigger this behavior as both a user and
+// SDK developer. However, the edge case is quite pathological and requires
+// calling [json.Marshaler.MarshalJSON] rather than [json.Marshal].
+func TestAppendCompact(t *testing.T) {
+
+ tests := map[string]struct {
+ value json.Marshaler
+ expected string
+ }{
+ //
+ // Non-compacted cases
+ //
+ // Note this is how to exploit the compacter to fail, you must call [json.Marshaler.MarshalJSON] rather than [json.Marshal].
+ // The type must also embed [param.APIObject] and return non-compacted JSON.
+ //
+
+ "no-compact/fails-compaction": {
+ NonCompacted{Raw: nonCompactedRaw},
+ nonCompactedRaw,
+ },
+ "no-compact/nested-with-bad-child": {
+ NonCompactedParent{BadChild: NonCompacted{
+ Raw: nonCompactedRaw,
+ }},
+ `{"bad_child":` + nonCompactedRaw + `}`,
+ },
+ "no-compact/double-nested-with-bad-child": {
+ NonCompactedDoubleParent{Prop: "1", Parent: NonCompactedParent{BadChild: NonCompacted{
+ Raw: nonCompactedRaw,
+ }}},
+ `{"prop":"1","parent":{"bad_child":` + nonCompactedRaw + `}}`,
+ },
+
+ //
+ // Compacted cases
+ //
+
+ "override/spaces-within": {
+ param.Override[NonCompactedDoubleParent](json.RawMessage(`{"com": "pact"}`)),
+ `{"com":"pact"}`,
+ },
+ "override/spaces-after": {
+ param.Override[NonCompactedDoubleParent](json.RawMessage(`{"com":"pact"} `)),
+ `{"com":"pact"}`,
+ },
+ "override/spaces-before": {
+ param.Override[NonCompactedDoubleParent](json.RawMessage(` {"com":"pact"}`)),
+ `{"com":"pact"}`,
+ },
+ "override/spaces-around": {
+ param.Override[NonCompactedDoubleParent](json.RawMessage(` { "com": "pact" }`)),
+ `{"com":"pact"}`,
+ },
+ "override/override-with-nested": {
+ param.Override[NonCompactedDoubleParent](NonCompactedParent{}),
+ `{"bad_child":{"foo":"bar"}}`,
+ },
+ "override/override-with-non-compacted": {
+ param.Override[NonCompactedDoubleParent](NonCompacted{}),
+ `{"foo":"bar"}`,
+ },
+ }
+
+ for name, test := range tests {
+ t.Run(name+"/marshal-json", func(t *testing.T) {
+ b, err := test.value.MarshalJSON()
+ if err != nil {
+ t.Fatalf("didn't expect error %v, expected %s", err, test.expected)
+ }
+ if string(b) != test.expected {
+ t.Fatalf("expected %s (%s), received %s", test.expected, reflect.TypeOf(test.value), string(b))
+ }
+ })
+
+ t.Run(name+"/json-marshal", func(t *testing.T) {
+ b, err := json.Marshal(test.value)
+ if err != nil {
+ t.Fatalf("didn't expect error %v, expected %s", err, test.expected)
+ }
+
+ // expected output of JSON Marshal should always be compacted
+ var compactedExpected bytes.Buffer
+ err = json.Compact(&compactedExpected, []byte(test.expected))
+ if err != nil {
+ t.Fatalf("didn't expect error %v, expected %s", err, test.expected)
+ }
+
+ if string(b) != compactedExpected.String() {
+ t.Fatalf("expected %s (%s), received %s", test.expected, reflect.TypeOf(test.value), string(b))
+ }
+ })
+
+ t.Run(name+"/shimjson-marshal", func(t *testing.T) {
+ b, err := shimjson.Marshal(test.value)
+ if err != nil {
+ t.Fatalf("didn't expect error %v, expected %s", err, test.expected)
+ }
+ if string(b) != test.expected {
+ t.Logf("expected %s (%s), received %s", test.expected, reflect.TypeOf(test.value), string(b))
+ }
+ })
+ }
+}
diff --git a/packages/param/null.go b/packages/param/null.go
index f89e1cb..c597997 100644
--- a/packages/param/null.go
+++ b/packages/param/null.go
@@ -1,6 +1,6 @@
package param
-import "github.com/stainless-sdks/sapient-go/internal/encoding/json/sentinel"
+import "github.com/usesapient/go-sdk/internal/encoding/json/sentinel"
// NullMap returns a non-nil map with a length of 0.
// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
diff --git a/packages/param/null_test.go b/packages/param/null_test.go
index 5cbaf51..b047bdc 100644
--- a/packages/param/null_test.go
+++ b/packages/param/null_test.go
@@ -2,7 +2,7 @@ package param_test
import (
"encoding/json"
- "github.com/stainless-sdks/sapient-go/packages/param"
+ "github.com/usesapient/go-sdk/packages/param"
"testing"
)
diff --git a/packages/param/option.go b/packages/param/option.go
index 2178ee2..90b8776 100644
--- a/packages/param/option.go
+++ b/packages/param/option.go
@@ -3,7 +3,7 @@ package param
import (
"encoding/json"
"fmt"
- shimjson "github.com/stainless-sdks/sapient-go/internal/encoding/json"
+ shimjson "github.com/usesapient/go-sdk/internal/encoding/json"
"time"
)
diff --git a/packages/param/param.go b/packages/param/param.go
index 2aea892..3176b1f 100644
--- a/packages/param/param.go
+++ b/packages/param/param.go
@@ -2,7 +2,7 @@ package param
import (
"encoding/json"
- "github.com/stainless-sdks/sapient-go/internal/encoding/json/sentinel"
+ "github.com/usesapient/go-sdk/internal/encoding/json/sentinel"
"reflect"
)
diff --git a/packages/respjson/decoder_test.go b/packages/respjson/decoder_test.go
index d6732da..dfb402b 100644
--- a/packages/respjson/decoder_test.go
+++ b/packages/respjson/decoder_test.go
@@ -3,8 +3,8 @@ package respjson_test
import (
"encoding/json"
"fmt"
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- rj "github.com/stainless-sdks/sapient-go/packages/respjson"
+ "github.com/usesapient/go-sdk/internal/apijson"
+ rj "github.com/usesapient/go-sdk/packages/respjson"
"reflect"
"testing"
)
diff --git a/prompt.go b/prompt.go
index 5530874..1826789 100644
--- a/prompt.go
+++ b/prompt.go
@@ -1,27 +1,33 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient
+package githubcomusesapientgosdk
import (
"context"
+ "errors"
+ "fmt"
"net/http"
+ "net/url"
"slices"
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/apiquery"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
)
// PromptService contains methods and other services that help with interacting
-// with the sapient API.
+// with the Sapient API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewPromptService] method instead.
type PromptService struct {
- options []option.RequestOption
+ Options []option.RequestOption
+ Topics PromptTopicService
+ Platforms PromptPlatformService
}
// NewPromptService generates a new service that applies the given options to each
@@ -29,92 +35,559 @@ type PromptService struct {
// is one), and before any request-specific options.
func NewPromptService(opts ...option.RequestOption) (r PromptService) {
r = PromptService{}
- r.options = opts
+ r.Options = opts
+ r.Topics = NewPromptTopicService(opts...)
+ r.Platforms = NewPromptPlatformService(opts...)
return
}
-// Generate From List
-func (r *PromptService) GenerateFromList(ctx context.Context, body PromptGenerateFromListParams, opts ...option.RequestOption) (res *PromptGenerateFromListResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/prompts/generate-from-list"
+// Create Prompt
+func (r *PromptService) New(ctx context.Context, body PromptNewParams, opts ...option.RequestOption) (res *PromptNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/prompts"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
-type PromptGenerateFromListResponse struct {
- Count int64 `json:"count" api:"required"`
- Prompts []PromptGenerateFromListResponsePrompt `json:"prompts" api:"required"`
+// Retrieve Prompt
+func (r *PromptService) Get(ctx context.Context, promptID string, opts ...option.RequestOption) (res *PromptGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if promptID == "" {
+ err = errors.New("missing required prompt_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/prompts/%s", promptID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Update Prompt
+func (r *PromptService) Update(ctx context.Context, promptID string, body PromptUpdateParams, opts ...option.RequestOption) (res *PromptUpdateResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if promptID == "" {
+ err = errors.New("missing required prompt_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/prompts/%s", promptID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
+ return res, err
+}
+
+// List Prompts
+func (r *PromptService) List(ctx context.Context, query PromptListParams, opts ...option.RequestOption) (res *PromptListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/prompts"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ return res, err
+}
+
+// Delete Prompt
+func (r *PromptService) Delete(ctx context.Context, promptID string, opts ...option.RequestOption) (res *PromptDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if promptID == "" {
+ err = errors.New("missing required prompt_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/prompts/%s", promptID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+type PromptNewResponse struct {
+ ID string `json:"id" api:"required"`
+ Text string `json:"text" api:"required"`
+ TopicID string `json:"topic_id" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ IsActive bool `json:"is_active"`
+ LanguageID string `json:"language_id" api:"nullable"`
+ Platforms []PromptNewResponsePlatform `json:"platforms"`
+ RegionID string `json:"region_id" api:"nullable"`
+ // Any of "active", "inactive", "archived".
+ Status PromptNewResponseStatus `json:"status" api:"nullable"`
+ Tags []PromptNewResponseTag `json:"tags"`
+ Topic PromptNewResponseTopic `json:"topic" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Text respjson.Field
+ TopicID respjson.Field
+ CreatedAt respjson.Field
+ IsActive respjson.Field
+ LanguageID respjson.Field
+ Platforms respjson.Field
+ RegionID respjson.Field
+ Status respjson.Field
+ Tags respjson.Field
+ Topic respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptNewResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptNewResponsePlatform struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptNewResponsePlatform) RawJSON() string { return r.JSON.raw }
+func (r *PromptNewResponsePlatform) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptNewResponseStatus string
+
+const (
+ PromptNewResponseStatusActive PromptNewResponseStatus = "active"
+ PromptNewResponseStatusInactive PromptNewResponseStatus = "inactive"
+ PromptNewResponseStatusArchived PromptNewResponseStatus = "archived"
+)
+
+type PromptNewResponseTag struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptNewResponseTag) RawJSON() string { return r.JSON.raw }
+func (r *PromptNewResponseTag) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptNewResponseTopic struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptNewResponseTopic) RawJSON() string { return r.JSON.raw }
+func (r *PromptNewResponseTopic) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptGetResponse struct {
+ ID string `json:"id" api:"required"`
+ Text string `json:"text" api:"required"`
+ TopicID string `json:"topic_id" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ IsActive bool `json:"is_active"`
+ LanguageID string `json:"language_id" api:"nullable"`
+ Platforms []PromptGetResponsePlatform `json:"platforms"`
+ RegionID string `json:"region_id" api:"nullable"`
+ // Any of "active", "inactive", "archived".
+ Status PromptGetResponseStatus `json:"status" api:"nullable"`
+ Tags []PromptGetResponseTag `json:"tags"`
+ Topic PromptGetResponseTopic `json:"topic" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Text respjson.Field
+ TopicID respjson.Field
+ CreatedAt respjson.Field
+ IsActive respjson.Field
+ LanguageID respjson.Field
+ Platforms respjson.Field
+ RegionID respjson.Field
+ Status respjson.Field
+ Tags respjson.Field
+ Topic respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptGetResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptGetResponsePlatform struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptGetResponsePlatform) RawJSON() string { return r.JSON.raw }
+func (r *PromptGetResponsePlatform) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptGetResponseStatus string
+
+const (
+ PromptGetResponseStatusActive PromptGetResponseStatus = "active"
+ PromptGetResponseStatusInactive PromptGetResponseStatus = "inactive"
+ PromptGetResponseStatusArchived PromptGetResponseStatus = "archived"
+)
+
+type PromptGetResponseTag struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptGetResponseTag) RawJSON() string { return r.JSON.raw }
+func (r *PromptGetResponseTag) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptGetResponseTopic struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptGetResponseTopic) RawJSON() string { return r.JSON.raw }
+func (r *PromptGetResponseTopic) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptUpdateResponse struct {
+ ID string `json:"id" api:"required"`
+ Text string `json:"text" api:"required"`
+ TopicID string `json:"topic_id" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ IsActive bool `json:"is_active"`
+ LanguageID string `json:"language_id" api:"nullable"`
+ Platforms []PromptUpdateResponsePlatform `json:"platforms"`
+ RegionID string `json:"region_id" api:"nullable"`
+ // Any of "active", "inactive", "archived".
+ Status PromptUpdateResponseStatus `json:"status" api:"nullable"`
+ Tags []PromptUpdateResponseTag `json:"tags"`
+ Topic PromptUpdateResponseTopic `json:"topic" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Text respjson.Field
+ TopicID respjson.Field
+ CreatedAt respjson.Field
+ IsActive respjson.Field
+ LanguageID respjson.Field
+ Platforms respjson.Field
+ RegionID respjson.Field
+ Status respjson.Field
+ Tags respjson.Field
+ Topic respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptUpdateResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptUpdateResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptUpdateResponsePlatform struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptUpdateResponsePlatform) RawJSON() string { return r.JSON.raw }
+func (r *PromptUpdateResponsePlatform) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptUpdateResponseStatus string
+
+const (
+ PromptUpdateResponseStatusActive PromptUpdateResponseStatus = "active"
+ PromptUpdateResponseStatusInactive PromptUpdateResponseStatus = "inactive"
+ PromptUpdateResponseStatusArchived PromptUpdateResponseStatus = "archived"
+)
+
+type PromptUpdateResponseTag struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptUpdateResponseTag) RawJSON() string { return r.JSON.raw }
+func (r *PromptUpdateResponseTag) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptUpdateResponseTopic struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptUpdateResponseTopic) RawJSON() string { return r.JSON.raw }
+func (r *PromptUpdateResponseTopic) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptListResponse struct {
+ Count int64 `json:"count" api:"required"`
+ Data []PromptListResponseData `json:"data" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
- Prompts respjson.Field
+ Data respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptListResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptListResponseData struct {
+ ID string `json:"id" api:"required"`
+ Text string `json:"text" api:"required"`
+ TopicID string `json:"topic_id" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ IsActive bool `json:"is_active"`
+ LanguageID string `json:"language_id" api:"nullable"`
+ Platforms []PromptListResponseDataPlatform `json:"platforms"`
+ RegionID string `json:"region_id" api:"nullable"`
+ // Any of "active", "inactive", "archived".
+ Status string `json:"status" api:"nullable"`
+ Tags []PromptListResponseDataTag `json:"tags"`
+ Topic PromptListResponseDataTopic `json:"topic" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Text respjson.Field
+ TopicID respjson.Field
+ CreatedAt respjson.Field
+ IsActive respjson.Field
+ LanguageID respjson.Field
+ Platforms respjson.Field
+ RegionID respjson.Field
+ Status respjson.Field
+ Tags respjson.Field
+ Topic respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptListResponseData) RawJSON() string { return r.JSON.raw }
+func (r *PromptListResponseData) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptListResponseDataPlatform struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptListResponseDataPlatform) RawJSON() string { return r.JSON.raw }
+func (r *PromptListResponseDataPlatform) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptListResponseDataTag struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
-func (r PromptGenerateFromListResponse) RawJSON() string { return r.JSON.raw }
-func (r *PromptGenerateFromListResponse) UnmarshalJSON(data []byte) error {
+func (r PromptListResponseDataTag) RawJSON() string { return r.JSON.raw }
+func (r *PromptListResponseDataTag) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type PromptGenerateFromListResponsePrompt struct {
- SourceName string `json:"source_name" api:"required"`
- Text string `json:"text" api:"required"`
- Goal string `json:"goal" api:"nullable"`
- Metadata map[string]any `json:"metadata"`
- SourceDomain string `json:"source_domain" api:"nullable"`
+type PromptListResponseDataTopic struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
- SourceName respjson.Field
- Text respjson.Field
- Goal respjson.Field
- Metadata respjson.Field
- SourceDomain respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
-func (r PromptGenerateFromListResponsePrompt) RawJSON() string { return r.JSON.raw }
-func (r *PromptGenerateFromListResponsePrompt) UnmarshalJSON(data []byte) error {
+func (r PromptListResponseDataTopic) RawJSON() string { return r.JSON.raw }
+func (r *PromptListResponseDataTopic) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type PromptGenerateFromListParams struct {
- Items []PromptGenerateFromListParamsItem `json:"items,omitzero" api:"required"`
- // Prompt goal or evaluation theme.
- Goal param.Opt[string] `json:"goal,omitzero"`
- CountPerItem param.Opt[int64] `json:"count_per_item,omitzero"`
- IncludeAgentTasks param.Opt[bool] `json:"include_agent_tasks,omitzero"`
- Language param.Opt[string] `json:"language,omitzero"`
- Region param.Opt[string] `json:"region,omitzero"`
+type PromptDeleteResponse = any
+
+type PromptNewParams struct {
+ Text string `json:"text" api:"required"`
+ TopicID string `json:"topic_id" api:"required"`
+ LanguageID param.Opt[string] `json:"language_id,omitzero"`
+ RegionID param.Opt[string] `json:"region_id,omitzero"`
+ PlatformIDs []string `json:"platform_ids,omitzero"`
paramObj
}
-func (r PromptGenerateFromListParams) MarshalJSON() (data []byte, err error) {
- type shadow PromptGenerateFromListParams
+func (r PromptNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow PromptNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *PromptGenerateFromListParams) UnmarshalJSON(data []byte) error {
+func (r *PromptNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// The property Name is required.
-type PromptGenerateFromListParamsItem struct {
- Name string `json:"name" api:"required"`
- Category param.Opt[string] `json:"category,omitzero"`
- Domain param.Opt[string] `json:"domain,omitzero"`
- Notes param.Opt[string] `json:"notes,omitzero"`
+type PromptUpdateParams struct {
+ IsActive param.Opt[bool] `json:"is_active,omitzero"`
+ LanguageID param.Opt[string] `json:"language_id,omitzero"`
+ RegionID param.Opt[string] `json:"region_id,omitzero"`
+ Text param.Opt[string] `json:"text,omitzero"`
+ TopicID param.Opt[string] `json:"topic_id,omitzero"`
+ PlatformIDs []string `json:"platform_ids,omitzero"`
paramObj
}
-func (r PromptGenerateFromListParamsItem) MarshalJSON() (data []byte, err error) {
- type shadow PromptGenerateFromListParamsItem
+func (r PromptUpdateParams) MarshalJSON() (data []byte, err error) {
+ type shadow PromptUpdateParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *PromptGenerateFromListParamsItem) UnmarshalJSON(data []byte) error {
+func (r *PromptUpdateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+
+type PromptListParams struct {
+ IsActive param.Opt[bool] `query:"is_active,omitzero" json:"-"`
+ Status param.Opt[string] `query:"status,omitzero" json:"-"`
+ TopicID param.Opt[string] `query:"topic_id,omitzero" json:"-"`
+ IncludeArchived param.Opt[bool] `query:"include_archived,omitzero" json:"-"`
+ paramObj
+}
+
+// URLQuery serializes [PromptListParams]'s query parameters as `url.Values`.
+func (r PromptListParams) URLQuery() (v url.Values, err error) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/prompt_test.go b/prompt_test.go
index 3de7043..a7b927c 100644
--- a/prompt_test.go
+++ b/prompt_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestPromptGenerateFromListWithOptionalParams(t *testing.T) {
+func TestPromptNewWithOptionalParams(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,26 +22,127 @@ func TestPromptGenerateFromListWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.Prompts.GenerateFromList(context.TODO(), sapient.PromptGenerateFromListParams{
- Items: []sapient.PromptGenerateFromListParamsItem{{
- Name: "name",
- Category: sapient.String("category"),
- Domain: sapient.String("domain"),
- Notes: sapient.String("notes"),
- }},
- CountPerItem: sapient.Int(1),
- Goal: sapient.String("goal"),
- IncludeAgentTasks: sapient.Bool(true),
- Language: sapient.String("language"),
- Region: sapient.String("region"),
+ _, err := client.Prompts.New(context.TODO(), githubcomusesapientgosdk.PromptNewParams{
+ Text: "x",
+ TopicID: "topic_id",
+ LanguageID: githubcomusesapientgosdk.String("language_id"),
+ PlatformIDs: []string{"string"},
+ RegionID: githubcomusesapientgosdk.String("region_id"),
})
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestPromptGet(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Prompts.Get(context.TODO(), "prompt_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestPromptUpdateWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Prompts.Update(
+ context.TODO(),
+ "prompt_id",
+ githubcomusesapientgosdk.PromptUpdateParams{
+ IsActive: githubcomusesapientgosdk.Bool(true),
+ LanguageID: githubcomusesapientgosdk.String("language_id"),
+ PlatformIDs: []string{"string"},
+ RegionID: githubcomusesapientgosdk.String("region_id"),
+ Text: githubcomusesapientgosdk.String("x"),
+ TopicID: githubcomusesapientgosdk.String("topic_id"),
+ },
+ )
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestPromptListWithOptionalParams(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Prompts.List(context.TODO(), githubcomusesapientgosdk.PromptListParams{
+ IncludeArchived: githubcomusesapientgosdk.Bool(true),
+ IsActive: githubcomusesapientgosdk.Bool(true),
+ Status: githubcomusesapientgosdk.String("archived"),
+ TopicID: githubcomusesapientgosdk.String("topic_id"),
+ })
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestPromptDelete(t *testing.T) {
+ t.Skip("Mock server tests are disabled")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := githubcomusesapientgosdk.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Prompts.Delete(context.TODO(), "prompt_id")
+ if err != nil {
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/promptplatform.go b/promptplatform.go
new file mode 100644
index 0000000..2f85aaf
--- /dev/null
+++ b/promptplatform.go
@@ -0,0 +1,41 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+)
+
+// PromptPlatformService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewPromptPlatformService] method instead.
+type PromptPlatformService struct {
+ Options []option.RequestOption
+}
+
+// NewPromptPlatformService generates a new service that applies the given options
+// to each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewPromptPlatformService(opts ...option.RequestOption) (r PromptPlatformService) {
+ r = PromptPlatformService{}
+ r.Options = opts
+ return
+}
+
+// List Platforms
+func (r *PromptPlatformService) List(ctx context.Context, opts ...option.RequestOption) (res *PromptPlatformListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/prompts/platforms"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+type PromptPlatformListResponse = any
diff --git a/apileaderboardcompany_test.go b/promptplatform_test.go
similarity index 52%
rename from apileaderboardcompany_test.go
rename to promptplatform_test.go
index edd5403..4d1a9a5 100644
--- a/apileaderboardcompany_test.go
+++ b/promptplatform_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestAPILeaderboardCompanyListWithOptionalParams(t *testing.T) {
+func TestPromptPlatformList(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,17 +22,13 @@ func TestAPILeaderboardCompanyListWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.Leaderboard.Companies.List(context.TODO(), sapient.APILeaderboardCompanyListParams{
- Category: sapient.String("category"),
- Limit: sapient.Int(1),
- })
+ _, err := client.Prompts.Platforms.List(context.TODO())
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/prompttopic.go b/prompttopic.go
new file mode 100644
index 0000000..8ea3572
--- /dev/null
+++ b/prompttopic.go
@@ -0,0 +1,170 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package githubcomusesapientgosdk
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/usesapient/go-sdk/internal/apijson"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
+ "github.com/usesapient/go-sdk/packages/param"
+ "github.com/usesapient/go-sdk/packages/respjson"
+)
+
+// PromptTopicService contains methods and other services that help with
+// interacting with the Sapient API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewPromptTopicService] method instead.
+type PromptTopicService struct {
+ Options []option.RequestOption
+}
+
+// NewPromptTopicService generates a new service that applies the given options to
+// each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewPromptTopicService(opts ...option.RequestOption) (r PromptTopicService) {
+ r = PromptTopicService{}
+ r.Options = opts
+ return
+}
+
+// Create Topic
+func (r *PromptTopicService) New(ctx context.Context, body PromptTopicNewParams, opts ...option.RequestOption) (res *PromptTopicNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/prompts/topics"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// Update Topic
+func (r *PromptTopicService) Update(ctx context.Context, topicID string, body PromptTopicUpdateParams, opts ...option.RequestOption) (res *PromptTopicUpdateResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if topicID == "" {
+ err = errors.New("missing required topic_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/prompts/topics/%s", topicID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
+ return res, err
+}
+
+// List Topics
+func (r *PromptTopicService) List(ctx context.Context, opts ...option.RequestOption) (res *[]PromptTopicListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1/prompts/topics"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Delete Topic
+func (r *PromptTopicService) Delete(ctx context.Context, topicID string, opts ...option.RequestOption) (res *PromptTopicDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if topicID == "" {
+ err = errors.New("missing required topic_id parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("v1/prompts/topics/%s", topicID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+type PromptTopicNewResponse struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptTopicNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptTopicNewResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptTopicUpdateResponse struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptTopicUpdateResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptTopicUpdateResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptTopicListResponse struct {
+ ID string `json:"id" api:"required"`
+ Name string `json:"name" api:"required"`
+ CreatedAt string `json:"created_at" api:"nullable"`
+ UpdatedAt string `json:"updated_at" api:"nullable"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Name respjson.Field
+ CreatedAt respjson.Field
+ UpdatedAt respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r PromptTopicListResponse) RawJSON() string { return r.JSON.raw }
+func (r *PromptTopicListResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptTopicDeleteResponse = any
+
+type PromptTopicNewParams struct {
+ Name string `json:"name" api:"required"`
+ paramObj
+}
+
+func (r PromptTopicNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow PromptTopicNewParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *PromptTopicNewParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type PromptTopicUpdateParams struct {
+ Name string `json:"name" api:"required"`
+ paramObj
+}
+
+func (r PromptTopicUpdateParams) MarshalJSON() (data []byte, err error) {
+ type shadow PromptTopicUpdateParams
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *PromptTopicUpdateParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/apijob_test.go b/prompttopic_test.go
similarity index 60%
rename from apijob_test.go
rename to prompttopic_test.go
index 58873f7..d984a8d 100644
--- a/apijob_test.go
+++ b/prompttopic_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,12 +8,12 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
-func TestAPIJobListJobsWithOptionalParams(t *testing.T) {
+func TestPromptTopicNew(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -22,18 +22,15 @@ func TestAPIJobListJobsWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.Jobs.ListJobs(context.TODO(), sapient.APIJobListJobsParams{
- Limit: sapient.Int(1),
- Status: sapient.String("status"),
- Type: sapient.String("type"),
+ _, err := client.Prompts.Topics.New(context.TODO(), githubcomusesapientgosdk.PromptTopicNewParams{
+ Name: "x",
})
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -41,7 +38,7 @@ func TestAPIJobListJobsWithOptionalParams(t *testing.T) {
}
}
-func TestAPIJobGetJob(t *testing.T) {
+func TestPromptTopicUpdate(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -50,14 +47,19 @@ func TestAPIJobGetJob(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.Jobs.GetJob(context.TODO(), "job_id")
+ _, err := client.Prompts.Topics.Update(
+ context.TODO(),
+ "topic_id",
+ githubcomusesapientgosdk.PromptTopicUpdateParams{
+ Name: "x",
+ },
+ )
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -65,7 +67,7 @@ func TestAPIJobGetJob(t *testing.T) {
}
}
-func TestAPIJobListWithOptionalParams(t *testing.T) {
+func TestPromptTopicList(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -74,18 +76,13 @@ func TestAPIJobListWithOptionalParams(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.Jobs.List(context.TODO(), sapient.APIJobListParams{
- Limit: sapient.Int(1),
- Status: sapient.String("status"),
- Type: sapient.String("type"),
- })
+ _, err := client.Prompts.Topics.List(context.TODO())
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
@@ -93,7 +90,7 @@ func TestAPIJobListWithOptionalParams(t *testing.T) {
}
}
-func TestAPIJobGet(t *testing.T) {
+func TestPromptTopicDelete(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -102,14 +99,13 @@ func TestAPIJobGet(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
- option.WithBearerToken("My Bearer Token"),
option.WithAPIKey("My API Key"),
)
- _, err := client.API.Jobs.Get(context.TODO(), "job_id")
+ _, err := client.Prompts.Topics.Delete(context.TODO(), "topic_id")
if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/release-please-config.json b/release-please-config.json
new file mode 100644
index 0000000..a38198e
--- /dev/null
+++ b/release-please-config.json
@@ -0,0 +1,67 @@
+{
+ "packages": {
+ ".": {}
+ },
+ "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
+ "include-v-in-tag": true,
+ "include-component-in-tag": false,
+ "versioning": "prerelease",
+ "prerelease": true,
+ "bump-minor-pre-major": true,
+ "bump-patch-for-minor-pre-major": false,
+ "pull-request-header": "Automated Release PR",
+ "pull-request-title-pattern": "release: ${version}",
+ "changelog-sections": [
+ {
+ "type": "feat",
+ "section": "Features"
+ },
+ {
+ "type": "fix",
+ "section": "Bug Fixes"
+ },
+ {
+ "type": "perf",
+ "section": "Performance Improvements"
+ },
+ {
+ "type": "revert",
+ "section": "Reverts"
+ },
+ {
+ "type": "chore",
+ "section": "Chores"
+ },
+ {
+ "type": "docs",
+ "section": "Documentation"
+ },
+ {
+ "type": "style",
+ "section": "Styles"
+ },
+ {
+ "type": "refactor",
+ "section": "Refactors"
+ },
+ {
+ "type": "test",
+ "section": "Tests",
+ "hidden": true
+ },
+ {
+ "type": "build",
+ "section": "Build System"
+ },
+ {
+ "type": "ci",
+ "section": "Continuous Integration",
+ "hidden": true
+ }
+ ],
+ "release-type": "go",
+ "extra-files": [
+ "internal/version.go",
+ "README.md"
+ ]
+}
\ No newline at end of file
diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh
index e9131ba..81b40d9 100755
--- a/scripts/utils/upload-artifact.sh
+++ b/scripts/utils/upload-artifact.sh
@@ -43,7 +43,7 @@ UPLOAD_RESPONSE=$(curl -v -X PUT \
if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
- echo -e "\033[32mInstallation: Download and unzip: 'https://pkg.stainless.com/s/sapient-go/$SHA'. Run 'go mod edit -replace github.com/stainless-sdks/sapient-go=/path/to/unzipped_directory'.\033[0m"
+ echo -e "\033[32mInstallation: Download and unzip: 'https://pkg.stainless.com/s/sapient-go/$SHA'. Run 'go mod edit -replace github.com/usesapient/go-sdk=/path/to/unzipped_directory'.\033[0m"
else
echo -e "\033[31mFailed to upload artifact.\033[0m"
exit 1
diff --git a/shared/constant/constants.go b/shared/constant/constants.go
index fc46679..59f8f93 100644
--- a/shared/constant/constants.go
+++ b/shared/constant/constants.go
@@ -3,7 +3,7 @@
package constant
import (
- shimjson "github.com/stainless-sdks/sapient-go/internal/encoding/json"
+ shimjson "github.com/usesapient/go-sdk/internal/encoding/json"
)
type Constant[T any] interface {
diff --git a/status.go b/status.go
index c0d7182..565b6a8 100644
--- a/status.go
+++ b/status.go
@@ -1,24 +1,24 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient
+package githubcomusesapientgosdk
import (
"context"
"net/http"
"slices"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk/internal/requestconfig"
+ "github.com/usesapient/go-sdk/option"
)
// StatusService contains methods and other services that help with interacting
-// with the sapient API.
+// with the Sapient API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewStatusService] method instead.
type StatusService struct {
- options []option.RequestOption
+ Options []option.RequestOption
}
// NewStatusService generates a new service that applies the given options to each
@@ -26,21 +26,13 @@ type StatusService struct {
// is one), and before any request-specific options.
func NewStatusService(opts ...option.RequestOption) (r StatusService) {
r = StatusService{}
- r.options = opts
+ r.Options = opts
return
}
// Get Status
func (r *StatusService) Get(ctx context.Context, opts ...option.RequestOption) (res *StatusGetResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/status"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-// Get Status
-func (r *StatusService) Get(ctx context.Context, opts ...option.RequestOption) (res *StatusGetResponse, err error) {
- opts = slices.Concat(r.options, opts)
+ opts = slices.Concat(r.Options, opts)
path := "v1/status"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
diff --git a/status_test.go b/status_test.go
index 7ad9f97..b994db2 100644
--- a/status_test.go
+++ b/status_test.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
@@ -8,9 +8,9 @@ import (
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
func TestStatusGet(t *testing.T) {
@@ -22,36 +22,13 @@ func TestStatusGet(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
_, err := client.Status.Get(context.TODO())
if err != nil {
- var apierr *sapient.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestStatusGet(t *testing.T) {
- t.Skip("Mock server tests are disabled")
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := sapient.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Status.Get(context.TODO())
- if err != nil {
- var apierr *sapient.Error
+ var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
diff --git a/usage_test.go b/usage_test.go
index 7d15581..02f83b1 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -1,15 +1,15 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package sapient_test
+package githubcomusesapientgosdk_test
import (
"context"
"os"
"testing"
- "github.com/stainless-sdks/sapient-go"
- "github.com/stainless-sdks/sapient-go/internal/testutil"
- "github.com/stainless-sdks/sapient-go/option"
+ "github.com/usesapient/go-sdk"
+ "github.com/usesapient/go-sdk/internal/testutil"
+ "github.com/usesapient/go-sdk/option"
)
func TestUsage(t *testing.T) {
@@ -21,7 +21,7 @@ func TestUsage(t *testing.T) {
if !testutil.CheckTestServer(t, baseURL) {
return
}
- client := sapient.NewClient(
+ client := githubcomusesapientgosdk.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
diff --git a/workflow.go b/workflow.go
deleted file mode 100644
index be787b6..0000000
--- a/workflow.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/param"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
-)
-
-// WorkflowService contains methods and other services that help with interacting
-// with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewWorkflowService] method instead.
-type WorkflowService struct {
- options []option.RequestOption
-}
-
-// NewWorkflowService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewWorkflowService(opts ...option.RequestOption) (r WorkflowService) {
- r = WorkflowService{}
- r.options = opts
- return
-}
-
-// Create Workflow
-func (r *WorkflowService) New(ctx context.Context, body WorkflowNewParams, opts ...option.RequestOption) (res *WorkflowResponse, err error) {
- opts = slices.Concat(r.options, opts)
- path := "v1/workflows"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-// Retrieve Workflow
-func (r *WorkflowService) Get(ctx context.Context, workflowID string, opts ...option.RequestOption) (res *WorkflowResponse, err error) {
- opts = slices.Concat(r.options, opts)
- if workflowID == "" {
- err = errors.New("missing required workflow_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/workflows/%s", url.PathEscape(workflowID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-// Run Workflow
-func (r *WorkflowService) Run(ctx context.Context, workflowID string, body WorkflowRunParams, opts ...option.RequestOption) (res *WorkflowRunResponse, err error) {
- opts = slices.Concat(r.options, opts)
- if workflowID == "" {
- err = errors.New("missing required workflow_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/workflows/%s/run", url.PathEscape(workflowID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type WorkflowResponse struct {
- ID string `json:"id" api:"required"`
- Name string `json:"name" api:"required"`
- CreatedAt string `json:"created_at" api:"nullable"`
- Description string `json:"description" api:"nullable"`
- Metadata map[string]any `json:"metadata"`
- Steps []map[string]any `json:"steps"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- ID respjson.Field
- Name respjson.Field
- CreatedAt respjson.Field
- Description respjson.Field
- Metadata respjson.Field
- Steps respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r WorkflowResponse) RawJSON() string { return r.JSON.raw }
-func (r *WorkflowResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type WorkflowRunResponse struct {
- RunID string `json:"run_id" api:"required"`
- Status string `json:"status" api:"required"`
- WorkflowID string `json:"workflow_id" api:"required"`
- Job PublicJob `json:"job" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- RunID respjson.Field
- Status respjson.Field
- WorkflowID respjson.Field
- Job respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r WorkflowRunResponse) RawJSON() string { return r.JSON.raw }
-func (r *WorkflowRunResponse) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type WorkflowNewParams struct {
- Name string `json:"name" api:"required"`
- Description param.Opt[string] `json:"description,omitzero"`
- Metadata map[string]any `json:"metadata,omitzero"`
- Steps []map[string]any `json:"steps,omitzero"`
- paramObj
-}
-
-func (r WorkflowNewParams) MarshalJSON() (data []byte, err error) {
- type shadow WorkflowNewParams
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *WorkflowNewParams) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
-
-type WorkflowRunParams struct {
- // Workflow ID. Optional when passed in the URL.
- WorkflowID param.Opt[string] `json:"workflow_id,omitzero"`
- Watch param.Opt[bool] `json:"watch,omitzero"`
- Input map[string]any `json:"input,omitzero"`
- paramObj
-}
-
-func (r WorkflowRunParams) MarshalJSON() (data []byte, err error) {
- type shadow WorkflowRunParams
- return param.MarshalObject(r, (*shadow)(&r))
-}
-func (r *WorkflowRunParams) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}
diff --git a/workflowrun.go b/workflowrun.go
deleted file mode 100644
index 8e2d194..0000000
--- a/workflowrun.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package sapient
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/stainless-sdks/sapient-go/internal/apijson"
- "github.com/stainless-sdks/sapient-go/internal/requestconfig"
- "github.com/stainless-sdks/sapient-go/option"
- "github.com/stainless-sdks/sapient-go/packages/respjson"
-)
-
-// WorkflowRunService contains methods and other services that help with
-// interacting with the sapient API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewWorkflowRunService] method instead.
-type WorkflowRunService struct {
- options []option.RequestOption
-}
-
-// NewWorkflowRunService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewWorkflowRunService(opts ...option.RequestOption) (r WorkflowRunService) {
- r = WorkflowRunService{}
- r.options = opts
- return
-}
-
-// Retrieve Workflow Run
-func (r *WorkflowRunService) Get(ctx context.Context, runID string, opts ...option.RequestOption) (res *PublicJob, err error) {
- opts = slices.Concat(r.options, opts)
- if runID == "" {
- err = errors.New("missing required run_id parameter")
- return nil, err
- }
- path := fmt.Sprintf("v1/workflow-runs/%s", url.PathEscape(runID))
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type PublicJob struct {
- ID string `json:"id" api:"required"`
- Status string `json:"status" api:"required"`
- Type string `json:"type" api:"required"`
- CompletedAt string `json:"completed_at" api:"nullable"`
- Config map[string]any `json:"config"`
- CreatedAt string `json:"created_at" api:"nullable"`
- Error string `json:"error" api:"nullable"`
- Progress map[string]any `json:"progress" api:"nullable"`
- Result map[string]any `json:"result" api:"nullable"`
- StartedAt string `json:"started_at" api:"nullable"`
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
- JSON struct {
- ID respjson.Field
- Status respjson.Field
- Type respjson.Field
- CompletedAt respjson.Field
- Config respjson.Field
- CreatedAt respjson.Field
- Error respjson.Field
- Progress respjson.Field
- Result respjson.Field
- StartedAt respjson.Field
- ExtraFields map[string]respjson.Field
- raw string
- } `json:"-"`
-}
-
-// Returns the unmodified JSON received from the API
-func (r PublicJob) RawJSON() string { return r.JSON.raw }
-func (r *PublicJob) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
-}