module HuggingfaceReport
IRC reply cards for Hugging Face plugin commands.
Constants
- RECOMMEND_SECTION_LABELS
- STYLE_BANNER
Public Instance Methods
Source
# File lib/huggingface_report.rb, line 116 def format_hardware_reply(hardware, synced: false) title = synced ? "hardware synced" : "hardware profile" lines = [ IrcFormat.report_header(tag: "HF", title: title, style: STYLE_BANNER), hardware_summary_line(hardware), IrcFormat.report_footer("huggingface.co/settings/hardware") ] lines.compact.join("\n") end
Source
# File lib/huggingface_report.rb, line 134 def format_help_reply(usage_message:) [ IrcFormat.report_header(tag: "HF", title: "commands", style: STYLE_BANNER), usage_message, IrcFormat.report_footer("voice +v or op required for search", "huggingface.co") ].join("\n") end
Source
# File lib/huggingface_report.rb, line 79 def format_login_reply(username:, hardware:) lines = [ IrcFormat.report_header(tag: "HF", title: "account linked", style: STYLE_BANNER), "Logged in as #{username}.", hardware_summary_line(hardware), IrcFormat.report_footer("token stored per nick", "huggingface.co/settings/hardware") ] lines.compact.join("\n") end
Source
# File lib/huggingface_report.rb, line 126 def format_logout_reply [ IrcFormat.report_header(tag: "HF", title: "logged out", style: STYLE_BANNER), "Hugging Face token removed for your nick.", IrcFormat.report_footer("huggingface.co") ].join("\n") end
Source
# File lib/huggingface_report.rb, line 53 def format_recommend_reply(sections, hardware:) lines = [ IrcFormat.report_header(tag: "HF", title: "model recommendations", style: STYLE_BANNER) ] hardware_label_text = HuggingfaceHardware.hardware_label(hardware) lines << "Hardware fit โ #{hardware_label_text}" if hardware_label_text total = 0 HuggingfaceModels::RECOMMEND_SECTIONS.each_key do |key| models = sections[key] || [] total += models.length lines << RECOMMEND_SECTION_LABELS[key] if models.empty? lines << "No models matched your hardware profile." else models.each_with_index do |model, index| lines << HuggingfaceModels.format_model_line(model, index: index + 1) end end end lines << IrcFormat.report_footer("huggingface.co", "#{total} models") lines.join("\n") end
Source
# File lib/huggingface_report.rb, line 28 def format_search_reply(models, query:, moderation:, hardware: nil) title = search_title(query: query, moderation: moderation) lines = [IrcFormat.report_header(tag: "HF", title: title, style: STYLE_BANNER)] hardware_label_text = HuggingfaceHardware.hardware_label(hardware) if hardware_label_text lines << "Hardware fit โ #{hardware_label_text}" elsif hardware lines << "Hardware fit โ log in with /msg <bot> !hf login <token> and set hardware at huggingface.co/settings/hardware" end if models.empty? lines << "No models matched that query." else models.each_with_index do |model, index| lines << HuggingfaceModels.format_model_line(model, index: index + 1) end end footer_bits = ["huggingface.co"] footer_bits << "#{models.length} models" lines << IrcFormat.report_footer(*footer_bits) lines.join("\n") end
Source
# File lib/huggingface_report.rb, line 89 def format_whoami_reply(account, mask_token:) unless account return [ IrcFormat.report_header(tag: "HF", title: "not linked", style: STYLE_BANNER), "Use /msg <bot> !hf login <token> to link your Hugging Face account.", IrcFormat.report_footer("huggingface.co/settings/tokens") ].join("\n") end lines = [ IrcFormat.report_header(tag: "HF", title: "account", style: STYLE_BANNER), "Linked as #{account['username']} (#{mask_token.call(account['token'])}).", hardware_summary_line(account["hardware"]), IrcFormat.report_footer("huggingface.co") ] lines.compact.join("\n") end
Source
# File lib/huggingface_report.rb, line 107 def hardware_summary_line(hardware) label = HuggingfaceHardware.hardware_label(hardware) return "No hardware profile saved yet โ add GPUs at huggingface.co/settings/hardware then !hf hardware sync." unless label count = hardware[:device_count] || hardware["device_count"] suffix = count.to_i > 1 ? " ยท #{count} devices" : "" "Primary hardware โ #{label}#{suffix}" end
Source
# File lib/huggingface_report.rb, line 18 def search_title(query:, moderation:) label = case moderation when :censored then "censored models" when :uncensored then "uncensored models" else "model search" end "#{label} โ #{query}" end