GoodMemGoodMem
ReferenceClient SDKsGo

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 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/&#123;id&#125;

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • id (string) — UUID of the decision model
  • params (*DecisionModelsGetParams, optional) — typed query parameters; pass nil for 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; pass nil for 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/&#123;id&#125;

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • id (string) — UUID of the decision model
  • req (*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/&#123;id&#125;

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/&#123;id&#125;/decide

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • id (string) — UUID of the decision model
  • req (*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, wire displayName) — Name shown in the console and CLI.
  • Description (string, optional, wire description) — Optional description.
  • ProviderType (models.DecisionModelProviderType, wire providerType) — Provider used by this model. This cannot be changed after creation.
  • EndpointURL (string, wire endpointUrl) — Base URL of the provider, starting with http:// or https://. Do not include a query string, fragment, or username and password.
  • APIPath (string, optional, wire apiPath) — 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, wire modelIdentifier) — Model identifier accepted by the provider.
  • Credentials (models.EndpointAuthentication, optional, wire credentials) — 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, wire configuration) — 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, wire labels) — Labels for filtering and organization.
  • Version (string, optional, wire version) — Optional version label.
  • MonitoringEndpoint (string, optional, wire monitoringEndpoint) — Optional URL for the provider health or metrics endpoint. Must start with http:// or https://.
  • OwnerID (string, optional, wire ownerId) — UUID of the principal that will own the model. If omitted, the authenticated principal becomes the owner.
  • DecisionModelID (string, optional, wire decisionModelId) — 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, wire decisionModelId) — UUID of the decision model.
  • DisplayName (string, wire displayName) — Name shown in the console and CLI.
  • Description (string, optional, wire description) — Optional description.
  • ProviderType (models.DecisionModelProviderType, wire providerType) — Provider used by this model.
  • EndpointURL (string, wire endpointUrl) — Provider base URL.
  • APIPath (string, wire apiPath) — Inference path appended to the base URL.
  • ModelIdentifier (string, wire modelIdentifier) — Configured model identifier.
  • Credentials (models.EndpointAuthentication, optional, wire credentials) — Stored credentials. Returned only by get when includeCredentials=true and you have READ_DECISION_MODEL_CREDENTIALS permission.
  • Configuration (map[string]any, wire configuration) — Settings used when calling the provider. These do not change which features the model supports.
  • Labels (map[string]string, wire labels) — Labels for filtering and organization.
  • Version (string, optional, wire version) — Optional version label.
  • MonitoringEndpoint (string, optional, wire monitoringEndpoint) — Optional HTTP(S) health or metrics URL.
  • OwnerID (string, wire ownerId) — UUID of the principal that owns this model.
  • Capabilities (models.DecisionModelCapabilities, wire capabilities) — Supported questions and media, known limits, and the meaning of each answer type.
  • CreatedAt (int64, wire createdAt) — Creation time in milliseconds since epoch.
  • UpdatedAt (int64, wire updatedAt) — Last update time in milliseconds since epoch.
  • CreatedByID (string, wire createdById) — UUID of the principal or API key that created this model.
  • UpdatedByID (string, wire updatedById) — 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, wire questionTypes) — Types of questions this model can answer.
  • Media ([]models.DecisionMediaSupport, wire media) — Supported media formats, placements and known limits.
  • Limits ([]models.DecisionLimit, wire limits) — Known numeric limits.
  • ContextBoundLimits ([]string, wire contextBoundLimits) — Limits that depend on the provider context window instead of a fixed count.
  • Semantics ([]models.DecisionQuestionSemantics, wire semantics) — Meaning of the answer and confidence value for each question type.
  • InputOverflow (string, wire inputOverflow) — What the provider does when the input exceeds its context window.

type DecisionMediaSupport

type DecisionMediaSupport struct{ … }

Media formats, placements and provider constraints.

  • Kind (string, wire kind) — Media category.
  • MIMETypes ([]string, wire mimeTypes) — Accepted MIME types.
  • Placements ([]string, wire placements) — Allowed content positions.
  • Limits ([]models.DecisionMediaLimit, wire limits) — Known limits for media. The provider checks dimensions and duration.

type DecisionLimit

type DecisionLimit struct{ … }

A known numeric limit.

  • Type (string, wire type) — Limit identifier.
  • Value (int64, wire value) — Known limit value.

type DecisionQuestionSemantics

type DecisionQuestionSemantics struct{ … }

Meaning of the answer and confidence value for one question type.

  • QuestionType (string, wire questionType) — Question type.
  • Confidence (string, wire confidence) — How to interpret the confidence value reported by the provider.
  • Output (string, wire output) — Meaning of the primary answer value.

type DecisionMediaLimit

type DecisionMediaLimit struct{ … }

A known media limit.

  • Type (string, wire type) — Media limit identifier.
  • Value (int64, wire value) — 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, wire state) — Content evaluated by all questions.
  • Attachments ([]models.DecisionMedia, optional, wire attachments) — Media files included with the request. Their order is preserved within each media type.
  • Questions (map[string]models.DecisionQuestion, wire questions) — 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, wire jsonValue) — 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, wire text) — Ordinary text without JSON quoting.
  • ObjectValue (models.DecisionObject, optional, wire objectValue) — Object whose fields can contain nested media.
  • ArrayValue (models.DecisionArray, optional, wire arrayValue) — Ordered array whose elements can contain nested media.
  • Media (models.DecisionMedia, optional, wire media) — 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, wire kind) — Media category.
  • MIMEType (string, wire mimeType) — Declared MIME type.
  • Data ([]byte, wire data) — 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, wire instructions) — 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, wire choice) — Choose one labeled option.
  • Score (models.DecisionScoreQuestion, optional, wire score) — Score the content against a list of levels ordered from lowest to highest.
  • Noul (models.DecisionNoulQuestion, optional, wire noul) — Estimate the probability that a statement is true.
  • Box (models.DecisionBoxQuestion, optional, wire box) — 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, wire fields) — Content keyed by field name.

type DecisionArray

type DecisionArray struct{ … }

Ordered decision content elements.

type DecisionChoiceQuestion

type DecisionChoiceQuestion struct{ … }

Choice options.

  • Options (map[string]models.DecisionContent, wire options) — Option identifiers and descriptions.

type DecisionScoreQuestion

type DecisionScoreQuestion struct{ … }

Ordered rubric levels.

  • Levels ([]models.DecisionContent, wire levels) — 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.

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, wire model) — Provider-reported model identifier.
  • Answers (map[string]models.DecisionAnswer, wire answers) — Answers keyed by the original question identifiers.
  • Usage (models.DecisionUsage, wire usage) — 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.

type DecisionUsage

type DecisionUsage struct{ … }

Token usage reported by the provider. Counts are omitted when unknown.

  • InputTokens (int64, optional, wire inputTokens) — Reported input tokens.
  • OutputTokens (int64, optional, wire outputTokens) — Reported output tokens.

type DecisionChoiceAnswer

type DecisionChoiceAnswer struct{ … }

Selected option and probability distribution.

  • Choice (string, wire choice) — Selected option identifier.
  • Probabilities (map[string]float64, wire probabilities) — Probability for every option.
  • Confidence (float64, optional, wire confidence) — Confidence reported by the provider. This is not a calibrated probability that the answer is correct.
  • ConfidenceMeaning (string, wire confidenceMeaning) — Interpretation of confidence.

type DecisionScoreAnswer

type DecisionScoreAnswer struct{ … }

Expected zero-based rubric level; not a percentage.

  • Score (float64, wire score) — Score on the scale defined by levels. The first level has value 0, and fractional values fall between levels.
  • Probabilities (map[string]float64, wire probabilities) — Probability assigned to each level, using its index starting at 0.
  • Levels ([]models.DecisionContent, wire levels) — Original caller rubric, including structured content and media.
  • Confidence (float64, optional, wire confidence) — Confidence reported by the provider. This is not a calibrated probability that the answer is correct.
  • ConfidenceMeaning (string, wire confidenceMeaning) — Interpretation of confidence.

type DecisionNoulAnswer

type DecisionNoulAnswer struct{ … }

Probability that the proposition is true.

  • ProbabilityTrue (float64, wire probabilityTrue) — 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, wire left) — Left edge as a fraction of image width.
  • Top (float64, wire top) — Top edge as a fraction of image height.
  • Right (float64, wire right) — Right edge as a fraction of image width.
  • Bottom (float64, wire bottom) — Bottom edge as a fraction of image height.
  • Confidence (float64, optional, wire confidence) — Optional provider confidence.

type ListDecisionModelsResponse

type ListDecisionModelsResponse struct{ … }

One page of decision models that you have permission to read.

  • DecisionModels ([]models.DecisionModelResponse, wire decisionModels) — Decision models ordered by creation time, newest first, with UUID descending to break ties.
  • NextPageToken (string, optional, wire nextPageToken) — Token to pass as pageToken in the next request. Omitted when there are no more results.
  • TotalCount (int64, wire totalCount) — 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, wire displayName) — Name shown in the console and CLI.
  • Description (string, optional, wire description) — Description of the model. Send an empty string to clear it, or omit it to keep the current value.
  • EndpointURL (string, optional, wire endpointUrl) — Base URL of the provider, starting with http:// or https://. Do not include a query string, fragment, or username and password.
  • APIPath (string, optional, wire apiPath) — 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, wire modelIdentifier) — Model identifier accepted by the provider.
  • Credentials (models.EndpointAuthentication, optional, wire credentials) — 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, wire configuration) — 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, wire version) — Version label. Send an empty string to clear it, or omit it to keep the current value.
  • MonitoringEndpoint (string, optional, wire monitoringEndpoint) — 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, wire replaceLabels) — Replace all labels with this map. Send {} to remove all labels. Do not combine with mergeLabels.
  • MergeLabels (map[string]string, optional, wire mergeLabels) — Add labels and replace the values of matching keys. Other labels are unchanged. Do not combine with replaceLabels.