#!/usr/bin/env ruby require 'ollama' include Ollama require 'irb' require 'irb/history' base_url = ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST') client = Client.new(base_url:) 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 client.help IRB.irb nil, client