This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +40
-44
lines changed
controllers/discourse_ai/admin Expand file tree Collapse file tree 5 files changed +40
-44
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def index
1515 each_serializer : LlmModelSerializer ,
1616 root : false ,
1717 scope : {
18- llm_usage : DiscourseAi ::Configuration ::LlmValidator . global_usage ,
18+ llm_usage : DiscourseAi ::Configuration ::LlmEnumerator . global_usage ,
1919 } ,
2020 ) . as_json ,
2121 meta : {
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def used_by
2727 if ( scope && scope [ :llm_usage ] )
2828 scope [ :llm_usage ]
2929 else
30- DiscourseAi ::Configuration ::LlmValidator . global_usage
30+ DiscourseAi ::Configuration ::LlmEnumerator . global_usage
3131 end
3232 )
3333
Original file line number Diff line number Diff line change 55module DiscourseAi
66 module Configuration
77 class LlmEnumerator < ::EnumSiteSetting
8+ def self . global_usage
9+ rval = Hash . new { |h , k | h [ k ] = [ ] }
10+
11+ if SiteSetting . ai_bot_enabled
12+ LlmModel
13+ . where ( "enabled_chat_bot = ?" , true )
14+ . pluck ( :id )
15+ . each { |llm_id | rval [ llm_id ] << { type : :ai_bot } }
16+
17+ AiPersona
18+ . where ( "force_default_llm = ?" , true )
19+ . pluck ( :default_llm , :name , :id )
20+ . each do |llm_name , name , id |
21+ llm_id = llm_name . split ( ":" ) . last . to_i
22+ rval [ llm_id ] << { type : :ai_persona , name : name , id : id }
23+ end
24+ end
25+
26+ if SiteSetting . ai_helper_enabled
27+ model_id = SiteSetting . ai_helper_model . split ( ":" ) . last . to_i
28+ rval [ model_id ] << { type : :ai_helper }
29+ end
30+
31+ if SiteSetting . ai_summarization_enabled
32+ model_id = SiteSetting . ai_summarization_model . split ( ":" ) . last . to_i
33+ rval [ model_id ] << { type : :ai_summarization }
34+ end
35+
36+ if SiteSetting . ai_embeddings_semantic_search_enabled
37+ model_id = SiteSetting . ai_embeddings_semantic_search_hyde_model . split ( ":" ) . last . to_i
38+ rval [ model_id ] << { type : :ai_embeddings_semantic_search }
39+ end
40+
41+ rval
42+ end
43+
844 def self . valid_value? ( val )
945 true
1046 end
Original file line number Diff line number Diff line change 33module DiscourseAi
44 module Configuration
55 class LlmValidator
6- def self . global_usage
7- rval = Hash . new { |h , k | h [ k ] = [ ] }
8-
9- if SiteSetting . ai_bot_enabled
10- LlmModel
11- . where ( "enabled_chat_bot = ?" , true )
12- . pluck ( :id )
13- . each { |llm_id | rval [ llm_id ] << { type : :ai_bot } }
14-
15- AiPersona
16- . where ( "force_default_llm = ?" , true )
17- . pluck ( :default_llm , :name , :id )
18- . each do |llm_name , name , id |
19- llm_id = llm_name . split ( ":" ) . last . to_i
20- rval [ llm_id ] << { type : :ai_persona , name : name , id : id }
21- end
22- end
23-
24- if SiteSetting . ai_helper_enabled
25- model_id = SiteSetting . ai_helper_model . split ( ":" ) . last . to_i
26- rval [ model_id ] << { type : :ai_helper }
27- end
28-
29- if SiteSetting . ai_summarization_enabled
30- model_id = SiteSetting . ai_summarization_model . split ( ":" ) . last . to_i
31- rval [ model_id ] << { type : :ai_summarization }
32- end
33-
34- if SiteSetting . ai_embeddings_semantic_search_enabled
35- model_id = SiteSetting . ai_embeddings_semantic_search_hyde_model . split ( ":" ) . last . to_i
36- rval [ model_id ] << { type : :ai_embeddings_semantic_search }
37- end
38-
39- rval
40- end
41-
426 def initialize ( opts = { } )
437 @opts = opts
448 end
Original file line number Diff line number Diff line change 1212 visit "/admin/plugins/discourse-ai/ai-llms"
1313
1414 find ( "[data-llm-id='anthropic-claude-3-haiku'] button" ) . click ( )
15-
1615 find ( "input.ai-llm-editor__api-key" ) . fill_in ( with : "abcd" )
17-
18- PageObjects ::Components ::DToggleSwitch . new ( ".ai-llm-editor__enabled-chat-bot" ) . toggle
19-
16+ find ( ".ai-llm-editor__enabled-chat-bot input" ) . click
2017 find ( ".ai-llm-editor__save" ) . click ( )
2118
2219 expect ( page ) . to have_current_path ( "/admin/plugins/discourse-ai/ai-llms" )
5552 find ( ".select-kit-row[data-name=\" Llama3Tokenizer\" ]" ) . click
5653
5754 find ( ".ai-llm-editor__vision-enabled input" ) . click
58-
59- PageObjects ::Components ::DToggleSwitch . new ( ".ai-llm-editor__enabled-chat-bot" ) . toggle
55+ find ( ".ai-llm-editor__enabled-chat-bot input" ) . click
6056
6157 find ( ".ai-llm-editor__save" ) . click ( )
6258
You can’t perform that action at this time.
0 commit comments