diff --git a/app/controllers/discourse_ai/admin/ai_llms_controller.rb b/app/controllers/discourse_ai/admin/ai_llms_controller.rb index 72cd7b13..2292e98c 100644 --- a/app/controllers/discourse_ai/admin/ai_llms_controller.rb +++ b/app/controllers/discourse_ai/admin/ai_llms_controller.rb @@ -110,9 +110,7 @@ module DiscourseAi ) provider = updating ? updating.provider : permitted[:provider] - permit_url = - (updating && updating.url != LlmModel::RESERVED_VLLM_SRV_URL) || - provider != LlmModel::BEDROCK_PROVIDER_NAME + permit_url = provider != LlmModel::BEDROCK_PROVIDER_NAME permitted[:url] = params.dig(:ai_llm, :url) if permit_url diff --git a/app/models/llm_model.rb b/app/models/llm_model.rb index 73666dd5..8e6049b4 100644 --- a/app/models/llm_model.rb +++ b/app/models/llm_model.rb @@ -2,44 +2,10 @@ class LlmModel < ActiveRecord::Base FIRST_BOT_USER_ID = -1200 - RESERVED_VLLM_SRV_URL = "https://vllm.shadowed-by-srv.invalid" BEDROCK_PROVIDER_NAME = "aws_bedrock" belongs_to :user - validates :url, exclusion: { in: [RESERVED_VLLM_SRV_URL] }, if: :url_changed? - - def self.seed_srv_backed_model - srv = SiteSetting.ai_vllm_endpoint_srv - srv_model = find_by(url: RESERVED_VLLM_SRV_URL) - - if srv.present? - if srv_model.present? - current_key = SiteSetting.ai_vllm_api_key - srv_model.update!(api_key: current_key) if current_key != srv_model.api_key - else - record = - new( - display_name: "vLLM SRV LLM", - name: "mistralai/Mixtral-8x7B-Instruct-v0.1", - provider: "vllm", - tokenizer: "DiscourseAi::Tokenizer::MixtralTokenizer", - url: RESERVED_VLLM_SRV_URL, - max_prompt_tokens: 8000, - api_key: SiteSetting.ai_vllm_api_key, - ) - - record.save(validate: false) # Ignore reserved URL validation - end - else - # Clean up companion users - srv_model&.enabled_chat_bot = false - srv_model&.toggle_companion_user - - srv_model&.destroy! - end - end - def self.provider_params { aws_bedrock: { @@ -54,7 +20,7 @@ class LlmModel < ActiveRecord::Base end def to_llm - DiscourseAi::Completions::Llm.proxy_from_obj(self) + DiscourseAi::Completions::Llm.proxy("custom:#{id}") end def toggle_companion_user diff --git a/app/serializers/llm_model_serializer.rb b/app/serializers/llm_model_serializer.rb index 71a1c1b9..2ef1b28b 100644 --- a/app/serializers/llm_model_serializer.rb +++ b/app/serializers/llm_model_serializer.rb @@ -19,6 +19,6 @@ class LlmModelSerializer < ApplicationSerializer has_one :user, serializer: BasicUserSerializer, embed: :object def shadowed_by_srv - object.url == LlmModel::RESERVED_VLLM_SRV_URL + object.url.to_s.starts_with?("srv://") end end diff --git a/assets/javascripts/discourse/components/ai-llm-editor-form.gjs b/assets/javascripts/discourse/components/ai-llm-editor-form.gjs index 20ce95db..48d239a5 100644 --- a/assets/javascripts/discourse/components/ai-llm-editor-form.gjs +++ b/assets/javascripts/discourse/components/ai-llm-editor-form.gjs @@ -60,17 +60,9 @@ export default class AiLlmEditorForm extends Component { return this.testRunning || this.testResult !== null; } - get displaySRVWarning() { - return this.args.model.shadowed_by_srv && !this.args.model.isNew; - } - get canEditURL() { // Explicitly false. - if (this.metaProviderParams.url_editable === false) { - return false; - } - - return !this.args.model.shadowed_by_srv || this.args.model.isNew; + return this.metaProviderParams.url_editable !== false; } @computed("args.model.provider") @@ -174,12 +166,6 @@ export default class AiLlmEditorForm extends Component { }