55module  DiscourseAi 
66  module  Configuration 
77    class  LlmEnumerator  < ::EnumSiteSetting 
8-       # TODO: global_usage is no longer accurate, it should be removed/updated 
98      def  self . global_usage 
109        rval  =  Hash . new  {  |h ,  k | h [ k ]  =  [ ]  } 
1110
@@ -23,24 +22,53 @@ def self.global_usage
2322          . each  {  |llm_id ,  name ,  id | rval [ llm_id ]  << {  type : :ai_persona ,  name : name ,  id : id  }  } 
2423
2524        if  SiteSetting . ai_helper_enabled 
26-           model_id  =  SiteSetting . ai_helper_model . split ( ":" ) . last . to_i 
27-           rval [ model_id ]  << {  type : :ai_helper  }  if  model_id  != 0 
25+           { 
26+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.proofread" ) }  "  => 
27+               SiteSetting . ai_helper_proofreader_persona , 
28+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.title_suggestions" ) }  "  => 
29+               SiteSetting . ai_helper_title_suggestions_persona , 
30+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.explain" ) }  "  => 
31+               SiteSetting . ai_helper_explain_persona , 
32+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.illustrate_post" ) }  "  => 
33+               SiteSetting . ai_helper_post_illustrator_persona , 
34+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.smart_dates" ) }  "  => 
35+               SiteSetting . ai_helper_smart_dates_persona , 
36+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.translator" ) }  "  => 
37+               SiteSetting . ai_helper_translator_persona , 
38+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.markdown_tables" ) }  "  => 
39+               SiteSetting . ai_helper_markdown_tables_persona , 
40+             "#{ I18n . t ( "js.discourse_ai.features.ai_helper.custom_prompt" ) }  "  => 
41+               SiteSetting . ai_helper_custom_prompt_persona , 
42+           } . each  do  |helper_type ,  persona_id |
43+             next  if  persona_id . blank? 
44+ 
45+             persona  =  AiPersona . find_by ( id : persona_id ) 
46+             next  if  persona . blank?  || persona . default_llm_id . blank? 
47+ 
48+             model_id  =  persona . default_llm_id  || SiteSetting . ai_default_llm_model . to_i 
49+             rval [ model_id ]  << {  type : :ai_helper ,  name : helper_type  } 
50+           end 
2851        end 
2952
30-         if  SiteSetting . ai_helper_image_caption_model 
31-           model_id  =  SiteSetting . ai_helper_image_caption_model . split ( ":" ) . last . to_i 
32-           rval [ model_id ]  << {  type : :ai_helper_image_caption  }  if  model_id  != 0 
53+         if  SiteSetting . ai_helper_enabled_features . split ( "|" ) . include? ( "image_caption" ) 
54+           image_caption_persona  =  AiPersona . find_by ( id : SiteSetting . ai_helper_image_caption_persona ) 
55+           model_id  =  image_caption_persona . default_llm_id  || SiteSetting . ai_default_llm_model . to_i 
56+ 
57+           rval [ model_id ]  << {  type : :ai_helper_image_caption  } 
3358        end 
3459
3560        if  SiteSetting . ai_summarization_enabled 
3661          summarization_persona  =  AiPersona . find_by ( id : SiteSetting . ai_summarization_persona ) 
37-           model_id  =  summarization_persona . default_llm_id  || LlmModel . last &. id 
62+           model_id  =  summarization_persona . default_llm_id  || SiteSetting . ai_default_llm_model . to_i 
3863
3964          rval [ model_id ]  << {  type : :ai_summarization  } 
4065        end 
4166
4267        if  SiteSetting . ai_embeddings_semantic_search_enabled 
43-           model_id  =  SiteSetting . ai_embeddings_semantic_search_hyde_model . split ( ":" ) . last . to_i 
68+           search_persona  = 
69+             AiPersona . find_by ( id : SiteSetting . ai_embeddings_semantic_search_hyde_persona ) 
70+           model_id  =  search_persona . default_llm_id  || SiteSetting . ai_default_llm_model . to_i 
71+ 
4472          rval [ model_id ]  << {  type : :ai_embeddings_semantic_search  } 
4573        end 
4674
0 commit comments