#!/usr/bin/env ruby require 'ollama' include Ollama require 'irb' require 'irb/history' def base_url ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST') end def ollama $ollama ||= Client.new(base_url:) end IRB.setup nil IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context IRB.conf[:HISTORY_FILE] = File.join(ENV.fetch('HOME'), '.ollama_console-history') IRB.conf[:SAVE_HISTORY] = 1000 require 'irb/ext/multi-irb' if io = IRB.conf[:MAIN_CONTEXT].io and io.support_history_saving? io.load_history at_exit { io.save_history } end ollama.help IRB.irb nil, ollama