diff --git a/app.rb b/app.rb index e8c4fdb..2eca3be 100644 --- a/app.rb +++ b/app.rb @@ -1,8 +1,12 @@ # frozen_string_literal: true -require "roda" + +require 'roda' require 'tilt' require 'tilt/erubi' +require_relative 'db' +require_relative 'models/assistant' + class App < Roda plugin :render, escape: true plugin :route_csrf @@ -12,10 +16,10 @@ class App < Roda r.root do @page_title = 'Assistants List' - @subtitle = 'All ASsistants in Database' + @subtitle = 'All Assistants in Database' + @assistants = Assistant.all # renders index.erb inside layout.erb view :index end - end end diff --git a/models/assistant.rb b/models/assistant.rb index 9c5730f..1101aae 100644 --- a/models/assistant.rb +++ b/models/assistant.rb @@ -1,24 +1,24 @@ -# app/models/assistant.rb +# 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? end - + # Optional: Add custom methods for common operations def self.find_by_name(name) where(name: name).first end - + def self.active where(active: true) end -end \ No newline at end of file +end diff --git a/views/index.erb b/views/index.erb index d83f99a..8bd9f7c 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1 +1,34 @@
| Name | +Run Command | +Reputation | +Context Length | +Prompt Rate | +Evaluation Rate | +Capabilities | +Created At | +
|---|---|---|---|---|---|---|---|
| <%= assistant.name %> | +<%= assistant.run_command %> | +<%= assistant.reputation || 'N/A' %> | +<%= assistant.context_length || 'N/A' %> | +<%= assistant.prompt_rate || 'N/A' %> | +<%= assistant.eval_rate || 'N/A' %> | +<%= assistant.capabilities || 'N/A' %> | +<%= assistant.created_at.strftime('%Y-%m-%d %H:%M') if assistant.created_at %> | +
No assistants found in the database.
+<% end %> \ No newline at end of file