AIExamples

AI Examples


Content moderation (minimal)

Single decision, no memory — classify one field and emit a structured result:

# providers/ai.providers.causet
providers:
  reasoning:
    executor: mock
    model: mock-model
 
# prompts/moderation.prompts.causet
prompts:
  moderation_v1:
    instructions: |
      Moderate this comment. Respond with JSON:
      allowed (boolean), confidence (0.0-1.0), explanation (string).
 
      Comment: {{ comment }}
 
# decisions/moderation.decisions.causet
decisions:
  moderate_comment:
    provider: reasoning
    prompt: moderation_v1
    emits: COMMENT_MODERATED
    input:
      comment: { type: string, required: true }
    output:
      allowed:     { type: boolean, required: true }
      confidence:  { type: number,  required: true }
      explanation: { type: string,  required: true }
 
# actions/moderate.actions.causet
actions:
  MODERATE:
    state: comment
    input:
      comment: string
    side_effects:
      rules:
        - name: run_moderation
          then:
            - op: decision
              ref: moderate_comment
              input:
                comment: intent.comment

Wire a listener to apply allowed and explanation to entity state when COMMENT_MODERATED fires.


Support triage with memory

Triage uses vector memory for customer context before classifying a ticket:

decisions:
  triage_ticket:
    provider: reasoning
    prompt: triage_v1
    emits: TICKET_AI_TRIAGED
    memories:
      - customer_history
    input:
      ticket_id:   { type: string, required: true }
      customer_id: { type: string, required: true }
      subject:     { type: string, required: true }
      body:        { type: string, required: true }
    output:
      priority:   { type: string, required: true }
      category:   { type: string, required: true }
      summary:    { type: string, required: true }
      confidence: { type: number,  required: true }
side_effects:
  rules:
    - name: ai_triage
      then:
        - op: decision
          ref: triage_ticket
          input:
            ticket_id:   intent.ticket_id
            customer_id: intent.customer_id
            subject:     intent.subject
            body:        intent.body

Seed customer_history with RECORD_CUSTOMER_NOTE and SIMULATE_ORDER intents before CREATE_TICKET so triage has context. Full file layout in Example — Support Copilot.


Applying AI output to state

listeners:
  - on: TICKET_AI_TRIAGED
    priority: 0
    mutate:
      - op: set
        field: priority
        value: event.payload.priority
      - op: set
        field: category
        value: event.payload.category
      - op: set
        field: ai_summary
        value: event.payload.summary
      - op: set
        field: ai_confidence
        value: event.payload.confidence

Full example apps

ExampleWhat it demonstrates
Support CopilotProviders, prompts, decisions, memories, listeners, projections, queries
Recommendation MemoryDeterministic entity-state personalization (complementary to vector memory)

Compile Support Copilot with the CLI:

causet build compile --runtime path/to/support-copilot --out build/tmp-support-copilot-out

Next steps