mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-10 21:44:42 +00:00
* UX: Validations to Llm-backed features (except AI Bot) This change is part of an ongoing effort to prevent enabling a broken feature due to lack of configuration. We also want to explicit which provider we are going to use. For example, Claude models are available through AWS Bedrock and Anthropic, but the configuration differs. Validations are: * You must choose a model before enabling the feature. * You must turn off the feature before setting the model to blank. * You must configure each model settings before being able to select it. * Add provider name to summarization options * vLLM can technically support same models as HF * Check we can talk to the selected model * Check for Bedrock instead of anthropic as a site could have both creds setup
45 lines
844 B
Ruby
45 lines
844 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Summarization
|
|
module Models
|
|
class Base
|
|
def initialize(model_name, max_tokens:)
|
|
@model_name = model_name
|
|
@max_tokens = max_tokens
|
|
end
|
|
|
|
def correctly_configured?
|
|
raise NotImplemented
|
|
end
|
|
|
|
def display_name
|
|
raise NotImplemented
|
|
end
|
|
|
|
def configuration_hint
|
|
raise NotImplemented
|
|
end
|
|
|
|
def available_tokens
|
|
max_tokens - reserved_tokens
|
|
end
|
|
|
|
def model
|
|
model_name.split(":").last
|
|
end
|
|
|
|
attr_reader :model_name, :max_tokens
|
|
|
|
protected
|
|
|
|
def reserved_tokens
|
|
# Reserve tokens for the response and the base prompt
|
|
# ~500 words
|
|
700
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|