Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new & manage Assistants #334

Merged
merged 88 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
92729a3
Encrypt the API keys for OpenAI and Anthropic
stephan-buckmaster Apr 16, 2024
bfd663e
Review comments: explain config.active_record.encryption.support_unen…
stephan-buckmaster Apr 18, 2024
c5cc86e
Merge latest from upstream, resolve merge conflict in db/schema.rb
stephan-buckmaster Apr 18, 2024
df65e2f
Merge from upstream
stephan-buckmaster Apr 19, 2024
f91da68
Restore original config/database.yml, remove .gitignore entry, and co…
stephan-buckmaster Apr 19, 2024
92024cf
Update README with respect to credentials.yml.enc, remove the sample …
stephan-buckmaster Apr 19, 2024
01c25cc
Merge branch 'main' into main
krschacht Apr 21, 2024
7f269e6
Merge branch 'upstream-main' -- (update for Render plan)
stephan-buckmaster Apr 24, 2024
89f80f7
Have keys related to active record encryption generated on Render via…
stephan-buckmaster Apr 24, 2024
51960d0
Have keys related to active record encryption generated on Render via…
stephan-buckmaster Apr 24, 2024
746d89f
Use an config/initializer for configuring active record encryption
stephan-buckmaster Apr 24, 2024
96e3340
Merge from upstream
stephan-buckmaster Apr 25, 2024
e26a5b1
Encrypt the email field of Person records also
stephan-buckmaster Apr 26, 2024
0349a83
Merge from upstream
stephan-buckmaster Apr 26, 2024
d1bf816
Merge upstream
stephan-buckmaster Apr 29, 2024
e5a2af1
cleanup migration
krschacht Apr 29, 2024
02cbed2
ensure encryption init happens with db:prepare
krschacht Apr 29, 2024
8490064
make docker entrypoint more resilient
krschacht Apr 29, 2024
5c571b5
Update readme and startup script
krschacht Apr 29, 2024
a52a289
fix whitespace
krschacht Apr 29, 2024
d99e387
update test runner
krschacht Apr 29, 2024
776ec26
Fix running tests in docker within dev
krschacht Apr 30, 2024
438bf8c
Add generation of master.key
krschacht Apr 30, 2024
6f2d938
simplify generation of ar encryption keys
krschacht Apr 30, 2024
77032c3
Merge upstream
stephan-buckmaster May 4, 2024
bac0e0d
Merge from upstream
stephan-buckmaster May 7, 2024
a178675
Allow adding new assistants
stephan-buckmaster May 8, 2024
06de134
Load all assistants when editing, only show 5 initially
stephan-buckmaster May 10, 2024
d919d6e
Rename ai_api_models table to llms
stephan-buckmaster May 10, 2024
dad33d5
Use label Custom Instructions in the Assistant form
stephan-buckmaster May 10, 2024
a299cb1
Less clumsy way to keep additional assistants shown when editing one …
stephan-buckmaster May 10, 2024
b3edb57
Add back the New Assistant link
stephan-buckmaster May 10, 2024
f525b96
Fix the collapse mechanism
stephan-buckmaster May 10, 2024
f33f388
Refactor display of Assistant section under Settings
stephan-buckmaster May 12, 2024
808285e
Have assistant list truncated in message view also (but there is no n…
stephan-buckmaster May 12, 2024
77dcefb
Rename the LLM model (all-caps identifiers are usually constants) to …
stephan-buckmaster May 12, 2024
de6c887
Update list of language models, Assistant model belongs_to LanguageMo…
stephan-buckmaster May 13, 2024
8b98bfa
Fix tests until question of adding language_model_id to assistants ta…
stephan-buckmaster May 13, 2024
d749276
Merge from upstream
stephan-buckmaster May 14, 2024
c7c0bd3
Tests are passing, added language_models fixtures which are a bit ra…
stephan-buckmaster May 15, 2024
c3d641d
Merge upstream
stephan-buckmaster May 15, 2024
812a6c0
Merge upstream
stephan-buckmaster May 15, 2024
ffe6de5
Merge branch 'main' into 308-manage-assistants
stephan-buckmaster May 15, 2024
bb32de5
Update assistants/language_models link, add LanguageModel constants a…
stephan-buckmaster May 15, 2024
abf9cf5
Fix system tests
stephan-buckmaster May 16, 2024
668b94c
Fixed migration, also left model column in the runs table
stephan-buckmaster May 16, 2024
6f3fbd0
Populate runs.model from the name of the assistant's language_model
stephan-buckmaster May 16, 2024
3ce4368
Fix rubocop issues
stephan-buckmaster May 16, 2024
5671754
Soft-deletion of assistants
stephan-buckmaster May 16, 2024
c0ab70d
Let's have an explicit position column for ordering
krschacht May 19, 2024
58d5650
Add association + updates fixtures do ref by name
krschacht May 19, 2024
2226188
Improve styling of external assistant list
krschacht May 19, 2024
1960c30
Remove explicit ref to LLM id's to be less brittle
krschacht May 19, 2024
958bebc
Tweak styling of the assistants edit page
krschacht May 19, 2024
594bc97
Remove assistant overflow on settings since it's not easy to simplify
krschacht May 19, 2024
c5eec77
Simplify conditional logic for convo's with deleted assistants
krschacht May 19, 2024
eece44d
Remove helper methods which get are already added automatically
krschacht May 19, 2024
2da5b5a
Slightly simplify logic w/ provider_name
krschacht May 19, 2024
1db3248
Ensure all assistants (incl deleted) are destroyed w/ a user
krschacht May 19, 2024
de75b25
Merge upstream
stephan-buckmaster May 20, 2024
d8cc7e2
Merge upstream into 308-manage-assistants
stephan-buckmaster May 20, 2024
6d8a141
Merge upstream into 308-manage-assistants
stephan-buckmaster May 20, 2024
9b0a31c
Review comments, fixing code + allowing dev to choose development/tes…
stephan-buckmaster May 21, 2024
ccbc7e4
Allowing user.destroy to work as previously
stephan-buckmaster May 21, 2024
02bd81e
Test updates round 1
stephan-buckmaster May 22, 2024
6c2d447
Tests for what gets sent to the API client libraries
stephan-buckmaster May 22, 2024
19b60a6
Test for message display when assistant is deleted
stephan-buckmaster May 22, 2024
5622e3b
Merge branch 'main' into pr/stephan-buckmaster/334
krschacht May 24, 2024
b80b060
Change how test stubbing works for OpenAI to detect model
krschacht May 24, 2024
88142ad
Some additional merge cleanup
krschacht May 24, 2024
f146f35
Correct an accidental hardcoding in string
krschacht May 24, 2024
c90adcd
Fix typos in README.md
stephan-buckmaster May 25, 2024
f8b6c4d
Assistants delegate supports_images? to their language model
stephan-buckmaster May 25, 2024
e49eef9
Ensured documents have assistant populated when available
stephan-buckmaster May 26, 2024
ea07426
Make sure documents.assistant_id is consistent with messages.assistan…
stephan-buckmaster May 26, 2024
97a4a2e
Merge from upstream
stephan-buckmaster May 26, 2024
d55ad9d
Remove trailing whitespace+accidental comment
stephan-buckmaster May 26, 2024
228f5a0
Merge branch 'main' into pr/stephan-buckmaster/334
krschacht May 27, 2024
cd612b8
Readme
krschacht May 27, 2024
e03f125
Complete an initial pass of tests with some cleanup
krschacht May 27, 2024
5b1a89c
Finish reviewing tests & ensuring all pass
krschacht May 27, 2024
27ec521
Update migrations
krschacht May 27, 2024
1d9f45c
database yml
krschacht May 27, 2024
3f1595e
Revise some settings view rendering logic
krschacht May 27, 2024
efaaf3b
Remove attr
krschacht May 27, 2024
c23297d
Remove some unused code
krschacht May 28, 2024
5f7a0db
Final tweaks
krschacht May 28, 2024
7c95ee3
restore database.yml
krschacht May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/assistants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def set_assistant
end

def assistant_params
params.require(:assistant).permit(:user_id, :model, :name, :description, :instructions, :tools)
params.require(:assistant).permit(:user_id, :language_model_id, :name, :description, :instructions, :tools)
end
end
11 changes: 9 additions & 2 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def create
def update
# Clicking edit beneath a message actually submits to create and not here. This action is only used for next/prev conversation.
# In order to force a morph we PATCH to here and redirect.
if @message.update(message_params)
@message.allow_deleted_assistant = true # disable that validation
stephan-buckmaster marked this conversation as resolved.
Show resolved Hide resolved
if @message.update(version_navigate_message_params)
redirect_to conversation_messages_path(@message.conversation, version: @version || @message.version)
else
render :edit, status: :unprocessable_entity
Expand All @@ -76,7 +77,7 @@ def set_conversation
end

def set_assistant
@assistant = Current.user.assistants.find_by(id: params[:assistant_id])
@assistant = Current.user.assistants_including_deleted.find_by(id: params[:assistant_id])
@assistant ||= @conversation.latest_message_for_version(@version).assistant
end

Expand All @@ -90,6 +91,7 @@ def set_nav_conversations

def set_nav_assistants
@nav_assistants = Current.user.assistants.ordered
@hide_settings_assistants_overflow = @nav_assistants.length > Assistant::MAX_LIST_DISPLAY
end

def message_params
Expand All @@ -110,4 +112,9 @@ def message_params
end
modified_params
end

def version_navigate_message_params
params.require(:message).permit(:conversation_id, :version)
end
end

25 changes: 13 additions & 12 deletions app/controllers/settings/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
class Settings::ApplicationController < ApplicationController
layout "settings"
before_action :set_settings_menu
before_action :set_settings_assistants

private

def set_settings_menu
# controller_name => array of items
@settings_menu = {
assistants: Current.user.assistants.ordered.map {
def set_settings_assistants
settings_assistants = Current.user.assistants.ordered.map {
|assistant| [ assistant, edit_settings_assistant_path(assistant) ]
}.to_h.merge({
#'New Assistant': new_settings_assistant_path(assistant)
}),

people: {
'Account': edit_settings_person_path
}
}
if settings_assistants.length > Assistant::MAX_LIST_DISPLAY
assistants_to_hide = settings_assistants[Assistant::MAX_LIST_DISPLAY, settings_assistants.length - Assistant::MAX_LIST_DISPLAY]
# If user is editing an "overflow assistant" don't collapse that section, keep it open from the start
@hide_settings_assistants_overflow = params[:controller] !='settings/assistants' ||
params[:action] != 'edit' ||
!assistants_to_hide.map(&:first).map(&:id).include?(params[:id].to_i)
end
@settings_menu = {assistants: settings_assistants.to_h,
new_assistant: {'New Assistant': new_settings_assistant_path},
people: {'Account': edit_settings_person_path}}
end
end
7 changes: 5 additions & 2 deletions app/controllers/settings/assistants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ def destroy
private

def set_assistant
@assistant = Current.user.assistants.find(params[:id])
@assistant = Current.user.assistants.where(id: params[:id]).first
if @assistant.nil?
redirect_to new_settings_assistant_url, notice: 'The assistant was deleted', status: :see_other
end
end

def assistant_params
params.require(:assistant).permit(:name, :description, :instructions)
params.require(:assistant).permit(:name, :description, :instructions, :language_model_id)
end
end
12 changes: 12 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
module ApplicationHelper

def hide_assistant_class(item, item_counter)
return nil unless item.is_a?(Assistant)
return 'hidden' if @hide_settings_assistants_overflow && item_counter >= Assistant::MAX_LIST_DISPLAY
nil
end

def assitant_data_transaction_target(item, item_counter)
return nil unless item.is_a?(Assistant)
return 'data-transition-target="transitionable"'.html_safe if @hide_settings_assistants_overflow && item_counter >= Assistant::MAX_LIST_DISPLAY
end

def spinner(opts = {})
html = <<~HTML
<svg class="animate-spin -ml-1 mr-3 h-#{opts[:size]} w-#{opts[:size]} #{opts[:class]}" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
Expand Down
6 changes: 1 addition & 5 deletions app/jobs/get_next_ai_message_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ class WaitForPrevious < StandardError; end
retry_on WaitForPrevious, wait: ->(run) { (2**run - 1).seconds }, attempts: 3

def ai_backend
if @assistant.model.starts_with?('gpt-')
AIBackends::OpenAI
else
AIBackends::Anthropic
end
@assistant.language_model.ai_backend
end

def perform(user_id, message_id, assistant_id, attempt = 1)
Expand Down
16 changes: 16 additions & 0 deletions app/models/assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ class Assistant < ApplicationRecord
has_many :steps, dependent: :destroy
has_many :messages # TODO: What should happen if an assistant is deleted?

belongs_to :language_model

validates :tools, presence: true, allow_blank: true
validates :name, presence: true

MAX_LIST_DISPLAY = 5

scope :ordered, -> { order(:id) }

scope :not_deleted, -> { where(deleted_at: nil) }

def initials
return nil if name.blank?

Expand All @@ -20,6 +27,15 @@ def initials
parts[1]&.try(:[], 0)&.capitalize.to_s
end

def destroy
raise "Can't delete user's last assistant" if user.assistants.count < 2
update!(deleted_at: Time.now)
end

def deleted?
deleted_at.present?
end

def to_s
name
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/user/registerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ module User::Registerable
private

def create_initial_assistants
assistants.create! name: "GPT-4", model: "gpt-4o-2024-05-13", images: true
assistants.create! name: "GPT-3.5", model: "gpt-3.5-turbo-0125", images: false
assistants.create! name: "Claude 3 Opus", model: "claude-3-opus-20240229", images: true
assistants.create! name: "Claude 3 Sonnet", model: "claude-3-sonnet-20240229", images: true
assistants.create! name: "GPT (best)", language_model_id: LanguageModel::GPT_BEST_ID, images: true
assistants.create! name: "GPT-3.5", language_model_id: LanguageModel::GPT_3_5_ID, images: false
assistants.create! name: "Claude (best)", language_model_id: LanguageModel::CLAUDE_BEST_ID, images: true
assistants.create! name: "Claude 3 Sonnet", language_model_id: LanguageModel::CLAUDE_3_SONNET_ID, images: true
end
end
30 changes: 30 additions & 0 deletions app/models/language_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# We don't care about large or not
class LanguageModel < ApplicationRecord
def readonly?
!new_record?
end

def before_destroy
raise ActiveRecord::ReadOnlyRecord
end
stephan-buckmaster marked this conversation as resolved.
Show resolved Hide resolved

PROVIDER_ID_MAP = {'gpt-best': 'gpt-4-turbo',
'claude-best': 'claude-3-opus-20240229'}

GPT_BEST_ID = 1
CLAUDE_BEST_ID = 2
GPT_3_5_ID = 12
CLAUDE_3_SONNET_ID = 18

def provider_id
PROVIDER_ID_MAP[self.name.to_sym] || self.name unless self.name =~ /^best/
end

def ai_backend
if name.starts_with?('gpt-')
AIBackends::OpenAI
else
AIBackends::Anthropic
end
end
end
2 changes: 2 additions & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Message < ApplicationRecord

scope :ordered, -> { latest_version_for_conversation }

attr_accessor :allow_deleted_assistant
private

def create_conversation
Expand All @@ -38,6 +39,7 @@ def validate_conversation

def validate_assistant
errors.add(:assistant, 'is invalid') unless assistant.user == Current.user
errors.add(:assistant, 'has been deleted') if assistant.deleted? && !allow_deleted_assistant
end

def start_assistant_reply
Expand Down
7 changes: 7 additions & 0 deletions app/models/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ class Run < ApplicationRecord

enum status: %w[queued in_progress requires_action cancelling cancelled failed completed expired].index_by(&:to_sym)

before_validation :set_model, on: :create
validates :status, :expired_at, :model, :instructions, presence: true
validates :tools, :file_ids, presence: true, allow_blank: true

private

def set_model
self.model = assistant&.language_model&.name
end
end
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class User < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true, on: :create

has_many :assistants, dependent: :destroy
has_many :assistants, -> { not_deleted }, dependent: :destroy
has_many :assistants_including_deleted, class_name: "Assistant"
has_many :conversations, dependent: :destroy
belongs_to :last_cancelled_message, class_name: "Message", optional: true

Expand Down
2 changes: 1 addition & 1 deletion app/services/ai_backends/anthropic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_next_chat_message(&chunk_received_handler)

begin
response = @client.messages(
model: @assistant.model,
model: @assistant.language_model.provider_id,
system: @assistant.instructions,
stephan-buckmaster marked this conversation as resolved.
Show resolved Hide resolved
messages: preceding_messages,
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion app/services/ai_backends/open_ai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_next_chat_message(&chunk_received_handler)

begin
response = @client.chat(parameters: {
model: @assistant.model,
model: @assistant.language_model.provider_id,
messages: system_message + preceding_messages,
stream: response_handler,
max_tokens: 2000, # we should really set this dynamically, based on the model, to the max
Expand Down
2 changes: 2 additions & 0 deletions app/views/assistants/_assistant.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
group cursor-pointer
text-sm rounded-lg
<%= selected && 'relationship' %>
<%= hide_assistant_class(assistant, assistant_counter) %>
"
data-role="assistant"
data-radio-behavior-target="radio"
data-action="radio-changed@window->radio-behavior#select"
data-radio-behavior-id-param="<%= assistant.id %>"
<%= assitant_data_transaction_target(assistant, assistant_counter) %>
>
<%= link_to new_assistant_message_path(assistant), class: "flex-1 flex items-center text-gray-950 dark:text-gray-100 font-medium truncate", data: { role: "name" } do %>
<%= render partial: "layouts/assistant_avatar", locals: { assistant: assistant, size: 7, classes: "mr-2" } %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/assistants/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</div>

<div class="my-5">
<%= form.label :model %>
<%= form.text_field :model, value: "gpt-4", class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
<%= form.label :language_model_id %><br/>
<%= form.select :language_model_id, LanguageModel.order(:description).all.pluck(:description, :id), class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black" %>
</div>

<div class="my-5">
Expand Down
2 changes: 1 addition & 1 deletion app/views/assistants/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<p class="my-5">
<strong class="block font-medium mb-1">Model:</strong>
<%= @assistant.model %>
<%= @assistant.language_model.description %>
</p>

<p class="my-5">
Expand Down
10 changes: 6 additions & 4 deletions app/views/layouts/_settings_item.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<% item, link = settings_item %>
<% selected = (controller.to_s == controller_name.to_s) %>
<% selected = selected && params[:id] == item.id.to_s if params[:id] %>
<% compare_id = item.respond_to?(:id) ? item.id.to_s : '' %>
<% selected = selected && params[:id] == compare_id if params[:id] %>
<% selected = selected && request.fullpath == link if params[:id].blank? %>
krschacht marked this conversation as resolved.
Show resolved Hide resolved

<div class="
flex justify-between items-center
Expand All @@ -9,8 +11,10 @@
group
text-sm rounded-s-lg
<%= selected ? "bg-gray-200 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-700 cursor-default" : "cursor-pointer" %>
<%= hide_assistant_class(item, settings_item_counter) %>
"
data-role="assistant"
<%= assitant_data_transaction_target(item, settings_item_counter) %>
>
<%= link_to link,
class: %|
Expand All @@ -27,8 +31,6 @@
<div id="profile" class="mr-2 w-7 h-7 bg-blue-200 rounded-full"></div>
<% end %>

<span class="<%= !item.is_a?(Assistant) && "ml-1 text-base" %>">
<%= item.to_s %>
</span>
<%= content_tag :span, item.to_s, class: !item.is_a?(Assistant) && "ml-1 text-base" %>
<% end %>
</div>
14 changes: 12 additions & 2 deletions app/views/layouts/settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@
Settings
</header>
<section id="menu" data-controller="radio-behavior" data-radio-behavior-selected-class="relationship">
<% @settings_menu.each do |controller, settings_items| %>
<% if @hide_settings_assistants_overflow %>
<div data-controller="transition" data-transition-toggle-class="hidden">
<%= button_tag type: "button",
class: "p-1 text-sm",
data: {transition_target: "transitionable", action: "transition#toggleClass",
} do %>
Show Remaining
<% end %>
<% end %>

<% @settings_menu.each do | controller, settings_items| %>
<div class="mb-5">
<%= render partial: "layouts/settings_item", collection: settings_items, locals: { controller: controller } %>
<%= render partial: "layouts/settings_item", collection: settings_items, locals: { controller: :assistants } %>
</div>
<% end %>
krschacht marked this conversation as resolved.
Show resolved Hide resolved
</section>
Expand Down
8 changes: 7 additions & 1 deletion app/views/messages/_main_column.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,15 @@
<% end %>
</div>

<div id="composer"
<div id="composer"
class="flex-1 pl-6 pr-6 w-full md:max-w-none lg:max-w-[700px] xl:max-w-[810px] mx-auto relative leading-relaxed <%= @assistant.images.blank? && 'relationship' %>"
data-controller="composer image-upload"
>
<% if @assistant.deleted? %>
<div class="text-center">
<p>This assistant has been deleted, and cannot assist any longer.</p>
</div>
<% else %>
<%= button_tag type: "button",
id: "attach-button",
class: "absolute left-11 bottom-[26px] w-[23px] h-[23px] relationship:hidden",
Expand Down Expand Up @@ -362,6 +367,7 @@
</div>

<% end %>
<% end %>
</div>

<div class="w-full mb-2 text-xs text-center text-gray-400 dark:text-gray-300">
Expand Down
6 changes: 3 additions & 3 deletions app/views/messages/_message.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ end
<% end %>
<% end %>

<% if message.user? && !message.has_document_image? %>
<% if message.user? && !message.has_document_image? && !message.assistant.deleted? %>
<%= link_to edit_assistant_message_path(message.assistant, message),
class: "cursor-pointer hover:text-gray-900 dark:hover:text-white flex items-center",
data: {
Expand All @@ -171,7 +171,7 @@ end
} do %>
<%= icon "pencil", variant: :outline, size: 18, title: "Edit" %>
<% end %>
<% elsif message.assistant? %>
<% elsif message.assistant? && !message.assistant.deleted? %>
<%= button_tag type: "button",
class: "cursor-pointer hover:text-gray-900 dark:hover:text-white",
data: {
Expand Down Expand Up @@ -261,4 +261,4 @@ end
<% end %>
</div>
</div>
</div>
</div>
Loading
Loading