diff --git a/app/models/api_service.rb b/app/models/api_service.rb index 303f501a0..89e2fd66a 100644 --- a/app/models/api_service.rb +++ b/app/models/api_service.rb @@ -31,6 +31,10 @@ def effective_token token.presence || default_llm_key end + def effective_token? + effective_token.present? + end + private def default_llm_key diff --git a/app/views/assistants/_assistant.html.erb b/app/views/assistants/_assistant.html.erb index 3e04f9fea..efb3f2c84 100644 --- a/app/views/assistants/_assistant.html.erb +++ b/app/views/assistants/_assistant.html.erb @@ -18,41 +18,55 @@ data-role="assistant" data-radio-behavior-target="radio" data-action="radio-changed@window->radio-behavior#select" - data-radio-behavior-id-param="<%= assistant.id %>" - data-transition-target="<%= !visible && 'transitionable' %>" + data-radio-behavior-id-param="<%= assistant.id %>" + data-transition-target="<%= !visible && 'transitionable' %>" > - <%= link_to new_assistant_message_path(assistant), class: "flex-1 flex py-1 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" } %> - <%= assistant.name %> - <% end %> - diff --git a/app/views/layouts/_assistant_avatar.erb b/app/views/layouts/_assistant_avatar.erb index 52efb8bd6..95f602529 100644 --- a/app/views/layouts/_assistant_avatar.erb +++ b/app/views/layouts/_assistant_avatar.erb @@ -14,7 +14,7 @@ elsif assistant.name.starts_with?("Meta Llama") end %> <% if logo %> - + <%= image_tag(logo, class: "w-full h-full") %> <% else %> diff --git a/test/controllers/settings/api_services_controller_test.rb b/test/controllers/settings/api_services_controller_test.rb index 33b1baf28..366b66674 100644 --- a/test/controllers/settings/api_services_controller_test.rb +++ b/test/controllers/settings/api_services_controller_test.rb @@ -10,7 +10,7 @@ class Settings::APIServicesControllerTest < ActionDispatch::IntegrationTest test "should get index" do get settings_api_services_url assert_response :success - assert_select "table#api-services tbody tr", count: 4 + assert_select "table#api-services tbody tr", count: 5 assert_select "p a", "Add New" assert_select "p#no-api-services", false end diff --git a/test/fixtures/api_services.yml b/test/fixtures/api_services.yml index cd9094939..37f1417a7 100644 --- a/test/fixtures/api_services.yml +++ b/test/fixtures/api_services.yml @@ -26,6 +26,11 @@ keith_other_service: token: abc-secret driver: openai +keith_missing_token_service: + name: Keith Server + user: keith + url: http://test.com/models + driver: openai rob_openai_service: name: OpenAI diff --git a/test/system/messages/nav_column_test.rb b/test/system/messages/nav_column_test.rb index 9c95448cc..6ed5395dc 100644 --- a/test/system/messages/nav_column_test.rb +++ b/test/system/messages/nav_column_test.rb @@ -160,4 +160,17 @@ class NavColumnTest < ApplicationSystemTestCase click_element pencil_on_second_assistant assert_current_path new_assistant_message_path(assistant2) end + + test "clicking the assistant name redirects to API service settings if token is missing" do + assistant = assistants(:keith_gpt4) + keith_missing_token_service = api_services(:keith_missing_token_service) + assistant.language_model.update! api_service: keith_missing_token_service + + conversation_path = conversation_messages_path(conversations(:greeting), version: 1) + visit conversation_path + + click_text assistant.name + + assert_current_path edit_settings_api_service_path(keith_missing_token_service) + end end