Skip to content

Latest commit

 

History

History
210 lines (164 loc) · 6.76 KB

File metadata and controls

210 lines (164 loc) · 6.76 KB
layout title permalink
page
Examples
/examples/

🎯 SigmOS Examples

Explore real-world examples of SigmOS in action. Each example demonstrates different aspects of the language and showcases how to build intelligent, reactive systems.

🤖 Basic Examples

AI Agent

A simple AI agent with personality and conversation capabilities.

spec "Agent" v1.0 {
  description: "Defines an AI Agent with LLM prompt capabilities."

  inputs:
    name: string
    tone: enum("friendly", "hostile")
    api_key: string { secret: true }

  computed:
    greeting: -> "Hello, I'm {{name}}, and I'm {{tone}}."

  events:
    on_message: trigger {
      when: input.message != null
      action: respond
    }

  actions:
    respond: prompt {
      system: "You are {{name}} with a {{tone}} personality."
      user: "{{input.message}}"
      model: "gpt-4"
    }
}

View Full Example →

Content Pipeline

An AI-powered content generation and validation pipeline.

spec "ContentPipeline" v1.0 {
  description: "AI-powered content generation with validation"
  
  inputs:
    topic: string
    target_audience: enum("technical", "general", "academic")
    content_type: enum("blog", "documentation", "tutorial")
  
  computed:
    content_prompt: -> "Write a {{content_type}} about {{topic}} for {{target_audience}} audience"
  
  actions:
    generate: prompt {
      system: "You are an expert content creator."
      user: "{{content_prompt}}"
      model: "gpt-4"
    }
    
    validate: prompt {
      system: "Review this content for quality and accuracy."
      user: "Content: {{actions.generate.result}}"
      model: "gpt-4"
    }
}

View Full Example →

🏭 Industry Examples

🏥 Healthcare

Patient data processing, medical record analysis, and treatment recommendation systems.

View Examples →

💰 FinTech

Risk assessment, fraud detection, and automated trading systems with AI-powered decision making.

View Examples →

🛒 E-Commerce

Product recommendations, inventory management, and customer service automation.

View Examples →

🏭 Manufacturing

Quality control, predictive maintenance, and supply chain optimization systems.

View Examples →

🚚 Logistics

Route optimization, demand forecasting, and automated dispatch systems.

View Examples →

🏙️ Smart City

Traffic management, energy optimization, and citizen service automation.

View Examples →

🔧 Advanced Patterns

User Management System

Complete user lifecycle management with validation and security.

spec "UserManagement" v1.0 {
  description: "Complete user lifecycle management system"
  
  types:
    User: struct {
      id: string
      email: string
      role: enum("admin", "user", "guest")
      created_at: string
      permissions: list<string>
    }
  
  inputs:
    action: enum("create", "update", "delete", "authenticate")
    user_data: User { optional: true }
    credentials: struct {
      email: string
      password: string { secret: true }
    } { optional: true }
  
  constraints:
    valid_email: user_data.email ~= /^[^\s@]+@[^\s@]+\.[^\s@]+$/
    strong_password: len(credentials.password) >= 8
  
  events:
    on_create: trigger {
      when: input.action == "create"
      action: create_user
    }
    
    on_auth: trigger {
      when: input.action == "authenticate"
      action: authenticate_user
    }
  
  actions:
    create_user: block {
      validate_input: -> constraints.valid_email && user_data.role != null
      hash_password: -> hash(credentials.password)
      store_user: rest.post("/api/users", user_data)
    }
    
    authenticate_user: block {
      verify_credentials: rest.post("/api/auth", credentials)
      generate_token: -> jwt.sign(verify_credentials.user_id)
    }
}

View Full Example →

🎓 Learning Path

  1. Start Simple: Begin with the basic Agent example
  2. Add Complexity: Explore the Content Pipeline
  3. Industry Focus: Choose an industry example that matches your domain
  4. Advanced Patterns: Study the User Management system

🛠️ Running Examples

# Clone the repository
git clone https://github.com/copyleftdev/sigmos.git
cd sigmos

# Run any example
sigmos run examples/agent.sigmos

# Run with custom inputs
sigmos run examples/agent.sigmos --input name="Alice" --input tone="friendly"

# Validate an example
sigmos validate examples/user-management.sigmos

📚 Next Steps


Have an example to share?

We'd love to see what you're building with SigmOS!

Submit Your Example