Documentation
¶
Overview ¶
Package jev provides a client for the TypeSafe "Jev" classification API (POST https://api.typesafe.ai/v1/systemone). It is used by internal/classify to classify documents (SMS, Gmail, call transcripts) into a segment (choice question) and a retention score (score question).
The client never logs request or response bodies — both may contain personal message content — only shapes and counts (see guides/... personal-data logging policy referenced by internal/worker/classification_worker.go).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChoiceAnswer ¶
type ChoiceAnswer struct {
Choice string `json:"choice"`
Probabilities map[string]float64 `json:"probabilities"`
Confidence float64 `json:"confidence"`
}
ChoiceAnswer is Jev's answer to a QuestionChoice question.
func (ChoiceAnswer) Probability ¶
func (a ChoiceAnswer) Probability() float64
Probability returns the probability Jev assigned to the chosen option, preferring Confidence (the top-choice probability field) and falling back to Probabilities[Choice] when Confidence is unset. Returns 0 when neither is available — callers must treat 0 as "no confidence", never as a disposable-eligible high-confidence answer.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a TypeSafe Jev API client.
func New ¶
New constructs a Client. apiKey may be empty — Enabled() reports false in that case and callers must not invoke Classify. httpClient, when nil, defaults to a client with a 15s timeout.
func NewForTest ¶
NewForTest constructs a Client pointed at baseURL instead of the real Jev endpoint. Exported (not test-file-scoped) so other packages' tests — e.g. internal/classify's — can point a Classifier at an httptest.Server without internal/jev having to export its baseURL field for production use.
func (*Client) Classify ¶
func (c *Client) Classify(ctx context.Context, state string, questions map[string]Question) (*Response, error)
Classify sends state and questions to the Jev API and returns the decoded response. Retries up to maxRetries times, with a linear backoff (attempt * retryBackoffUnit), on HTTP 429 and 5xx responses and on network-level errors. state and questions are never logged — only the resulting error (which must never embed response bodies) may surface to callers' logs.
type Question ¶
type Question struct {
Type QuestionType `json:"type"`
Instructions string `json:"instructions"`
// Criteria is map[string]string for QuestionChoice (option -> description)
// or []string for QuestionScore (ordered score descriptions).
Criteria any `json:"criteria"`
}
Question is one entry of a classification Request's Questions map.
type QuestionType ¶
type QuestionType string
QuestionType identifies the shape of a Question's expected answer.
const ( // QuestionChoice asks Jev to pick one option from Criteria (a // map[string]string of option -> description) and answers with // ChoiceAnswer. QuestionChoice QuestionType = "choice" // QuestionScore asks Jev to rate the state against an ordered list of // Criteria descriptions (index = score) and answers with ScoreAnswer. QuestionScore QuestionType = "score" )
type Response ¶
type Response struct {
Answers map[string]json.RawMessage `json:"answers"`
Usage Usage `json:"usage"`
}
Response is a decoded POST /v1/systemone response. Individual answers are kept as raw JSON until Choice/Score is called with the expected question name, because the wire shape of answers[name] depends on the corresponding request Question's Type, which the Response itself does not carry.