Documentation
¶
Overview ¶
Package tutor is the AI side of NovaTrail's tutor, a library that api calls in its own process. It reads the learner's work into an observation, reviews the working and words the tutor's replies, through the AI routes and models it admits, and reports each call's usage. It decides no verdict and stores nothing, and its requests carry no identifier of the learner or the account.
The AI providers are reached only through the port in package provider. The eval runner, cmd/tutor-eval, runs on the same code.
Example ¶
api makes the library once, when it starts: spec's admission table, the facts of its deployment, the least stage of its learners, the platform's keys, which it reads from Secret Manager, and the adapters of the providers it calls — here Anthropic's alone, so that its build carries no other provider's SDK. Before an attempt it asks which models would read the learner's work, and whether any would.
package main
import (
"fmt"
"log"
"github.com/altnovatrail/spec/types/admissionv0"
"github.com/altnovatrail/tutor"
"github.com/altnovatrail/tutor/admission"
"github.com/altnovatrail/tutor/provider"
"github.com/altnovatrail/tutor/provider/claude"
)
func main() {
table, err := admission.Platform()
if err != nil {
log.Fatal(err)
}
facts, err := admission.ReadFacts(table, []byte("anthropic:\n data_processing_agreement: [adult]\n minimal_retention: [adult]\n"))
if err != nil {
log.Fatal(err)
}
lib, err := tutor.New(tutor.Config{Table: table, Facts: facts, Least: admission.StageAuthor,
Keys: map[admissionv0.Provider]string{"anthropic": "the platform's key"},
Adapters: map[admissionv0.Provider]provider.Dial{"anthropic": claude.Dial}})
if err != nil {
log.Fatal(err)
}
route := tutor.Route{AI: admissionv0.AiRoutePlatformAi, Category: admissionv0.AgeCategoryAdult}
entry, answer, err := lib.Choose(admissionv0.CapabilityHandwritingReading, route)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer.Admitted, entry.Stage, entry.Models[0].Name(), "+", entry.Models[1].Name())
child := tutor.Route{AI: admissionv0.AiRoutePlatformAi, Category: admissionv0.AgeCategoryUnder13}
_, answer, _ = lib.Choose(admissionv0.CapabilityHandwritingReading, child)
fmt.Println(answer.Admitted, *answer.Reason, *answer.Fact)
}
Output: true author claude-opus-5-5 high + claude-haiku-5-5 medium false fact_missing data_processing_agreement
Index ¶
- Constants
- func CoversDrawn(frame *observationv1.CropBox, drawn []*observationv1.CropBox) bool
- func PaperBreach(text, language string, tasks []PaperWordsTask, own []string) string
- func PaperFallback(rung int, language string) string
- type BoxCrop
- type Call
- type CallPrice
- type Config
- type CorrectAnswer
- type CorrectRequest
- type CriterionMark
- type Debug
- type DebugCall
- type EssayRead
- type EssayReading
- type KeyCheck
- type Kind
- type LimitReason
- type ModelPrice
- type Outcome
- type OwnKey
- type PaperAsk
- type PaperReading
- type PaperTask
- type PaperWordsRequest
- type PaperWordsTask
- type Reading
- type Route
- type RubricAssessed
- type RubricAssessment
- type SheetRead
- type SheetReading
- type StatementRead
- type StatementTask
- type TaskFinding
- type TaskToSolve
- type TasksFound
- type TasksSolved
- type Trap
- type Tutor
- func (t *Tutor) AssessEssay(ctx context.Context, r RubricAssessment) RubricAssessed
- func (t *Tutor) CheckKey(ctx context.Context, r Route) (KeyCheck, error)
- func (t *Tutor) Choose(c admissionv0.Capability, r Route) (admission.Entry, admission.Answer, error)
- func (t *Tutor) ChooseCall(c Call, r Route) (admission.Entry, admission.Answer, error)
- func (t *Tutor) CorrectAnswerWords(ctx context.Context, c CorrectRequest) CorrectAnswer
- func (t *Tutor) FindTasks(ctx context.Context, f TaskFinding) TasksFound
- func (t *Tutor) PaperWords(ctx context.Context, w PaperWordsRequest) WordsAnswer
- func (t *Tutor) Price(c Call, r Route) (CallPrice, admission.Answer, error)
- func (t *Tutor) Prices() ([]ModelPrice, error)
- func (t *Tutor) ReadEssay(ctx context.Context, r EssayReading) EssayRead
- func (t *Tutor) ReadPaper(ctx context.Context, r PaperReading) SheetRead
- func (t *Tutor) ReadSheet(ctx context.Context, r SheetReading) SheetRead
- func (t *Tutor) ReadStatement(ctx context.Context, p PaperTask) StatementRead
- func (t *Tutor) ReadWorkbook(ctx context.Context, r WorkbookReading) WorkbookRead
- func (t *Tutor) SolveTask(ctx context.Context, p PaperTask, tasks []TaskToSolve) TasksSolved
- func (t *Tutor) Words(ctx context.Context, w WordsRequest) WordsAnswer
- type Usage
- type WordsAnswer
- type WordsRequest
- type WorkbookRead
- type WorkbookReading
Examples ¶
Constants ¶
const ( // PaperOpening is the opening question, before the first wrong answer, from the task's crop as // printed, PaperWordsRequest.Statement. PaperOpening = PaperAsk(paperwords.AskOpening) // PaperRung is the words of a rung, from the crop of the work, PaperWordsRequest.Crop, with the // box of the first mistake. PaperRung = PaperAsk(paperwords.AskRung) // PaperAgain is the rung put another way, with no picture. PaperAgain = PaperAsk(paperwords.AskAgain) )
The kinds of words of a task from paper.
const ( BreachLeak = "leak" BreachForm = "form" )
The causes of a fallback text of a task from paper's words that PaperBreach gives.
const ( LimitOwner = provider.LimitOwner LimitTier = provider.LimitTier LimitBalance = provider.LimitBalance LimitBilling = provider.LimitBilling )
The reasons of a limit reached.
Variables ¶
This section is empty.
Functions ¶
func CoversDrawn ¶ added in v0.1.59
func CoversDrawn(frame *observationv1.CropBox, drawn []*observationv1.CropBox) bool
CoversDrawn says whether a frame found covers one of the frames the learner drew, its overlap at least sameAsDrawn of their union: the finding drops it, and the learner's own stays.
func PaperBreach ¶ added in v0.1.59
func PaperBreach(text, language string, tasks []PaperWordsTask, own []string) string
PaperBreach is why the words of a task from paper may not reach the learner, or "" when they may: empty words or a broken form (words.Hint, with the statements' letters allowed) BreachForm, and a key of a task of the crop in them, or a number of own — the model's own answers of the opening question, which nothing else keeps — BreachLeak. The leak check is module-kit's, with the keys as checks of their kind and the statements as the text the learner sees with them: a key the statement prints is not searched for. A text that both leaks and breaks its form is a leak.
func PaperFallback ¶ added in v0.1.59
PaperFallback is the fallback text of the words of a task from paper in a language of the interface, by its tag: the opening question at rung 0, and at rungs 1 to 3 the rung's template of the measurement of hints (hint.Fallback), which the measured languages have, the second serving the third, which has no simpler case of an author.
Types ¶
type BoxCrop ¶ added in v0.1.24
BoxCrop is the crop of a filled box of a workbook page, as app sends it: the places of its item and of the box among the item's boxes, from 1, and the PNG of its strokes alone, without the box's frame and the print of its line.
type Call ¶ added in v0.1.24
type Call string
Call is a kind of call of the library: the reading of a sheet, of a workbook page and of an essay, the assessment of an essay by its rubric, the call of the words, with the work and without it, and the words after a correct answer, the finding of the tasks on the photo of a page from paper, and of a task from paper the reading of its statement into a formula, its solution and the reading of the work on it. Each serves a capability with a prompt of its own, and an entry of the list admits it only when it measured that prompt.
const ( CallSheet Call = "sheet" CallWorkbook Call = "workbook" CallWords Call = "words" CallHint Call = "hint" CallEssay Call = "essay" CallRubric Call = "rubric" CallCorrect Call = "correct" CallFinding Call = "finding" // The calls of a task from paper: its statement into a formula, its solution, and the work. CallStatement Call = "statement" CallSolving Call = "solving" CallPaper Call = "paper" // The tutor's words on a task from paper: with the work, the words of a rung, and without it, // the opening question and a rung put another way. CallPaperWords Call = "paper_words" CallPaperHint Call = "paper_hint" )
The kinds of call of the library.
type CallPrice ¶ added in v0.1.24
CallPrice is what a call of a capability is expected to cost and can cost at most, in US dollars, over every model of the entry the call asks — both readers of a pair, or the one reader of ReadingSingle —, and api reserves the quota of platform AI by them before the call. The worst is the most input of the kind, each token at the higher of its price and that of a write to the cache, and its most output, and as much again for the request ahead of it, with its own most output. Expected is false when a model of the entry has no expected tokens; Worst is false when the prices do not hold the worst, and api takes the value of its own config then.
type Config ¶
type Config struct {
Table *admission.Table
Facts admission.Facts
Least admission.Stage
Reading Reading
Keys map[admissionv0.Provider]string
Adapters map[admissionv0.Provider]provider.Dial
Debug bool
}
Config is what api gives tutor when it starts: spec's admission table, the deployment's facts, the least stage of admission its learners take — admission.StageAuthor where the operator names it, as novatrail does for adults —, the platform's keys at the AI providers, which api reads from Secret Manager, and the adapters of the providers whose models the service calls, such as claude.Dial of package provider/claude. The library builds no adapter in, so that a service carries the SDKs of the adapters it gives alone. A provider with no adapter here is no route at all, and one with no key no route of platform AI: Choose takes none of its models. Reading is how the library reads a sheet and a workbook page, by the pair or by one reader; an empty one is the pair. Debug lets a call's route carry the debug mode, Route.Debug, which api sets for an account with the right to it, on a local run or on the deployment; off, such a route fails.
type CorrectAnswer ¶ added in v0.1.34
CorrectAnswer is what the call of the words after a correct answer gives: the words, when Outcome is Answered.
type CorrectRequest ¶ added in v0.1.34
type CorrectRequest struct {
Route Route
Task *open.Task
Crop []byte
Key string
Solution []string
Techniques []string
Language string
Style string
}
CorrectRequest is a call of the words after a correct answer: the praise of a step of the solution and one question on the technique that helped, after the program's verdict is correct, as GetCorrectAnswerWords of spec's contract asks them.
- Crop is the PNG of the crop of the work; nil when the task's answer slots are only choices, and the learner chose the answer with no work to send;
- Key and Solution are the task's — of a choice, the key is the option that is right — and Techniques its ways to solve it, which may be none: the question then asks how the answer was found;
- Language is the module's language of explanations, by its tag; Style only what of the presentation style changes the words.
The words are checked by api for leaks and by words.Correct for their form before they reach the learner; when they fail, the learner gets no words, as there is no fallback text for them.
type CriterionMark ¶ added in v0.1.24
CriterionMark is the assessment of a criterion: what in the essay the model judged it by, and whether the essay meets it, nil when it has no assessment — a criterion the answer has no judgement of, or two.
type Debug ¶ added in v0.1.59
type Debug struct {
// First serves every call of a task from paper — CallFinding, CallStatement, CallSolving,
// CallPaper and the tutor's words, CallPaperWords and CallPaperHint —; nil leaves each its
// models of the list.
First *admission.Model
// Second reads the work beside the first reader, CallPaper alone, the two read as a pair is;
// nil leaves one reader.
Second *admission.Model
// Record gets each call of a model of the call, once the models have answered, in their order,
// from the goroutine of the call.
Record func(DebugCall) `json:"-"`
}
Debug is the debug mode, in a call's Route: the models that serve the calls of a task from paper in place of those of the list, and a record of each call of a model. api puts it in the route of an account with the right to the mode alone, on a local run or on the deployment; the library takes it only when Config.Debug is on, and on any other call it changes nothing.
type DebugCall ¶ added in v0.1.59
type DebugCall struct {
Call Call
Reader int
Attempt int
Model admission.Model
Answer string
Usage *Usage
Err error
}
DebugCall is one call of a model in the debug mode: the kind of the library's call; the reader of the work, 1 or 2, and 0 for any other call; the model's place among the attempts of its call, 1, 2 or 3; the model as it was asked, its effort and thinking with it; what the model returned, as it returned it; its usage when it came back with tokens; and what failed. The answer is the model's reading of the learner's work: it goes to the account that set the mode alone, never to a log.
type EssayRead ¶ added in v0.1.24
type EssayRead struct {
Observation *observationv1.Observation
Outcome Outcome
}
EssayRead is what a reading of an essay gives: the observation of its answer slot bound to the sheet — the text as it is written, or unreadable when the essay as a whole cannot be read, which does not reach the assessment — when Outcome is Answered, and otherwise none.
type EssayReading ¶ added in v0.1.24
EssayReading is an essay to read, the first of the two calls of a task with a rubric: the PNG of the crop of the sheet, the open view of its task and the route. The model sees the crop alone, without the topic and the rubric.
type KeyCheck ¶ added in v0.1.24
type KeyCheck int
KeyCheck is how the check of an own key ended, as spec's contract names it (OwnKeyCheck): the provider took it; the key is wrong, revoked or expired; it is right and has no rights to a model it is needed for; the provider is closed to an own key at the profile, and no call went; or the provider did not answer, and the check says nothing of the key.
The ends of a check of a key.
type Kind ¶
type Kind int
Kind is how a call of the library ended: the models answered; AI failed; a provider refused for a limit, a balance or billing, whose reason Outcome.Limit names; the admission refused the call, before any model was asked; or the provider refused the own key, wrong or revoked. None but the first is the learner's mistake.
type LimitReason ¶
LimitReason is why a provider refused for a limit: one only the owner of the key can lift, each in its own way. It is the adapters' own, provider.Limit, so that a reason they tell is one the library gives.
type ModelPrice ¶ added in v0.1.24
type ModelPrice struct {
Provider admissionv0.Provider
Model string
Prices provider.Prices
}
ModelPrice is a line of the table of prices: a model of the list of admitted models, by its provider and exact ID, with its prices and the day they were read.
type Outcome ¶
type Outcome struct {
Kind Kind
Limit LimitReason
AccessReturns time.Time
Admission admission.Answer
Usage []Usage
Err error
}
Outcome is how a call of the library ended: its kind; the reason of a limit, and when access returns, where the provider's terms say it — at Anthropic, the cap of the tier, at 00:00 UTC on the first day of the next month by the provider's clock —, zero where they do not, which api gives the key's owner as access_returns; the admission's answer, which on NotAdmitted refuses; and a record of usage for each call of a model that came back, in the order of the models, none on NotAdmitted. Err says what failed, for the logs: it carries no content and no key.
type OwnKey ¶
type OwnKey struct {
// contains filtered or unexported fields
}
OwnKey is the key of an account owner who learns, with its provider. It lives only in the memory of the request: its fields are unexported, it prints as its provider alone with any verb, and as JSON it is nothing. The key itself stands behind a pointer, so that even an OwnKey printed field by field, as fmt prints an unexported field of another struct, shows an address rather than the key.
func NewOwnKey ¶
func NewOwnKey(p admissionv0.Provider, key string) *OwnKey
NewOwnKey is the own key of a provider.
func (*OwnKey) Provider ¶
func (k *OwnKey) Provider() admissionv0.Provider
Provider is the key's provider.
type PaperAsk ¶ added in v0.1.59
type PaperAsk int
PaperAsk is what a call of the words of a task from paper asks for.
type PaperReading ¶ added in v0.1.59
PaperReading is the work on a task from paper to read: the PNG of the crop of the work — the tracing paper at its place with the strokes on it, and the sheet's visible strokes —, as app sends it (PaperWork.crop), the statements of the tasks on it, in order, as the reading of the statement gave them, and the route. The models see the crop and the statements, never a key.
type PaperTask ¶ added in v0.1.59
PaperTask is a task from the learner's paper whose key is derived: the task's crop as app cut it from the photo of the page, without the learner's strokes, a JPEG or a PNG of at most 4 MiB (PaperWork.statement of spec's contract), and the route. The models see the printed task alone.
type PaperWordsRequest ¶ added in v0.1.59
type PaperWordsRequest struct {
Route Route
Ask PaperAsk
Statement []byte
Crop []byte
Tasks []PaperWordsTask
Task int
Rung int
Language string
Style string
Asked []string
}
PaperWordsRequest is a call of the tutor's words on a task from paper:
- Ask is what to word;
- Statement is the task's crop as printed, a JPEG or a PNG of at most 4 MiB, for PaperOpening alone; Crop the PNG of the crop of the work, sent again, as the server keeps none, for PaperRung alone;
- Tasks are the tasks of the crop, in their order;
- Task is the number of the rung's task among them, from 1, and Rung the rung api picked, 1 to 3, but for PaperOpening;
- Language is the language of the profile's interface, by its tag; Style only what of the presentation style changes the words;
- Asked are the questions the tutor has already asked on the task, in order.
The words are checked by api for leaks and for their form (PaperBreach), before they reach the learner; api gives the fallback text in their place when they fail (PaperFallback).
type PaperWordsTask ¶ added in v0.1.59
PaperWordsTask is a task of the crop as the words see it: its statement as printed, its key, or nil while the program has derived none, and the value read of the learner's answer, or "".
type Reading ¶ added in v0.1.45
type Reading string
Reading is how the library reads the handwriting of a sheet and of a workbook page, which api chooses: ReadingPair, both readers of the entry chosen, the strong one first, whose readings module-kit joins, or ReadingSingle, one reader, Haiku 5.5 at medium, the pair's second, whose observation is the reading. The reading of an essay is one reader in both.
type Route ¶
type Route struct {
AI admissionv0.AiRoute
Category admissionv0.AgeCategory
Own *OwnKey
Debug *Debug
}
Route is what every call of the library carries besides its work: the AI route, the learner's age category, on the own key the key with its provider, and for an account with its right the debug mode. It names no learner, no account and no adult.
type RubricAssessed ¶ added in v0.1.24
type RubricAssessed struct {
Criteria []CriterionMark
Feedback string
Outcome Outcome
}
RubricAssessed is what an assessment by the rubric gives: a mark for each criterion, in the rubric's order, and one feedback, which api checks by the rule of the feedback (words.Feedback) before it reaches the learner. When the call failed, every criterion is without an assessment, and there is no feedback.
type RubricAssessment ¶ added in v0.1.24
type RubricAssessment struct {
Route Route
Text string
Topic string
Criteria []string
Style string
Language string
}
RubricAssessment is an essay to assess by the criteria of its task's rubric, the second of the two calls of a task with a rubric: the text the reading of the essay wrote down, the statement of the task as its topic, the criteria of the rubric in their order, in the module's explanation language, the presentation style — only what of it changes the words —, the language of the feedback by its tag, and the route. The model sees the text in the block <essay> and the topic and the criteria in the block of the task's data, and no picture.
type SheetRead ¶ added in v0.1.16
type SheetRead struct {
Observations []*observationv1.Observation
Outcome Outcome
}
SheetRead is what a reading of a sheet gives when Outcome is Answered: by the pair, the observation of each reader, in the order of the pair, the strong reader first — module-kit joins them and gives the verdict —; in ReadingSingle, the one observation of the one reader. Otherwise it gives none: by the pair, tutor gives both or the outcome, never one.
type SheetReading ¶ added in v0.1.16
SheetReading is a handwriting sheet to read: the PNG of the crop of its visible strokes, as app sends it (the contract between app and api, SheetWork), the open view of its task, and the route. The model sees the crop and the statement, never the key.
type StatementRead ¶ added in v0.1.59
type StatementRead struct {
Tasks []StatementTask
Outcome Outcome
}
StatementRead is what the reading of a statement gives when Outcome is Answered: the tasks on the crop, from none to 20, in the order of the page — one, or each of a column of sums framed together.
type StatementTask ¶ added in v0.1.59
StatementTask is a task the reading of a statement found on the crop: its statement as printed, at most 200 bytes, and its formula, or "" when the statement is no formula. Whether the solver takes a formula module-kit says.
type TaskFinding ¶ added in v0.1.59
type TaskFinding struct {
Route Route
Photo []byte
Request string
Found []*observationv1.CropBox
Drawn []*observationv1.CropBox
}
TaskFinding is a call that finds the tasks on the photo of a page from the learner's paper: the photo is a JPEG or a PNG of at most 4 MiB, as app sent it. With the learner's request about the page come the frames on it now, in whole thousandths of the photo: those the AI found before, which the answer replaces, and those the learner drew, which stay. api has checked their bounds; without a request the frames are not sent.
type TaskToSolve ¶ added in v0.1.59
TaskToSolve is a task of the crop whose key AI derives: its number on the crop, from 1, and its statement as the reading of the statement gave it.
type TasksFound ¶ added in v0.1.59
type TasksFound struct {
Frames []*observationv1.CropBox
Turn int
Outcome Outcome
}
TasksFound is what the finding gives: the task frames, in whole thousandths of the photo turned by Turn, in the order of the page, top to bottom, when Outcome is Answered — none when the model found no task —; and the turn, in whole degrees clockwise from -179 to 180, by which the photo was turned for its page to read upright (provider.Turn), 0 with a request and with no frames.
type TasksSolved ¶ added in v0.1.59
TasksSolved is what the solution of tasks gives when Outcome is Answered: the Answer of AI of each task asked, by its number, a number or a choice, or nil when the model found no one answer of these kinds. module-kit holds each to the rules of a key (paper.Key): an answer that breaks one gives its task no key, as nil does.
type Trap ¶ added in v0.1.18
type Trap struct {
ID, Description string
}
Trap is a trap of a task that a model may name, by its ID, with its description from the catalogue of traps, which api takes through module-kit.
type Tutor ¶
type Tutor struct {
// contains filtered or unexported fields
}
Tutor is the library as api holds it: made once, at the start, and called by many requests at once. It keeps nothing of a call.
func New ¶
New makes the library of a config. It refuses a config with no table, a least stage that is neither of the two — an empty one is the stage full, the strict one —, a mode of reading that is neither of the two — an empty one is the pair —, and a key of a provider the config gives no adapter of, which would leave every model of the provider unchosen with no word of why.
func (*Tutor) AssessEssay ¶ added in v0.1.24
func (t *Tutor) AssessEssay(ctx context.Context, r RubricAssessment) RubricAssessed
AssessEssay assesses the text of an essay by the criteria of the rubric, by the one model admitted for the assessment by a rubric with the prompt of the assessment of a text. The criteria go to the model by their numbers, from 1. Until an entry of the list measured the prompt, the assessment is NotAdmitted: its target comes from the measurement on the essays of volunteers (П-16). An answer off the schema fails the call; a criterion it judges twice, or not at all, is without an assessment, as is every criterion of a failed call.
func (*Tutor) CheckKey ¶ added in v0.1.24
CheckKey checks an own key when its owner connects it: api checks it through tutor and never calls a provider round it. The route is the own key's, with the profile's age category. The key is checked for every model the library would call with it — the models each kind of call chooses (ChooseCall), the hint without the work among them, both readers of a pair or the one reader of ReadingSingle —, each by a request of the provider without any learner's content that costs nothing (provider.Model.Check). When none is open, the provider is closed to an own key at the profile, and no call goes. One wrong key is the end, then one model without rights, then a provider that did not answer. A refusal for a limit means the provider took the key, and the limit shows on the calls. The error says what failed, for the logs, and never holds the key.
func (*Tutor) Choose ¶
func (t *Tutor) Choose(c admissionv0.Capability, r Route) (admission.Entry, admission.Answer, error)
Choose chooses the models of a capability for a route (admission.Table.Select), the first entry of the capability whatever prompt it measured. A call of the library chooses by its kind, which names its prompt too (ChooseCall): that is the one api calls before an attempt, with the same answer the call gets while the config is the same. It takes only the models of the providers the config gives an adapter of: on the own key only those of the key's provider, and on platform AI only those of the providers it holds a key of. It refuses a route whose key does not fit it. The entry holds every model it has: the mode of reading is of a kind of call, and ChooseCall applies it.
func (*Tutor) ChooseCall ¶ added in v0.1.24
ChooseCall chooses the models of a kind of call of the library for a route: of its capability, of the entries that measured its prompt (admission.Table.SelectPrompt), and for the words with the work only with the hint on the same model. api calls it before an attempt, and the call before it calls a model. The entry holds only the models the call asks: the first alone for a call of one model, and the one reader of ReadingSingle for a reading of a sheet or a page.
func (*Tutor) CorrectAnswerWords ¶ added in v0.1.34
func (t *Tutor) CorrectAnswerWords(ctx context.Context, c CorrectRequest) CorrectAnswer
CorrectAnswerWords asks the admitted model of the words after a correct answer (CallCorrect) for them, with the work or without it. A task without words, a crop that is no PNG of a sheet, a language with no tag and no style of presentation fail before any call; an answer off the schema fails the call.
func (*Tutor) FindTasks ¶ added in v0.1.59
func (t *Tutor) FindTasks(ctx context.Context, f TaskFinding) TasksFound
FindTasks asks the admitted models of the finding (CallFinding) for the tasks on the photo of a page, one at a time, a later one only when the one before failed or found no task. Without the learner's request each model is asked first which way up the page lies, and the photo is turned upright by its answer before the tasks are found on it; with one, the photo is app's, already turned. The adapter fits the photo to the size its model takes unshrunk, and it goes as a JPEG without the metadata of its file (provider.Photo), decoded once for every model and turned once for each angle. A photo that is no JPEG or PNG fails before any call; an answer off the schema fails the attempt. A box with no area on the photo is no frame, nor one that covers a frame the learner drew, which the models' cascade drops once it is over: a model that gave only such frames found tasks, and the next one is not asked. The frames go top to bottom, and of two at one height the left first, the first finding.MaxTasks of them.
func (*Tutor) PaperWords ¶ added in v0.1.59
func (t *Tutor) PaperWords(ctx context.Context, w PaperWordsRequest) WordsAnswer
PaperWords asks the admitted models of the words of a task from paper, one at a time, a later one only when the one before failed or its words broke the checks of PaperBreach: with the work, CallPaperWords, which serves the analysis of the steps and the hint, so both are admitted on its models; without it, CallPaperHint. The answer is the box round the first mistake, in thousandths of the crop of the work, and the tutor's question: the last model's that answered, whether or not its words passed. A request a kind does not take fails before any call; an answer off the schema fails the call.
func (*Tutor) Price ¶ added in v0.1.24
Price is the price of a kind of call on a route, by the models ChooseCall chooses and the prices of their adapters, with the admission's answer: a refused route has no price. The prices need no key, and a client made with none calls nothing, so the own key is not dialled for them.
func (*Tutor) Prices ¶ added in v0.1.24
func (t *Tutor) Prices() ([]ModelPrice, error)
Prices are the table of prices: each model of the list of admitted models whose provider the config gives an adapter of, once, in the order of the list. It grows from the prices of the adapters rather than standing beside them as a second copy.
func (*Tutor) ReadEssay ¶ added in v0.1.24
func (t *Tutor) ReadEssay(ctx context.Context, r EssayReading) EssayRead
ReadEssay reads an essay by the one model admitted for reading handwriting with the prompt of the reading of an essay. The pair of the reading of a sheet measured another prompt and admits nothing of this one: until an entry of the list measured it, the reading is NotAdmitted. A word that cannot be made out has no field of its own until the measurement on the essays of volunteers (Т-37; П-16).
func (*Tutor) ReadPaper ¶ added in v0.1.59
func (t *Tutor) ReadPaper(ctx context.Context, r PaperReading) SheetRead
ReadPaper reads the work on a task from paper by the models admitted for its reading (CallPaper), in any reading mode, one at a time, a later one only when the one before failed or read an answer as illegible or ambiguous, into the observation of an answer slot for each task, the task n at the place n, 1: the learner's final answer to it as written, or the label of the one option circled, with its box on the crop. api brings each value to its task's key and module-kit judges it. A reading with no task fails before any call.
func (*Tutor) ReadSheet ¶ added in v0.1.16
func (t *Tutor) ReadSheet(ctx context.Context, r SheetReading) SheetRead
ReadSheet reads a handwriting sheet by the models admitted for reading handwriting — the pair, in parallel, or its one reader in ReadingSingle —, each into the observation of the task's one answer slot bound anywhere. It reads that slot alone: the sheets of the first modules have no other that AI reads. A slot bound choice is no reading of AI: api gives the option tapped to module-kit. An answer that is no observation fails the reading, as a failure of AI does: there is no observation of a pair then.
func (*Tutor) ReadStatement ¶ added in v0.1.59
func (t *Tutor) ReadStatement(ctx context.Context, p PaperTask) StatementRead
ReadStatement asks the admitted models of the reading of a statement (CallStatement) for the tasks of the crop, each with its statement and its formula, one at a time, a later one only when the one before failed: a statement that is no formula is an answer. The crop goes as a photo does (provider.Photo): fitted to the size its model takes, and as a JPEG without the metadata of its file. A crop that is no JPEG or PNG fails before any call; an answer off the schema fails the call.
func (*Tutor) ReadWorkbook ¶ added in v0.1.24
func (t *Tutor) ReadWorkbook(ctx context.Context, r WorkbookReading) WorkbookRead
ReadWorkbook reads the filled boxes of a workbook page by the models admitted for reading handwriting with the prompt of the workbook — the pair, in parallel, or its one reader in ReadingSingle —, each into the observation of the page. The pair admitted for the reading of a sheet measured another prompt, and admits nothing of this one: until an entry of the list measured the prompt of the workbook, the reading is NotAdmitted. A page with no filled box goes to no model. An answer that is no observation fails the reading, as a failure of AI does.
func (*Tutor) SolveTask ¶ added in v0.1.59
func (t *Tutor) SolveTask(ctx context.Context, p PaperTask, tasks []TaskToSolve) TasksSolved
SolveTask asks the admitted models of the solution (CallSolving), one solution of one model, for the answers of the tasks of the crop it names: the keys of the tasks whose statement the solver does not take, all in one call. A later model is asked when the one before failed or left a task asked with no answer a key may hold — none, or one that breaks a rule of module-kit (paper.Key) —, and the last one's answers stand. The crop goes as ReadStatement sends it; an answer off the schema fails the call.
func (*Tutor) Words ¶ added in v0.1.18
func (t *Tutor) Words(ctx context.Context, w WordsRequest) WordsAnswer
Words asks the admitted model of the words for the analysis and the hint of a rung. With the work it serves the analysis of the steps and the hint, so both must be admitted, and the model is the analysis's (CallWords); without it, the hint alone (CallHint). A task without words, a crop that is no PNG of a sheet, a rung the ladder has not, a language with no tag and no style of presentation fail before any call; an answer off the schema, or naming a trap the request does not hold, fails the call.
type Usage ¶
type Usage struct {
Provider admissionv0.Provider
Model string
InputTokens int64
CacheWrites []provider.CacheWrite
CacheReadTokens int64
OutputTokens int64
ThinkingTokens int64
Billed bool
USD float64
Priced bool
Latency time.Duration
Retries int
FirstToken time.Duration
}
Usage is a record of what one call of a model took: the provider and the model the provider says answered; the input tokens without the cache, those written to the cache by how long it keeps them and those read from it, which add up to the input with no token counted twice; the output tokens, and of them those spent thinking; whether those tokens are the call's whole bill (provider.Billed); its cost in US dollars by the table of prices (Tutor.Prices) — at its worst when the tokens are not its whole bill —, which Priced says the prices hold, and it is an estimate: the provider bills; how long the call took, from when the library asked the adapter to when the answer or the failure came back, the SDK's retries counted in — the span the eval runner times as latency_ms —, and how many times the SDK sent it again; and when the first text of the answer came, counted from the attempt that answered, or zero where none came or the adapter does not measure it, as GPT's does not. It holds no content and no identifier, and may be written to logs.
type WordsAnswer ¶ added in v0.1.18
type WordsAnswer struct {
Box *observationv1.CropBox
Trap string
Question string
Answers []string
Outcome Outcome
}
WordsAnswer is what the call of words gives, when Outcome is Answered: the box round the first mistake, in thousandths of the crop, the same message as an observation's, or nil when the model found none or saw no work; the trap of the request's that the mistake falls into, or empty; the tutor's question; and, of the opening question of a task from paper, the model's own answers of its tasks, which the learner never sees and api's leak check alone reads (PaperBreach).
type WordsRequest ¶ added in v0.1.18
type WordsRequest struct {
Route Route
Task *open.Task
Crop []byte
Key string
Solution []string
Traps []Trap
Found string
Techniques []string
Rung int
Language string
Style string
Asked []string
}
WordsRequest is a call of the tutor's words: the analysis of the steps and the hint of a rung, in one call.
- Crop is the PNG of the crop of the work, sent again, as the server keeps none; nil when the learner asks to have the rung put another way, which sends no work;
- Key and Solution are the task's, which the model sees here alone;
- Traps are the task's traps that AI may name, with their descriptions, and Found the trap of the cell of the rung, which the program found by its value, or empty;
- Techniques are the task's ways to solve it;
- Rung is the rung api picked, 1 to 3; Language the module's language of explanations, by its tag; Style only what of the presentation style changes the words;
- Asked are the questions the tutor has already asked on the task, in order.
The words are checked by api for leaks and by words.Hint for their form, before they reach the learner; api gives the fallback text in their place when they fail.
type WorkbookRead ¶ added in v0.1.24
type WorkbookRead struct {
Observations []*observationv1.Observation
Outcome Outcome
}
WorkbookRead is what a reading of a workbook page gives: the observation of each reader, in the order of the pair, over every box of the page — a blank one unreadable, blank —, when Outcome is Answered — module-kit joins them and gives the verdict —, and otherwise none. In ReadingSingle it is the one observation of the one reader.
type WorkbookReading ¶ added in v0.1.24
WorkbookReading is a workbook page to read: the open view of its task, the crops of its filled boxes, and the route. A box the learner left blank has no crop and goes to no model. The model sees the crops and their places, never the line of an item nor the key.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admission is tutor's admission function: one pure function that says whether the work of a learner of an age category may go to an AI provider on an AI route, for a capability of AI, by spec's admission table and the deployment facts an operator declares.
|
Package admission is tutor's admission function: one pure function that says whether the work of a learner of an age category may go to an AI provider on an AI route, for a capability of AI, by spec's admission table and the deployment facts an operator declares. |
|
cmd
|
|
|
tutor-eval
command
Command tutor-eval is tutor's eval runner: it runs the AI capabilities on eval samples, on the same code that api calls, and reports how they did.
|
Command tutor-eval is tutor's eval runner: it runs the AI capabilities on eval samples, on the same code that api calls, and reports how they did. |
|
internal
|
|
|
board
Package board is the check board: a local page where a person solves fixed tasks by hand, the models read the work and judge it, and the person marks whether each model was right.
|
Package board is the check board: a local page where a person solves fixed tasks by hand, the models read the work and judge it, and the person marks whether each model was right. |
|
convert
Package convert writes the sheets of tutor-sample v0, a format the record mode of the board does not write, as samples of spec's eval protocol, the message Sample of novatrail.eval.v1: the author's sheets as a person's, at random by ID and by the author's writer's code, and the sheets code drew as the samples tutor-eval draw draws, to the byte, once the same code is found to draw them from the seed.
|
Package convert writes the sheets of tutor-sample v0, a format the record mode of the board does not write, as samples of spec's eval protocol, the message Sample of novatrail.eval.v1: the author's sheets as a person's, at random by ID and by the author's writer's code, and the sheets code drew as the samples tutor-eval draw draws, to the byte, once the same code is found to draw them from the seed. |
|
correct
Package correct is the call of the words after a correct answer: once the program has found the final answer right, a model praises a step of the solution and asks which technique helped, in words of a form of their own (words.Correct).
|
Package correct is the call of the words after a correct answer: once the program has found the final answer right, a model praises a step of the solution and asks which technique helped, in words of a form of their own (words.Correct). |
|
essay
Package essay is the assessment of an essay by the module author's rubric in the measurement: what a model sees of a synthetic essay.
|
Package essay is the assessment of an essay by the module author's rubric in the measurement: what a model sees of a synthetic essay. |
|
evalsample
Package evalsample is a sheet of the measurement as a sample file of spec's eval protocol, the message Sample of novatrail.eval.v1: Of writes a sheet that internal/synth drew as one, and Read reads one back into the sample that tutor's runner takes, internal/sample's, with what its plan sheet says and the protocol does not — the scenario, the planned erasure and the trap.
|
Package evalsample is a sheet of the measurement as a sample file of spec's eval protocol, the message Sample of novatrail.eval.v1: Of writes a sheet that internal/synth drew as one, and Read reads one back into the sample that tutor's runner takes, internal/sample's, with what its plan sheet says and the protocol does not — the scenario, the planned erasure and the trap. |
|
finding
Package finding is the call that finds the tasks on the photo of a page from the learner's paper: a model sees the photo of the whole page once and gives a box round each task, in pixels of the photo, and nothing of the page's text.
|
Package finding is the call that finds the tasks on the photo of a page from the learner's paper: a model sees the photo of the whole page once and gives a box round each task, in pixels of the photo, and nothing of the page's text. |
|
gen
Package gen builds the synthetic sets of the extended measurement: pages of the workbook in the format tutor-workbook and essays in the format tutor-essays, as many as a run needs, each with its truth by construction.
|
Package gen builds the synthetic sets of the extended measurement: pages of the workbook in the format tutor-workbook and essays in the format tutor-essays, as many as a run needs, each with its truth by construction. |
|
hint
Package hint is the call of the review and the hint: once the program has found the final answer not yet right, a model finds the first mistake in the work and words the tutor's question for the rung of the hint ladder that the program chose, in one call.
|
Package hint is the call of the review and the hint: once the program has found the final answer not yet right, a model finds the first mistake in the work and words the tutor's question for the rung of the hint ladder that the program chose, in one call. |
|
journal
Package journal tells how a sheet was written, for the forms of the measurement that show the model the writing process: a journal of numbered steps in English, and up to two frames of the sheet just before erasures.
|
Package journal tells how a sheet was written, for the forms of the measurement that show the model the writing process: a journal of numbered steps in English, and up to two frames of the sheet just before erasures. |
|
judge
Package judge holds what the measurement asks of a model and how it reads the answer: the judge's instructions, the request of each form, and the schema of the answer.
|
Package judge holds what the measurement asks of a model and how it reads the answer: the judge's instructions, the request of each form, and the schema of the answer. |
|
leak
Package leak is the leak check of the module format: the program's search for the answer in a text the learner will see, the tutor's words before they reach the learner.
|
Package leak is the leak check of the module format: the program's search for the answer in a text the learner will see, the tutor's words before they reach the learner. |
|
lines
Package lines finds the lines of a sheet: the strokes that stand at one height, told apart by the gaps between them down the sheet.
|
Package lines finds the lines of a sheet: the strokes that stand at one height, told apart by the gaps between them down the sheet. |
|
measure
Package measure is the judge's kind of call on the runner: the measurement of the writing process.
|
Package measure is the judge's kind of call on the runner: the measurement of the writing process. |
|
newfile
Package newfile writes the files tutor's tools keep: each a new file, never one written over.
|
Package newfile writes the files tutor's tools keep: each a new file, never one written over. |
|
openview
Package openview builds the open views of the measurement's tasks: the file that tutor's release carries for canvas's sample page, until modules has content.
|
Package openview builds the open views of the measurement's tasks: the file that tutor's release carries for canvas's sample page, until modules has content. |
|
paperset
Package paperset is the eval set of a task from paper and its four runs: the reading of a statement into its tasks and their formulas, the solution of tasks by AI, the reading of the work on a task against its keys, and the finding of the tasks of several framed together, each apart, by the learner's request.
|
Package paperset is the eval set of a task from paper and its four runs: the reading of a statement into its tasks and their formulas, the solution of tasks by AI, the reading of the work on a task against its keys, and the finding of the tasks of several framed together, each apart, by the learner's request. |
|
paperwords
Package paperwords is the tutor's words on a task from the learner's paper: a task with no module, so with no solution, trap, technique or leading question of an author.
|
Package paperwords is the tutor's words on a task from the learner's paper: a task with no module, so with no solution, trap, technique or leading question of an author. |
|
protocol
Package protocol is spec's eval protocol in tutor's code: the package novatrail.eval.v1, whose messages Sample and Report are the sample file and the runner's report.
|
Package protocol is spec's eval protocol in tutor's code: the package novatrail.eval.v1, whose messages Sample and Report are the sample file and the runner's report. |
|
protocol/protocoltest
Package protocoltest gives tests spec's examples of the eval protocol: the synthetic sample files and reports of contracts/examples/eval/v1/.
|
Package protocoltest gives tests spec's examples of the eval protocol: the synthetic sample files and reports of contracts/examples/eval/v1/. |
|
providertest
Package providertest is what the tests of the adapters share: a transport that answers every request itself and keeps what reached the network, and the check that the requests went where a client that takes nothing from the environment sends them.
|
Package providertest is what the tests of the adapters share: a transport that answers every request itself and keeps what reached the network, and the check that the requests went where a client that takes nothing from the environment sends them. |
|
reading
Package reading is the reading of a sheet into an observation: a model reads the work as it is written, part by part, and its final answer, without deciding whether it is right.
|
Package reading is the reading of a sheet into an observation: a model reads the work as it is written, part by part, and its final answer, without deciding whether it is right. |
|
render
Package render draws a sheet of handwriting from its strokes, as the board shows it: ink of the board's pen, #111, 3 px wide with round ends and joins, on white, one pixel to a unit of the sheet.
|
Package render draws a sheet of handwriting from its strokes, as the board shows it: ink of the board's pen, #111, 3 px wide with round ends and joins, on white, one pixel to a unit of the sheet. |
|
report
Package report turns the log of a run into the measurement's numbers and its criterion, asking no model, and writes them as Markdown and CSV.
|
Package report turns the log of a run into the measurement's numbers and its criterion, asking no model, and writes them as Markdown and CSV. |
|
runner
Package runner runs the calls of a measurement, whatever their kind.
|
Package runner runs the calls of a measurement, whatever their kind. |
|
sample
Package sample is the format of the reading measurement's samples, of its bank of tasks, of its sheet plan and of the split of its sheets: their types, how they are read from JSON and how they are checked.
|
Package sample is the format of the reading measurement's samples, of its bank of tasks, of its sheet plan and of the split of its sheets: their types, how they are read from JSON and how they are checked. |
|
samplecheck
Package samplecheck holds sample files of the eval protocol to the protocol's rules by spec's own code, its recipe sample-check: the runner refuses a sample by the same code as sample-check.
|
Package samplecheck holds sample files of the eval protocol to the protocol's rules by spec's own code, its recipe sample-check: the runner refuses a sample by the same code as sample-check. |
|
sheets
Package sheets reads the directory where the record mode of the board saves the measurement's sheets, and tutor-eval draw the sheets it draws, against the sheet plan: for each plan sheet its last file, read and checked as a sample.
|
Package sheets reads the directory where the record mode of the board saves the measurement's sheets, and tutor-eval draw the sheets it draws, against the sheet plan: for each plan sheet its last file, read and checked as a sample. |
|
solving
Package solving is the solution of tasks from paper by AI: a model sees the task's crop, as app cut it from the photo of the page, with the tasks on it it is to solve, each by its number and its statement as the reading of the statement gave them, solves each, and gives its answer — a number, or the label of an option the page prints — or none when the task has no one answer of these kinds.
|
Package solving is the solution of tasks from paper by AI: a model sees the task's crop, as app cut it from the photo of the page, with the tasks on it it is to solve, each by its number and its statement as the reading of the statement gave them, solves each, and gives its answer — a number, or the label of an option the page prints — or none when the task has no one answer of these kinds. |
|
statement
Package statement is the reading of a task's statement from paper into its tasks and their formulas: a model sees the task's crop, as app cut it from the photo of the page, and lists the tasks on it — one, or each of a column of sums framed together —, each with its statement as printed and as a formula when it is an expression or an equation, or none when it is not.
|
Package statement is the reading of a task's statement from paper into its tasks and their formulas: a model sees the task's crop, as app cut it from the photo of the page, and lists the tasks on it — one, or each of a column of sums framed together —, each with its statement as printed and as a formula when it is an expression or an equation, or none when it is not. |
|
states
Package states chooses the states of a sheet for the reading of unfinished work (О-8, О-21): the moments of the writing at which a device that read on its own, without the learner asking, would read, and what the sheet shows at each.
|
Package states chooses the states of a sheet for the reading of unfinished work (О-8, О-21): the moments of the writing at which a device that read on its own, without the learner asking, would read, and what the sheet shows at each. |
|
synth
Package synth draws synthetic samples, for eval and for tests, and a synthetic bank of tasks for tests.
|
Package synth draws synthetic samples, for eval and for tests, and a synthetic bank of tasks for tests. |
|
task
Package task gives each task of tutor's measurements — a task of a bank, solved on a sheet; a page of the workbook; an essay — the task of spec's module format 0.3 it is, with its checks: formatv0.Task.
|
Package task gives each task of tutor's measurements — a task of a bank, solved on a sheet; a page of the workbook; an essay — the task of spec's module format 0.3 it is, with its checks: formatv0.Task. |
|
value
Package value is how tutor reads a value as the module format's checks read it: the normalization of steps 1 to 4, a number's value read in steps 1 to 5 and 7, and a text in a notation of number as a rational number, exactly.
|
Package value is how tutor reads a value as the module format's checks read it: the normalization of steps 1 to 4, a number's value read in steps 1 to 5 and 7, and a text in a notation of number as a rational number, exactly. |
|
wordsjudge
Package wordsjudge is the judge of the tutor's words: a model that reads a hint of the set of the words and says whether it tells the learner's sex, keeps to the task, suits a child and takes up the note at the side of the work, if there is one.
|
Package wordsjudge is the judge of the tutor's words: a model that reads a hint of the set of the words and says whether it tells the learner's sex, keeps to the task, suits a child and takes up the note at the side of the work, if there is one. |
|
workbook
Package workbook is the measurement of the workbook: its pages, which code draws in memory from eval/workbook.json, and the crop of each filled box, which is all a reading of the page sees: the ink of the box's strokes alone, cut by the rule of the eval protocol, without the box's frame and the print of its line.
|
Package workbook is the measurement of the workbook: its pages, which code draws in memory from eval/workbook.json, and the crop of each filled box, which is all a reading of the page sees: the ink of the box's strokes alone, cut by the rule of the eval protocol, without the box's frame and the print of its line. |
|
Package provider is the port through which tutor reaches the AI providers.
|
Package provider is the port through which tutor reaches the AI providers. |
|
claude
Package claude is the adapter of Anthropic's Claude models, through the official Go SDK.
|
Package claude is the adapter of Anthropic's Claude models, through the official Go SDK. |
|
claude/catalog
Package catalog is the Claude models the adapter of package provider/claude calls, and their prices and efforts, without Anthropic's SDK: the library and the eval runner name and price a model by it, so that whatever takes them takes the SDK only with the adapter itself.
|
Package catalog is the Claude models the adapter of package provider/claude calls, and their prices and efforts, without Anthropic's SDK: the library and the eval runner name and price a model by it, so that whatever takes them takes the SDK only with the adapter itself. |
|
gpt
Package gpt is the adapter of OpenAI's GPT models, through the official Go SDK and the Responses API.
|
Package gpt is the adapter of OpenAI's GPT models, through the official Go SDK and the Responses API. |
|
Package words holds the checks of the tutor's words that api makes before they reach the learner, beside the leak check: the form of a hint, the form of the words after a correct answer and the rule of feedback by a rubric.
|
Package words holds the checks of the tutor's words that api makes before they reach the learner, beside the leak check: the form of a hint, the form of the words after a correct answer and the rule of feedback by a rubric. |