Examples / Classification / Model Primitive Sentiment

Model Primitive Sentiment

Has Specs

A minimal Model primitive example using a mock backend. Demonstrates: - Stateless prediction via the Model primitive - Input/output schemas on the model itself - Deterministic specs that run in CI without API keys

Source Code

-- Model Primitive: Mocked Sentiment Classifier
--
-- Use a Model primitive when you want stateless, repeatable predictions.
-- This example uses a mock backend so it runs in CI without API keys.

Model "sentiment_mock" {
  type = "mock",
  value = {label = "positive", confidence = 0.93},
  input = {text = "string"},
  output = {label = "string", confidence = "float"}
}

Procedure {
  input = {
    text = field.string{required = true, description = "Text to classify"}
  },
  output = {
    label = field.string{required = true, description = "Sentiment label"},
    confidence = field.number{required = true, description = "Confidence score"}
  },
  function(input)
    local classifier = Model("sentiment_mock")
    local result = classifier({text = input.text})
    local output = result.output or result

    return {label = output.label, confidence = output.confidence}
  end
}

Specification([[
Feature: Model primitive (mocked sentiment)

  Scenario: Returns the mocked label and confidence
    Given the procedure has started
    And the input text is "This product is wonderful."
    When the procedure runs
    Then the procedure should complete successfully
    And the output label should be "positive"
    And the output confidence should be 0.93
]])

Quick Start

Run the example:

$tactus run 02-classification/03-model-primitive-sentiment.tac

Test with mocks:

$tactus test 02-classification/03-model-primitive-sentiment.tac --mock

View source on GitHub →

Explore more examples

Learn Tactus through practical, runnable examples organized by topic.

Part of the Anthus Platform
Tactus icon

Tactus

Tactus is a programming language and runtime for durable AI agent procedures with checkpointing, sandboxing, and built-in human-in-the-loop controls.

PART OF

The Anthus Platform

Solve complex business problems with AI and ML using a proven, reusable technology stack. These interoperable building blocks give our solutions a stronger operational foundation: durable procedures, MLOps control loops, workload orchestration, knowledge systems, observability, and programmable media workflows.

Plexus

MLOps platform for agent evaluation and iteration.

Tactus

Durable runtime for agent procedures.

Korporus

Agent operating system and federated shell.

Biblicus

Corpus analysis for extraction and retrieval.

Babulus

Marketing automation built around VideoML.

Kanbus

Durable multi-agent task management.

Caducus

Monitoring, alerts, and operator support.

Free and open-source softwareDesigned cybernetically by Ryan Porter
Contact us

How can we help?

GitHub

Browse the code.

LinkedIn

Company updates.

Discord

Join the chat.