Module: OllamaChat::Information
Overview
A module that provides information and user agent functionality for OllamaChat
The Information module encapsulates methods for managing application identification, displaying version and configuration details, and handling command-line interface help messages. It includes user agent capabilities for HTTP requests and provides comprehensive information display features for chat sessions.
Defined Under Namespace
Modules: UserAgent
Instance Method Summary collapse
-
#collection_stats ⇒ nil
The collection_stats method displays statistics about the current document collection.
-
#display_chat_help ⇒ nil
The display_chat_help method outputs the chat help message to standard output.
-
#info ⇒ nil
The info method displays comprehensive information about the current state of the ollama_chat instance.
-
#server_url ⇒ String
The server_url method returns the base URL of the Ollama server connection.
-
#server_version ⇒ String
The server_version method retrieves the version of the Ollama server.
-
#usage ⇒ Integer
The usage method displays the command-line interface help text and returns an exit code of 0.
-
#version ⇒ Integer
The version method outputs the program name and its version number to standard output.
Instance Method Details
#collection_stats ⇒ nil
The collection_stats method displays statistics about the current document collection.
This method outputs information regarding the active document collection, including the collection name, total number of embeddings, and a list of tags.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ollama_chat/information.rb', line 66 def collection_stats STDOUT.puts " Current Collection\n Name: \#{bold{@documents.collection}}\n #Embeddings: \#{@documents.size}\n #Tags: \#{@documents.tags.size}\n Tags: \#{@documents.tags}\n EOT\n nil\nend\n" |
#display_chat_help ⇒ nil
The display_chat_help method outputs the chat help message to standard output.
161 162 163 164 |
# File 'lib/ollama_chat/information.rb', line 161 def display_chat_help STDOUT.puts nil end |
#info ⇒ nil
The info method displays comprehensive information about the current state of the ollama_chat instance. This includes version details, server connection status, model configurations, embedding settings, and various operational switches.
directly to standard output.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/ollama_chat/information.rb', line 84 def info STDOUT.puts "Running ollama_chat version: #{bold(OllamaChat::VERSION)}" STDOUT.puts "Connected to ollama server version: #{bold(server_version)} on: #{bold(server_url)}" STDOUT.puts "Current conversation model is #{bold{@model}}." if .present? STDOUT.puts " Options: #{JSON.pretty_generate(@model_options).gsub(/(?<!\A)^/, ' ')}" end .show if .on? STDOUT.puts "Current embedding model is #{bold{@embedding_model}}" if .present? STDOUT.puts " Options: #{JSON.pretty_generate(@embedding_model_options).gsub(/(?<!\A)^/, ' ')}" end STDOUT.puts "Text splitter is #{bold{config.embedding.splitter.name}}." collection_stats end markdown.show stream.show think_show think_loud.show location.show voice.show if @voice.on? STDOUT.puts " Using voice #{bold{@current_voice}} to speak." end STDOUT.puts "Documents database cache is #{@documents.nil? ? 'n/a' : bold{@documents.cache.class}}" STDOUT.puts "Document policy for references in user text: #{bold{@document_policy}}" STDOUT.puts "Currently selected search engine is #{bold(search_engine)}." STDOUT.puts "Conversation length: #{bold(@messages.size.to_s)} message(s)." nil end |
#server_url ⇒ String
The server_url method returns the base URL of the Ollama server connection.
212 213 214 |
# File 'lib/ollama_chat/information.rb', line 212 def server_url @server_url ||= ollama.base_url end |
#server_version ⇒ String
The server_version method retrieves the version of the Ollama server.
205 206 207 |
# File 'lib/ollama_chat/information.rb', line 205 def server_version @server_version ||= ollama.version.version end |
#usage ⇒ Integer
The usage method displays the command-line interface help text and returns an exit code of 0.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ollama_chat/information.rb', line 170 def usage STDOUT.puts " Usage: \#{progname} [OPTIONS]\n\n -f CONFIG config file to read\n -u URL the ollama base url, OLLAMA_URL\n -m MODEL the ollama model to chat with, OLLAMA_CHAT_MODEL, ?selector\n -s SYSTEM the system prompt to use as a file, OLLAMA_CHAT_SYSTEM, ?selector\n -c CHAT a saved chat conversation to load\n -C COLLECTION name of the collection used in this conversation\n -D DOCUMENT load document and add to embeddings collection (multiple)\n -M use (empty) MemoryCache for this chat session\n -E disable embeddings for this chat session\n -S open a socket to receive input from ollama_chat_send\n -V display the current version number and quit\n -h this help\n\n Use `?selector` with `-m` or `-s` to filter options. Multiple matches\n will open a chooser dialog.\n EOT\n 0\nend\n" |
#version ⇒ Integer
The version method outputs the program name and its version number to standard output.
197 198 199 200 |
# File 'lib/ollama_chat/information.rb', line 197 def version STDOUT.puts "%s %s" % [ progname, OllamaChat::VERSION ] 0 end |