local-llm-database/models/assistant.rb
2025-09-03 00:12:44 -05:00

35 lines
834 B
Ruby

# models/assistant.rb
require 'sequel'
class Assistant < Sequel::Model
# This model assumes your assistants table has these columns:
# id (primary key), name, description, created_at, updated_at
# If you have a different schema, modify the column names accordingly
# Optional: Add validations
def validate
super
errors.add(:name, 'must be present') if name.nil? || name.empty?
errors.add(:run_command, 'must be present') if run_command.nil? || run_command.empty?
end
# Optional: Add custom methods for common operations
def self.find_by_name(name)
where(name: name).first
end
def self.find_by_run_command(run_command)
where(run_command: run_command).first
end
def self.active
where(active: true)
end
# Helper to check if this is a new record
def new?
id.nil?
end
end