Class: Rllama::Cli
- Inherits:
-
Object
- Object
- Rllama::Cli
- Defined in:
- lib/rllama/cli.rb
Constant Summary collapse
- POPULAR_MODELS =
[ { path: 'lmstudio-community/gemma-3-1B-it-QAT-GGUF/gemma-3-1B-it-QAT-Q4_0.gguf', size: 720_425_472 }, { path: 'lmstudio-community/gpt-oss-20b-GGUF/gpt-oss-20b-MXFP4.gguf', size: 12_109_565_632 }, { path: 'bartowski/Llama-3.2-3B-Instruct-GGUF/Llama-3.2-3B-Instruct-Q4_K_M.gguf', size: 2_019_377_696 }, { path: 'unsloth/Qwen3-30B-A3B-GGUF/Qwen3-30B-A3B-Q3_K_S.gguf', size: 13_292_468_800 }, { path: 'inclusionAI/Ling-mini-2.0-GGUF/Ling-mini-2.0-Q4_K_M.gguf', size: 9_911_575_072 }, { path: 'unsloth/gemma-3n-E4B-it-GGUF/gemma-3n-E4B-it-Q4_K_S.gguf', size: 4_404_697_216 }, { path: 'microsoft/phi-4-gguf/phi-4-Q4_K_S.gguf', size: 8_440_762_560 } ].freeze
- COLOR_CODES =
{ red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Cli
Returns a new instance of Cli.
30 31 32 33 34 |
# File 'lib/rllama/cli.rb', line 30 def initialize(args) @args = args @model_path = args.first end |
Class Method Details
.start(args) ⇒ Object
26 27 28 |
# File 'lib/rllama/cli.rb', line 26 def self.start(args) new(args).run end |
Instance Method Details
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rllama/cli.rb', line 36 def run model_path = select_or_load_model puts "\n#{colorize('Loading model...', :yellow)}" model = Rllama.load_model(model_path) context = model.init_context puts colorize('Model loaded successfully!', :green) puts "\n#{colorize('Chat started. Type your message and press Enter. Type "exit" or "quit" to end the chat.', :cyan)}\n\n" chat_loop(context) rescue Interrupt puts "\n\n#{colorize('Chat interrupted. Goodbye!', :yellow)}" exit(0) rescue StandardError => e puts "\n#{colorize("Error: #{e.message}", :red)}" exit(1) ensure context&.close model&.close end |