added viewing all assistants
This commit is contained in:
parent
6c27feb9e7
commit
a80ba5bfe0
10
app.rb
10
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1 +1,34 @@
|
|||
<h2 class="subtitle"><%= @subtitle %></h2>
|
||||
|
||||
<% if @assistants.any? %>
|
||||
<table class="table is-striped is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Run Command</th>
|
||||
<th>Reputation</th>
|
||||
<th>Context Length</th>
|
||||
<th>Prompt Rate</th>
|
||||
<th>Evaluation Rate</th>
|
||||
<th>Capabilities</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @assistants.each do |assistant| %>
|
||||
<tr>
|
||||
<td><%= assistant.name %></td>
|
||||
<td><%= assistant.run_command %></td>
|
||||
<td><%= assistant.reputation || 'N/A' %></td>
|
||||
<td><%= assistant.context_length || 'N/A' %></td>
|
||||
<td><%= assistant.prompt_rate || 'N/A' %></td>
|
||||
<td><%= assistant.eval_rate || 'N/A' %></td>
|
||||
<td><%= assistant.capabilities || 'N/A' %></td>
|
||||
<td><%= assistant.created_at.strftime('%Y-%m-%d %H:%M') if assistant.created_at %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p>No assistants found in the database.</p>
|
||||
<% end %>
|
||||
Loading…
Reference in a new issue