typesafe

package
v0.9.52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL = "https://api.typesafe.ai"
	DefaultTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	*providerhttp.StatusError
	Method  string
	Path    string
	Message string
}

APIError reports a non-successful TypeSafe API response.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type Answer

type Answer struct {
	Type          string                     `json:"type"`
	Choice        *string                    `json:"choice,omitempty"`
	Score         *float64                   `json:"score,omitempty"`
	Noul          *float64                   `json:"noul,omitempty"`
	Confidence    *float64                   `json:"confidence,omitempty"`
	Probabilities map[string]float64         `json:"probabilities,omitempty"`
	Legend        map[string]json.RawMessage `json:"legend,omitempty"`
}

Answer is a TypeSafe primitive answer. Fields are populated according to Type.

func (*Answer) UnmarshalJSON

func (a *Answer) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects null numeric probability values.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a native HTTP client for the TypeSafe System One API.

func NewClient

func NewClient(opts Options) (*Client, error)

NewClient creates a TypeSafe client.

func (*Client) Classify

func (c *Client) Classify(ctx context.Context, req Request) (*Response, error)

Classify evaluates a state against typed questions.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) (*ModelsResponse, error)

ListModels lists models available to the account.

type Model

type Model struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	ReleaseDate string `json:"release_date"`
}

Model describes an available TypeSafe model.

type ModelsResponse

type ModelsResponse struct {
	Models []Model         `json:"models"`
	Raw    json.RawMessage `json:"-"`
}

ModelsResponse is the /v1/models response.

type Options

type Options struct {
	APIKey  string
	BaseURL string
	Timeout time.Duration
}

Options configures a TypeSafe API client.

type Question

type Question struct {
	Type         string          `json:"type"`
	Instructions json.RawMessage `json:"instructions"`
	Criteria     json.RawMessage `json:"criteria,omitempty"`
}

Question describes one typed TypeSafe question.

type Request

type Request struct {
	State     json.RawMessage     `json:"state"`
	Model     string              `json:"model"`
	Questions map[string]Question `json:"questions"`
}

Request is the /v1/systemone classification request.

func (Request) Validate

func (r Request) Validate() error

Validate checks the request before it is sent to TypeSafe.

type Response

type Response struct {
	Model   string            `json:"model"`
	Answers map[string]Answer `json:"answers"`
	Usage   Usage             `json:"usage"`
	Raw     json.RawMessage   `json:"-"`
}

Response is the /v1/systemone response.

type Usage

type Usage struct {
	InputTokens  *int `json:"input_tokens,omitempty"`
	OutputTokens *int `json:"output_tokens,omitempty"`
}

Usage contains token usage reported by TypeSafe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL