Module: OllamaChat::Information

Extended by:
Tins::Concern
Included in:
Chat
Defined in:
lib/ollama_chat/information.rb

Defined Under Namespace

Modules: UserAgent

Instance Method Summary collapse

Instance Method Details

#collection_statsObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/ollama_chat/information.rb', line 19

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_helpObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ollama_chat/information.rb', line 59

def display_chat_help
  STDOUT.puts "    /copy                           to copy last response to clipboard\n    /paste                          to paste content\n    /markdown                       toggle markdown output\n    /stream                         toggle stream output\n    /location                       toggle location submission\n    /voice( change)                 toggle voice output or change the voice\n    /list [n]                       list the last n / all conversation exchanges\n    /clear                          clear the whole conversation\n    /clobber                        clear the conversation, links, and collection\n    /drop [n]                       drop the last n exchanges, defaults to 1\n    /model                          change the model\n    /system                         change system prompt (clears conversation)\n    /regenerate                     the last answer message\n    /collection( clear|change)      change (default) collection or clear\n    /info                           show information for current session\n    /config                         output current configuration (\#{@ollama_chat_config.filename.to_s.inspect})\n    /document_policy                pick a scan policy for document references\n    /import source                  import the source's content\n    /summarize [n] source           summarize the source's content in n words\n    /embedding                      toggle embedding paused or not\n    /embed source                   embed the source's content\n    /web [n] query                  query web search & return n or 1 results\n    /links( clear)                  display (or clear) links used in the chat\n    /save filename                  store conversation messages\n    /load filename                  load conversation messages\n    /quit                           to quit\n    /help                           to view this help\n  EOT\n  nil\nend\n"

#infoObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ollama_chat/information.rb', line 30

def info
  STDOUT.puts "Running ollama_chat version: #{bold(OllamaChat::VERSION)}"
  STDOUT.puts "Connected to ollama server version: #{bold(server_version)}"
  STDOUT.puts "Current model is #{bold{@model}}."
  if @model_options.present?
    STDOUT.puts "  Options: #{JSON.pretty_generate(@model_options).gsub(/(?<!\A)^/, '  ')}"
  end
  @embedding.show
  if @embedding.on?
    STDOUT.puts "Embedding model is #{bold{@embedding_model}}"
    if @embedding_model_options.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
  STDOUT.puts "Documents database cache is #{@documents.nil? ? 'n/a' : bold{@documents.cache.class}}"
  markdown.show
  stream.show
  location.show
  STDOUT.puts "Document policy for references in user text: #{bold{@document_policy}}"
  STDOUT.puts "Currently selected search engine is #{bold(search_engine)}."
  if @voice.on?
    STDOUT.puts "Using voice #{bold{@current_voice}} to speak."
  end
  @messages.show_system_prompt
  nil
end

#server_versionObject



117
118
119
# File 'lib/ollama_chat/information.rb', line 117

def server_version
  @server_version ||= ollama.version.version
end

#usageObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ollama_chat/information.rb', line 92

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\n      -s SYSTEM      the system prompt to use as a file, OLLAMA_CHAT_SYSTEM\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      -V             display the current version number and quit\n      -h             this help\n\n  EOT\n  0\nend\n"

#versionObject



112
113
114
115
# File 'lib/ollama_chat/information.rb', line 112

def version
  STDOUT.puts "%s %s" % [ progname, OllamaChat::VERSION ]
  0
end