Decision Models
Go SDK reference for decision models: methods create, decide, delete, get, list, update.
package goodmem // import "fury.io/pairsys/goodmem"Decision-model registration and typed evaluation.
Methods are called as client.DecisionModels().<Method>(ctx, ...) on a *goodmem.Client. Service: DecisionModelsService.
Index
- type DecisionModelsService
- type CreateDecisionModelRequest
- type DecisionModelProviderType
- type DecisionModelResponse
- type DecisionModelCapabilities
- type DecisionMediaSupport
- type DecisionLimit
- type DecisionQuestionSemantics
- type DecisionMediaLimit
- type DecisionRequest
- type DecisionContent
- type DecisionMedia
- type DecisionQuestion
- type DecisionObject
- type DecisionArray
- type DecisionChoiceQuestion
- type DecisionScoreQuestion
- type DecisionNoulQuestion
- type DecisionBoxQuestion
- type DecisionResponse
- type DecisionAnswer
- type DecisionUsage
- type DecisionChoiceAnswer
- type DecisionScoreAnswer
- type DecisionNoulAnswer
- type DecisionBoxAnswer
- type ListDecisionModelsResponse
- type UpdateDecisionModelRequest
type DecisionModelsService
type DecisionModelsService struct{ … }
Access this service as client.DecisionModels() on a *goodmem.Client. Its methods follow.
func (s *DecisionModelsService) Create
func (s *DecisionModelsService) Create(ctx context.Context, req *models.CreateDecisionModelRequest) (*models.DecisionModelResponse, error)
Saves the connection settings for a decision model. Requires CREATE_DECISION_MODEL for the new model and its owner. You can register the same provider connection more than once, but each registration must have a unique UUID. Credentials are omitted from the response.
HTTP — POST /v1/decision-models
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.req(*models.CreateDecisionModelRequest) — the request payload. The linked type documents every field and its JSON wire name.
Returns — (*models.DecisionModelResponse, error)
Example
model, err := client.DecisionModels().Create(ctx, &models.CreateDecisionModelRequest{
DisplayName: "Doc decision model", ProviderType: models.DecisionModelProviderTypeLAYA,
EndpointURL: "http://localhost:8000", ModelIdentifier: "laya",
})
if err != nil {
log.Fatal(err)
}
log.Print(model.DecisionModelID)func (s *DecisionModelsService) Get
func (s *DecisionModelsService) Get(ctx context.Context, id string, params *DecisionModelsGetParams) (*models.DecisionModelResponse, error)
Returns the connection settings and supported features of a decision model. Requires READ_DECISION_MODEL. Set includeCredentials=true to include stored credentials; this also requires READ_DECISION_MODEL_CREDENTIALS. Returns 404 if the model does not exist, or 403 if it exists but you lack permission.
HTTP — GET /v1/decision-models/{id}
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.id(string) — UUID of the decision modelparams(*DecisionModelsGetParams, optional) — typed query parameters; passnilfor an empty filter set.
Returns — (*models.DecisionModelResponse, error)
Example
fetched, err := client.DecisionModels().Get(ctx, "your-decision-model-id", nil)
if err != nil {
log.Fatal(err)
}
log.Print(fetched.DisplayName)func (s *DecisionModelsService) List
func (s *DecisionModelsService) List(ctx context.Context, params *DecisionModelsListParams) (*models.ListDecisionModelsResponse, error)
Lists decision models that you have permission to read. Requires LIST_DECISION_MODEL for the instance and READ_DECISION_MODEL for each returned model. Results are ordered by creation time, newest first, with UUID descending to break ties. Credentials are omitted.
LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
HTTP — GET /v1/decision-models
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.params(*DecisionModelsListParams, optional) — typed query parameters; passnilfor an empty filter set.
Returns — (*models.ListDecisionModelsResponse, error)
Example
page, err := client.DecisionModels().List(ctx, nil)
if err != nil {
log.Fatal(err)
}
log.Print(page.TotalCount, page.NextPageToken)func (s *DecisionModelsService) Update
func (s *DecisionModelsService) Update(ctx context.Context, id string, req *models.UpdateDecisionModelRequest) (*models.DecisionModelResponse, error)
Changes only the fields supplied in the request. Requires UPDATE_DECISION_MODEL. Send an empty string to clear description, version, or monitoringEndpoint. A supplied configuration replaces all existing settings; use {} to reset them to defaults. The provider and owner cannot be changed. Credentials are omitted from the response.
HTTP — PUT /v1/decision-models/{id}
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.id(string) — UUID of the decision modelreq(*models.UpdateDecisionModelRequest) — the request payload. The linked type documents every field and its JSON wire name.
Returns — (*models.DecisionModelResponse, error)
Example
name := "Updated decision model"
updated, err := client.DecisionModels().Update(ctx, "your-decision-model-id", &models.UpdateDecisionModelRequest{DisplayName: &name})
if err != nil {
log.Fatal(err)
}
log.Print(updated.DisplayName)func (s *DecisionModelsService) Delete
func (s *DecisionModelsService) Delete(ctx context.Context, id string) error
Removes the decision model from GoodMem. Requires DELETE_DECISION_MODEL. This does not contact or delete the model at the provider. Returns 404 if the registration has already been deleted.
HTTP — DELETE /v1/decision-models/{id}
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.id(string) — UUID of the decision model
Returns — error — nil on success.
Example
err := client.DecisionModels().Delete(ctx, "your-decision-model-id")
if err != nil {
log.Fatal(err)
}func (s *DecisionModelsService) Decide
func (s *DecisionModelsService) Decide(ctx context.Context, id string, req *models.DecisionRequest) (*models.DecisionResponse, error)
Sends the supplied questions and content to the registered provider. Requires READ_DECISION_MODEL and EXECUTE_DECISION_MODEL. Each request calls the provider once and may incur charges, so do not retry automatically. GoodMem does not store the input or answers. Unsupported questions or media return 400. Problems with the stored provider credentials or settings return 412.
HTTP — POST /v1/decision-models/{id}/decide
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.id(string) — UUID of the decision modelreq(*models.DecisionRequest) — the request payload. The linked type documents every field and its JSON wire name.
Returns — (*models.DecisionResponse, error)
Example
text := "The account has been verified."
instructions := "Is the account verified?"
result, err := client.DecisionModels().Decide(ctx, "your-evaluation-model-id", &models.DecisionRequest{
State: models.DecisionContent{Text: &text},
Questions: map[string]models.DecisionQuestion{"verified": {
Instructions: &models.DecisionContent{Text: &instructions},
Noul: &models.DecisionNoulQuestion{},
}},
})
if err != nil {
log.Fatal(err)
}
log.Print(result.Answers["verified"].Noul.ProbabilityTrue)type CreateDecisionModelRequest
type CreateDecisionModelRequest struct{ … }
Connection settings for a new decision model.
DisplayName(string, wiredisplayName) — Name shown in the console and CLI.Description(string, optional, wiredescription) — Optional description.ProviderType(models.DecisionModelProviderType, wireproviderType) — Provider used by this model. This cannot be changed after creation.EndpointURL(string, wireendpointUrl) — Base URL of the provider, starting with http:// or https://. Do not include a query string, fragment, or username and password.APIPath(string, optional, wireapiPath) — Path appended to endpointUrl when sending a request. Jev and Laya use /v1/systemone if omitted. Clef requires the path for your account and model.ModelIdentifier(string, wiremodelIdentifier) — Model identifier accepted by the provider.Credentials(models.EndpointAuthentication, optional, wirecredentials) — API key for the provider, supplied in credentials.apiKey.inlineSecret with kind set to CREDENTIAL_KIND_API_KEY. May be omitted for Laya when the endpoint allows anonymous access.Configuration(map[string]any, optional, wireconfiguration) — Provider settings. Supported keys are image_preview (Jev only), timeout_millis, and max_response_bytes. These settings cannot change which features the model supports.Labels(map[string]string, optional, wirelabels) — Labels for filtering and organization.Version(string, optional, wireversion) — Optional version label.MonitoringEndpoint(string, optional, wiremonitoringEndpoint) — Optional URL for the provider health or metrics endpoint. Must start with http:// or https://.OwnerID(string, optional, wireownerId) — UUID of the principal that will own the model. If omitted, the authenticated principal becomes the owner.DecisionModelID(string, optional, wiredecisionModelId) — Optional UUID for the new model. GoodMem generates one if omitted. A UUID that is already in use returns 409; reusing connection settings is allowed.
type DecisionModelProviderType
type DecisionModelProviderType string
Decision-model provider protocol.
String enum (type DecisionModelProviderType string): "JEV" · "LAYA" · "CLEF"
type DecisionModelResponse
type DecisionModelResponse struct{ … }
Connection settings and supported features of a registered decision model.
DecisionModelID(string, wiredecisionModelId) — UUID of the decision model.DisplayName(string, wiredisplayName) — Name shown in the console and CLI.Description(string, optional, wiredescription) — Optional description.ProviderType(models.DecisionModelProviderType, wireproviderType) — Provider used by this model.EndpointURL(string, wireendpointUrl) — Provider base URL.APIPath(string, wireapiPath) — Inference path appended to the base URL.ModelIdentifier(string, wiremodelIdentifier) — Configured model identifier.Credentials(models.EndpointAuthentication, optional, wirecredentials) — Stored credentials. Returned only by get when includeCredentials=true and you have READ_DECISION_MODEL_CREDENTIALS permission.Configuration(map[string]any, wireconfiguration) — Settings used when calling the provider. These do not change which features the model supports.Labels(map[string]string, wirelabels) — Labels for filtering and organization.Version(string, optional, wireversion) — Optional version label.MonitoringEndpoint(string, optional, wiremonitoringEndpoint) — Optional HTTP(S) health or metrics URL.OwnerID(string, wireownerId) — UUID of the principal that owns this model.Capabilities(models.DecisionModelCapabilities, wirecapabilities) — Supported questions and media, known limits, and the meaning of each answer type.CreatedAt(int64, wirecreatedAt) — Creation time in milliseconds since epoch.UpdatedAt(int64, wireupdatedAt) — Last update time in milliseconds since epoch.CreatedByID(string, wirecreatedById) — UUID of the principal or API key that created this model.UpdatedByID(string, wireupdatedById) — UUID of the principal or API key that last updated this model.
type DecisionModelCapabilities
type DecisionModelCapabilities struct{ … }
Supported features and known limits for this provider and model. An omitted limit is unknown; it does not mean unlimited.
QuestionTypes([]string, wirequestionTypes) — Types of questions this model can answer.Media([]models.DecisionMediaSupport, wiremedia) — Supported media formats, placements and known limits.Limits([]models.DecisionLimit, wirelimits) — Known numeric limits.ContextBoundLimits([]string, wirecontextBoundLimits) — Limits that depend on the provider context window instead of a fixed count.Semantics([]models.DecisionQuestionSemantics, wiresemantics) — Meaning of the answer and confidence value for each question type.InputOverflow(string, wireinputOverflow) — What the provider does when the input exceeds its context window.
type DecisionMediaSupport
type DecisionMediaSupport struct{ … }
Media formats, placements and provider constraints.
Kind(string, wirekind) — Media category.MIMETypes([]string, wiremimeTypes) — Accepted MIME types.Placements([]string, wireplacements) — Allowed content positions.Limits([]models.DecisionMediaLimit, wirelimits) — Known limits for media. The provider checks dimensions and duration.
type DecisionLimit
type DecisionLimit struct{ … }
A known numeric limit.
Type(string, wiretype) — Limit identifier.Value(int64, wirevalue) — Known limit value.
type DecisionQuestionSemantics
type DecisionQuestionSemantics struct{ … }
Meaning of the answer and confidence value for one question type.
QuestionType(string, wirequestionType) — Question type.Confidence(string, wireconfidence) — How to interpret the confidence value reported by the provider.Output(string, wireoutput) — Meaning of the primary answer value.
type DecisionMediaLimit
type DecisionMediaLimit struct{ … }
A known media limit.
Type(string, wiretype) — Media limit identifier.Value(int64, wirevalue) — Known limit value.
type DecisionRequest
type DecisionRequest struct{ … }
Sends named questions and content to a registered decision model. The provider may charge for this request.
State(models.DecisionContent, wirestate) — Content evaluated by all questions.Attachments([]models.DecisionMedia, optional, wireattachments) — Media files included with the request. Their order is preserved within each media type.Questions(map[string]models.DecisionQuestion, wirequestions) — Questions keyed by names that you choose. The model must support each question type and its media.
type DecisionContent
type DecisionContent struct{ … }
Set exactly one of text, jsonValue, objectValue, arrayValue, or media. Use text for ordinary text. Use jsonValue to preserve a complete JSON value, including the exact precision of its numbers.
JSONValue(string, optional, wirejsonValue) — A complete JSON value encoded as a string. For example, {"jsonValue":"null"} represents JSON null. For ordinary text, use the text field.Text(string, optional, wiretext) — Ordinary text without JSON quoting.ObjectValue(models.DecisionObject, optional, wireobjectValue) — Object whose fields can contain nested media.ArrayValue(models.DecisionArray, optional, wirearrayValue) — Ordered array whose elements can contain nested media.Media(models.DecisionMedia, optional, wiremedia) — Media file included in the request. GoodMem does not download media from URLs.
type DecisionMedia
type DecisionMedia struct{ … }
Media file included in the request. The provider and model determine which formats and sizes are supported.
Kind(string, wirekind) — Media category.MIMEType(string, wiremimeType) — Declared MIME type.Data([]byte, wiredata) — Base64-encoded file bytes.
type DecisionQuestion
type DecisionQuestion struct{ … }
Set exactly one of choice, score, noul, or box. Clef requires instructions for every question.
Instructions(models.DecisionContent, optional, wireinstructions) — Instructions for this question. Clef requires nonblank text, an object, or an array. Other providers allow omission; to supply JSON null, use {"jsonValue":"null"}.Choice(models.DecisionChoiceQuestion, optional, wirechoice) — Choose one labeled option.Score(models.DecisionScoreQuestion, optional, wirescore) — Score the content against a list of levels ordered from lowest to highest.Noul(models.DecisionNoulQuestion, optional, wirenoul) — Estimate the probability that a statement is true.Box(models.DecisionBoxQuestion, optional, wirebox) — Locate an object in an image. A returned box does not guarantee that the object is present.
type DecisionObject
type DecisionObject struct{ … }
Named decision content fields.
Fields(map[string]models.DecisionContent, wirefields) — Content keyed by field name.
type DecisionArray
type DecisionArray struct{ … }
Ordered decision content elements.
Values([]models.DecisionContent, wirevalues) — Ordered content elements.
type DecisionChoiceQuestion
type DecisionChoiceQuestion struct{ … }
Choice options.
Options(map[string]models.DecisionContent, wireoptions) — Option identifiers and descriptions.
type DecisionScoreQuestion
type DecisionScoreQuestion struct{ … }
Ordered rubric levels.
Levels([]models.DecisionContent, wirelevels) — Descriptions of the score levels, ordered from lowest to highest. The first level has index 0.
type DecisionNoulQuestion
type DecisionNoulQuestion struct{ … }
Optional true and false descriptions.
TrueCriterion(models.DecisionContent, optional, wiretrueCriterion) — Description of the true outcome.FalseCriterion(models.DecisionContent, optional, wirefalseCriterion) — Description of the false outcome.
type DecisionBoxQuestion
type DecisionBoxQuestion struct{ … }
Locate an object in an image. Use instructions to describe the object.
(no exported fields)
type DecisionResponse
type DecisionResponse struct{ … }
Structured provider answers with reported usage.
Model(string, wiremodel) — Provider-reported model identifier.Answers(map[string]models.DecisionAnswer, wireanswers) — Answers keyed by the original question identifiers.Usage(models.DecisionUsage, wireusage) — Token counts reported by the provider. An omitted count is unknown; a count of 0 means the provider reported zero.
type DecisionAnswer
type DecisionAnswer struct{ … }
Answer to one question. Exactly one of choice, score, noul, or box is present.
Choice(models.DecisionChoiceAnswer, optional, wirechoice) — Selected option and the probability assigned to each option.Score(models.DecisionScoreAnswer, optional, wirescore) — Score and the probability assigned to each score level.Noul(models.DecisionNoulAnswer, optional, wirenoul) — Probability that the statement is true.Box(models.DecisionBoxAnswer, optional, wirebox) — Normalized image coordinates.
type DecisionUsage
type DecisionUsage struct{ … }
Token usage reported by the provider. Counts are omitted when unknown.
InputTokens(int64, optional, wireinputTokens) — Reported input tokens.OutputTokens(int64, optional, wireoutputTokens) — Reported output tokens.
type DecisionChoiceAnswer
type DecisionChoiceAnswer struct{ … }
Selected option and probability distribution.
Choice(string, wirechoice) — Selected option identifier.Probabilities(map[string]float64, wireprobabilities) — Probability for every option.Confidence(float64, optional, wireconfidence) — Confidence reported by the provider. This is not a calibrated probability that the answer is correct.ConfidenceMeaning(string, wireconfidenceMeaning) — Interpretation of confidence.
type DecisionScoreAnswer
type DecisionScoreAnswer struct{ … }
Expected zero-based rubric level; not a percentage.
Score(float64, wirescore) — Score on the scale defined by levels. The first level has value 0, and fractional values fall between levels.Probabilities(map[string]float64, wireprobabilities) — Probability assigned to each level, using its index starting at 0.Levels([]models.DecisionContent, wirelevels) — Original caller rubric, including structured content and media.Confidence(float64, optional, wireconfidence) — Confidence reported by the provider. This is not a calibrated probability that the answer is correct.ConfidenceMeaning(string, wireconfidenceMeaning) — Interpretation of confidence.
type DecisionNoulAnswer
type DecisionNoulAnswer struct{ … }
Probability that the proposition is true.
ProbabilityTrue(float64, wireprobabilityTrue) — Probability that the statement is true. Your application decides what threshold to use.
type DecisionBoxAnswer
type DecisionBoxAnswer struct{ … }
Rectangle with coordinates expressed as fractions of the image width or height. A returned box does not guarantee that the object is present.
Left(float64, wireleft) — Left edge as a fraction of image width.Top(float64, wiretop) — Top edge as a fraction of image height.Right(float64, wireright) — Right edge as a fraction of image width.Bottom(float64, wirebottom) — Bottom edge as a fraction of image height.Confidence(float64, optional, wireconfidence) — Optional provider confidence.
type ListDecisionModelsResponse
type ListDecisionModelsResponse struct{ … }
One page of decision models that you have permission to read.
DecisionModels([]models.DecisionModelResponse, wiredecisionModels) — Decision models ordered by creation time, newest first, with UUID descending to break ties.NextPageToken(string, optional, wirenextPageToken) — Token to pass as pageToken in the next request. Omitted when there are no more results.TotalCount(int64, wiretotalCount) — Total number of models that match the filters and that you have permission to read, across all pages.
type UpdateDecisionModelRequest
type UpdateDecisionModelRequest struct{ … }
Changes only the supplied fields. Omitted fields keep their current values. A supplied configuration replaces all existing provider settings.
DisplayName(string, optional, wiredisplayName) — Name shown in the console and CLI.Description(string, optional, wiredescription) — Description of the model. Send an empty string to clear it, or omit it to keep the current value.EndpointURL(string, optional, wireendpointUrl) — Base URL of the provider, starting with http:// or https://. Do not include a query string, fragment, or username and password.APIPath(string, optional, wireapiPath) — Path appended to endpointUrl when sending a request. Omit it to keep the current path. An empty string resets Jev and Laya to /v1/systemone; Clef requires the path for your account and model.ModelIdentifier(string, optional, wiremodelIdentifier) — Model identifier accepted by the provider.Credentials(models.EndpointAuthentication, optional, wirecredentials) — Replacement API key for the provider, supplied in credentials.apiKey.inlineSecret with kind set to CREDENTIAL_KIND_API_KEY. Omit credentials to keep the current key.Configuration(map[string]any, optional, wireconfiguration) — Replacement provider settings. Supported keys are image_preview (Jev only), timeout_millis, and max_response_bytes. Send {} to reset all settings to defaults, or omit configuration to keep the current settings.Version(string, optional, wireversion) — Version label. Send an empty string to clear it, or omit it to keep the current value.MonitoringEndpoint(string, optional, wiremonitoringEndpoint) — URL for the provider health or metrics endpoint. Must start with http:// or https://. Send an empty string to clear it, or omit it to keep the current value.ReplaceLabels(map[string]string, optional, wirereplaceLabels) — Replace all labels with this map. Send {} to remove all labels. Do not combine with mergeLabels.MergeLabels(map[string]string, optional, wiremergeLabels) — Add labels and replace the values of matching keys. Other labels are unchanged. Do not combine with replaceLabels.