Module: OllamaChat::History
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/history.rb
Instance Method Summary collapse
- #chat_history_filename ⇒ Object
- #clear_history ⇒ Object
- #init_chat_history ⇒ Object
- #save_history ⇒ Object
Instance Method Details
#chat_history_filename ⇒ Object
2 3 4 |
# File 'lib/ollama_chat/history.rb', line 2 def chat_history_filename File.(config.chat_history_filename) end |
#clear_history ⇒ Object
20 21 22 |
# File 'lib/ollama_chat/history.rb', line 20 def clear_history Readline::HISTORY.clear end |
#init_chat_history ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/ollama_chat/history.rb', line 6 def init_chat_history if File.exist?(chat_history_filename) File.open(chat_history_filename, ?r) do |history| history_data = JSON.load(history) clear_history Readline::HISTORY.push(*history_data) end end end |
#save_history ⇒ Object
16 17 18 |
# File 'lib/ollama_chat/history.rb', line 16 def save_history File.secure_write(chat_history_filename, JSON.dump(Readline::HISTORY)) end |