Module: Observ::ChatsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/observ/chats_helper.rb
Instance Method Summary collapse
-
#agent_select_options ⇒ Array<Array<String>>
Returns formatted agent selection options for the chat form.
-
#agents_with_prompts_map ⇒ Hash<String, String>
Returns a map of agent class names to their prompt names.
Instance Method Details
#agent_select_options ⇒ Array<Array<String>>
Returns formatted agent selection options for the chat form
This helper provides agent selection options for use in select dropdowns. The options are memoized per request to avoid redundant agent discovery.
Usage in views:
<%= form.select :agent_class_name, agent_select_options, {}, class: "observ-select" %>
15 16 17 |
# File 'app/helpers/observ/chats_helper.rb', line 15 def ||= AgentSelectionService. end |
#agents_with_prompts_map ⇒ Hash<String, String>
Returns a map of agent class names to their prompt names
This helper identifies which agents use prompt management and maps them to their configured prompt names. Used by the chat form's Stimulus controller to dynamically show/hide the prompt version selector.
Usage in views:
data: {
observ__chat_form_agents_with_prompts_value: agents_with_prompts_map.to_json
}
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/observ/chats_helper.rb', line 32 def agents_with_prompts_map @agents_with_prompts_map ||= begin Observ::AgentProvider.all_agents.each_with_object({}) do |agent_class, hash| # Check if agent includes PromptManagement and has prompt management enabled if agent_class.included_modules.include?(Observ::PromptManagement) && agent_class.respond_to?(:prompt_management_enabled?) && agent_class.prompt_management_enabled? # Extract prompt name from agent's configuration prompt_name = agent_class.prompt_config[:prompt_name] hash[agent_class.name] = prompt_name if prompt_name.present? end end end end |