mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-14 15:34:42 +00:00
DEV: Only permit config of allowed seeded models (#1103)
This update resolves a regression that was introduced in https://github.com/discourse/discourse-ai/pull/1036/files. Previously, only seeded models that were allowed could be configured for model settings. However, in our attempts to prevent unreachable LLM errors from not allowing settings to persist, it also unknowingly allowed seeded models that were not allowed to be configured. This update resolves this issue, while maintaining the ability to still set unreachable LLMs.
This commit is contained in:
parent
980f17a338
commit
13f9a1908a
@ -2,6 +2,9 @@
|
||||
|
||||
module DiscourseAi
|
||||
module Configuration
|
||||
class InvalidSeededModelError < StandardError
|
||||
end
|
||||
|
||||
class LlmValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
@ -18,8 +21,12 @@ module DiscourseAi
|
||||
allowed_seeded_model?(val)
|
||||
|
||||
run_test(val).tap { |result| @unreachable = result }
|
||||
rescue DiscourseAi::Configuration::InvalidSeededModelError => e
|
||||
@unreachable = true
|
||||
false
|
||||
rescue StandardError => e
|
||||
raise e if Rails.env.test?
|
||||
@unreachable = true
|
||||
true
|
||||
end
|
||||
|
||||
@ -76,7 +83,7 @@ module DiscourseAi
|
||||
|
||||
if allowed_list.split("|").exclude?(id)
|
||||
@invalid_seeded_model = true
|
||||
raise Discourse::InvalidParameters.new
|
||||
raise DiscourseAi::Configuration::InvalidSeededModelError.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user