Module: OllamaChat::Feedback
- Included in:
- Chat, Database::Models::AppState, FollowChat, StateSelectors::Common, ToolCallProcessor, Tools::Concern, Vim
- Defined in:
- lib/ollama_chat/feedback.rb
Overview
Provides typed user-facing output to STDOUT.
Constant Summary collapse
- PREFIXES =
Glyph prefixes keyed by message type.
Unknown types trigger a
warnvia the default proc but still emit the message without a prefix. Hash.new { warn "type %s not defined!" % _2.inspect unless _2.nil? }.merge( success: "\u2705", # ✅ cancel: "\u274C", # ❌ denied: "\u{1F6AB}", # 🚫 warn: "\u26A0", # ⚠️ info: "\u2139", # ℹ️ alarm: "\u{1F514}" # 🔔 )
Instance Method Summary collapse
-
#feedback(msg, type: nil, output: STDOUT, newline: true, timeout: nil) ⇒ nil
Write a user-facing message to STDOUT with an optional glyph prefix.
Instance Method Details
#feedback(msg, type: nil, output: STDOUT, newline: true, timeout: nil) ⇒ nil
Write a user-facing message to STDOUT with an optional glyph prefix.
36 37 38 39 40 41 42 43 |
# File 'lib/ollama_chat/feedback.rb', line 36 def feedback(msg, type: nil, output: STDOUT, newline: true, timeout: nil) prefix = PREFIXES[type&.to_sym]&.+(' ') newline and msg = msg.sub(/(?<!\n)\z/, ?\n) output.print(prefix.to_s + msg) timeout.nil? and return chat.confirm?(prompt: '⏎ Press any key to continue (%s). ', timeout:) nil end |