jev

package
v0.2.76 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package jev provides a client for TypeSafe AI's Jev System One API.

Jev is a decision model, not an LLM: it evaluates state against named, typed questions and returns probabilities rather than generated text.

Index

Constants

View Source
const (
	// DefaultBaseURL is the TypeSafe AI API root.
	DefaultBaseURL = "https://api.typesafe.ai"
	// DefaultModel tracks TypeSafe's current Jev alias.
	DefaultModel = "jev-latest"
)

Variables

View Source
var (
	// ErrNoAPIKey means a request was attempted without a TypeSafe API key.
	ErrNoAPIKey = errors.New("jev: no API key configured")
	// ErrInvalidRequest means the request cannot satisfy the System One contract.
	ErrInvalidRequest = errors.New("jev: invalid request")
	// ErrInvalidResponse means TypeSafe returned a response that does not match the request.
	ErrInvalidResponse = errors.New("jev: invalid response")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	RequestID  string
	Message    string
}

APIError describes a non-success response from TypeSafe AI.

func (*APIError) Error

func (e *APIError) Error() string

type Answer

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

Answer is one typed answer returned by Jev. Only fields matching Type are set.

type ChoiceQuestion

type ChoiceQuestion struct {
	Type         QuestionType           `json:"type"`
	Instructions interface{}            `json:"instructions,omitempty"`
	Criteria     map[string]interface{} `json:"criteria"`
}

ChoiceQuestion asks Jev to select one of the named criteria.

type Client

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

Client calls TypeSafe AI's System One endpoint.

func NewClient

func NewClient(apiKey string, options ...Option) *Client

NewClient creates a Jev client. The API key is only sent to the configured base URL.

func (*Client) SystemOne

func (c *Client) SystemOne(ctx context.Context, request Request) (*Response, error)

SystemOne evaluates state against all named questions in a single Jev call.

type NoulCriteria

type NoulCriteria struct {
	True  interface{} `json:"true,omitempty"`
	False interface{} `json:"false,omitempty"`
}

NoulCriteria optionally describes the true and false outcomes.

type NoulQuestion

type NoulQuestion struct {
	Type         QuestionType  `json:"type"`
	Instructions interface{}   `json:"instructions,omitempty"`
	Criteria     *NoulCriteria `json:"criteria,omitempty"`
}

NoulQuestion asks for the probability that a yes/no judgment is true.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the TypeSafe API root, primarily for gateways and tests.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient replaces the HTTP transport. The client is used as supplied.

func WithModel

func WithModel(model string) Option

WithModel changes the default model used when Request.Model is empty.

func WithRetry

func WithRetry(maxRetries int, initialBackoff time.Duration) Option

WithRetry configures retries after the initial attempt and their first delay. Only connection failures, HTTP 408/429, and HTTP 5xx responses are retried. No single backoff sleep exceeds maxRetryDelay, including one requested by a Retry-After response header.

type Question

type Question interface {
	// contains filtered or unexported methods
}

Question is implemented by the three Jev question primitives.

func Choice

func Choice(instructions interface{}, criteria map[string]interface{}) Question

Choice creates a question whose answer must be one of the criteria labels.

func Noul

func Noul(instructions interface{}) Question

Noul creates a yes/no question.

func NoulWithCriteria

func NoulWithCriteria(instructions, whenTrue, whenFalse interface{}) Question

NoulWithCriteria creates a yes/no question with descriptions of both outcomes.

func Score

func Score(instructions interface{}, criteria ...interface{}) Question

Score creates an ordered rubric question. The first criterion is score zero.

type QuestionType

type QuestionType string

QuestionType identifies the shape of a Jev question and its answer.

const (
	// QuestionTypeNoul is a yes/no judgment returned as the probability of yes.
	QuestionTypeNoul QuestionType = "noul"
	// QuestionTypeChoice selects one label from caller-provided criteria.
	QuestionTypeChoice QuestionType = "choice"
	// QuestionTypeScore evaluates state against an ordered rubric.
	QuestionTypeScore QuestionType = "score"
)

type Request

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

Request evaluates State against one or more named Questions.

type Response

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

Response contains answers keyed by request question name.

type ScoreQuestion

type ScoreQuestion struct {
	Type         QuestionType  `json:"type"`
	Instructions interface{}   `json:"instructions,omitempty"`
	Criteria     []interface{} `json:"criteria"`
}

ScoreQuestion asks Jev to evaluate state against an ordered rubric.

type Usage

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

Usage reports request token consumption.

Jump to

Keyboard shortcuts

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