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 <<~EOT
    Current Collection
      Name: #{bold{@documents.collection}}
      #Embeddings: #{@documents.size}
      #Tags: #{@documents.tags.size}
      Tags: #{@documents.tags}
  EOT
  nil
end

#display_chat_helpObject



56
57
58
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
# File 'lib/ollama_chat/information.rb', line 56

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

#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
# File 'lib/ollama_chat/information.rb', line 30

def info
  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}}"
  if @voice.on?
    STDOUT.puts "Using voice #{bold{@current_voice}} to speak."
  end
  @messages.show_system_prompt
  nil
end

#usageObject



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

def usage
  STDOUT.puts <<~EOT
    Usage: #{progname} [OPTIONS]

      -f CONFIG      config file to read
      -u URL         the ollama base url, OLLAMA_URL
      -m MODEL       the ollama model to chat with, OLLAMA_CHAT_MODEL
      -s SYSTEM      the system prompt to use as a file, OLLAMA_CHAT_SYSTEM
      -c CHAT        a saved chat conversation to load
      -C COLLECTION  name of the collection used in this conversation
      -D DOCUMENT    load document and add to embeddings collection (multiple)
      -M             use (empty) MemoryCache for this chat session
      -E             disable embeddings for this chat session
      -V             display the current version number and quit
      -h             this help

  EOT
  0
end

#versionObject



109
110
111
112
# File 'lib/ollama_chat/information.rb', line 109

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