Class: Foobara::Ai::OllamaApi::BaseCommand

Inherits:
Command
  • Object
show all
Includes:
HttpApiCommand
Defined in:
foobara-ollama-api-1.0.3/src/foobara/ai/ollama_api/base_command.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Method Summary collapse

Methods inherited from Command

install!

Methods included from TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Method Details

#api_tokenObject



17
18
19
20
21
22
23
# File 'src/foobara/ai/ollama_api/base_command.rb', line 17

def api_token
  key = ENV["OLLAMA_API_KEY"]

  if key
    key.empty? ? nil : key
  end
end

#build_request_headersObject



9
10
11
12
13
14
15
# File 'src/foobara/ai/ollama_api/base_command.rb', line 9

def build_request_headers
  self.request_headers = if api_token
                           super.merge("x-api-Key" => api_token)
                         else
                           super
                         end
end