mirror of
https://github.com/langchain-ai/langsmith-go.git
synced 2026-08-24 12:13:40 -04:00
348f070184
* codegen metadata * chore(internal): remove mock server code * chore: update mock server docs * fix: allow canceling a request while it is waiting to retry * codegen metadata * codegen metadata * codegen metadata * fix(internal): skip tests that depend on mock server * codegen metadata * codegen metadata * codegen metadata * codegen metadata * chore(internal): move custom custom `json` tags to `api` * feat(api): manual updates * codegen metadata * feat(api): manual updates * codegen metadata * feat(api): manual updates * codegen metadata * codegen metadata * feat(api): api update * codegen metadata * codegen metadata * feat(api): api update * feat(api): api update * codegen metadata * codegen metadata * codegen metadata * codegen metadata * feat(api): api update * codegen metadata * codegen metadata * codegen metadata * codegen metadata * codegen metadata * codegen metadata * chore(internal): codegen related update * codegen metadata * codegen metadata * feat(api): api update * codegen metadata * feat(api): manual updates removed endpoints not in openAPI spec * codegen metadata * codegen metadata * codegen metadata * feat(api): api update * codegen metadata * codegen metadata * feat(api): api update * chore(internal): codegen related update * chore(ci): skip uploading artifacts on stainless-internal branches * chore: update placeholder string * codegen metadata * codegen metadata * codegen metadata * codegen metadata * feat(api): api update * codegen metadata * codegen metadata * chore(internal): minor cleanup * chore(internal): use explicit returns * codegen metadata * chore(internal): use explicit returns in more places * codegen metadata * feat(api): api update * feat(api): api update * codegen metadata * codegen metadata * feat(api): api update * codegen metadata * chore(internal): tweak CI branches * codegen metadata * codegen metadata * codegen metadata * codegen metadata * codegen metadata * codegen metadata * codegen metadata * feat(api): api update * chore: change user client (#38) * feat(api): api update * codegen metadata * fix: type mismatch (#39) * codegen metadata * release: 0.2.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: ericdong-langchain <ericdong@langchain.dev>
117 lines
4.2 KiB
Go
117 lines
4.2 KiB
Go
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
|
|
package langsmith
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"reflect"
|
|
"slices"
|
|
"time"
|
|
|
|
"github.com/langchain-ai/langsmith-go/internal/apijson"
|
|
"github.com/langchain-ai/langsmith-go/internal/requestconfig"
|
|
"github.com/langchain-ai/langsmith-go/option"
|
|
"github.com/langchain-ai/langsmith-go/shared"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
// ExampleValidateService contains methods and other services that help with
|
|
// interacting with the langChain 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 [NewExampleValidateService] method instead.
|
|
type ExampleValidateService struct {
|
|
Options []option.RequestOption
|
|
}
|
|
|
|
// NewExampleValidateService 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 NewExampleValidateService(opts ...option.RequestOption) (r *ExampleValidateService) {
|
|
r = &ExampleValidateService{}
|
|
r.Options = opts
|
|
return
|
|
}
|
|
|
|
// Validate an example.
|
|
func (r *ExampleValidateService) New(ctx context.Context, opts ...option.RequestOption) (res *ExampleValidationResult, err error) {
|
|
opts = slices.Concat(r.Options, opts)
|
|
path := "api/v1/examples/validate"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return res, err
|
|
}
|
|
|
|
// Validate examples in bulk.
|
|
func (r *ExampleValidateService) Bulk(ctx context.Context, opts ...option.RequestOption) (res *[]ExampleValidationResult, err error) {
|
|
opts = slices.Concat(r.Options, opts)
|
|
path := "api/v1/examples/validate/bulk"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return res, err
|
|
}
|
|
|
|
// Validation result for Example, combining fields from Create/Base/Update schemas.
|
|
type ExampleValidationResult struct {
|
|
ID string `json:"id" api:"nullable" format:"uuid"`
|
|
CreatedAt time.Time `json:"created_at" api:"nullable" format:"date-time"`
|
|
DatasetID string `json:"dataset_id" api:"nullable" format:"uuid"`
|
|
Inputs map[string]interface{} `json:"inputs" api:"nullable"`
|
|
Metadata map[string]interface{} `json:"metadata" api:"nullable"`
|
|
Outputs map[string]interface{} `json:"outputs" api:"nullable"`
|
|
Overwrite bool `json:"overwrite"`
|
|
SourceRunID string `json:"source_run_id" api:"nullable" format:"uuid"`
|
|
Split ExampleValidationResultSplitUnion `json:"split" api:"nullable"`
|
|
UseSourceRunIo bool `json:"use_source_run_io"`
|
|
JSON exampleValidationResultJSON `json:"-"`
|
|
}
|
|
|
|
// exampleValidationResultJSON contains the JSON metadata for the struct
|
|
// [ExampleValidationResult]
|
|
type exampleValidationResultJSON struct {
|
|
ID apijson.Field
|
|
CreatedAt apijson.Field
|
|
DatasetID apijson.Field
|
|
Inputs apijson.Field
|
|
Metadata apijson.Field
|
|
Outputs apijson.Field
|
|
Overwrite apijson.Field
|
|
SourceRunID apijson.Field
|
|
Split apijson.Field
|
|
UseSourceRunIo apijson.Field
|
|
raw string
|
|
ExtraFields map[string]apijson.Field
|
|
}
|
|
|
|
func (r *ExampleValidationResult) UnmarshalJSON(data []byte) (err error) {
|
|
return apijson.UnmarshalRoot(data, r)
|
|
}
|
|
|
|
func (r exampleValidationResultJSON) RawJSON() string {
|
|
return r.raw
|
|
}
|
|
|
|
// Union satisfied by [ExampleValidationResultSplitArray] or [shared.UnionString].
|
|
type ExampleValidationResultSplitUnion interface {
|
|
ImplementsExampleValidationResultSplitUnion()
|
|
}
|
|
|
|
func init() {
|
|
apijson.RegisterUnion(
|
|
reflect.TypeOf((*ExampleValidationResultSplitUnion)(nil)).Elem(),
|
|
"",
|
|
apijson.UnionVariant{
|
|
TypeFilter: gjson.JSON,
|
|
Type: reflect.TypeOf(ExampleValidationResultSplitArray{}),
|
|
},
|
|
apijson.UnionVariant{
|
|
TypeFilter: gjson.String,
|
|
Type: reflect.TypeOf(shared.UnionString("")),
|
|
},
|
|
)
|
|
}
|
|
|
|
type ExampleValidationResultSplitArray []string
|
|
|
|
func (r ExampleValidationResultSplitArray) ImplementsExampleValidationResultSplitUnion() {}
|