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

Inherits:
Command
  • Object
show all
Includes:
HttpApiCommand
Defined in:
foobara-ollama-api-1.0.4/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 CommandPatternImplementation

install_state_machine_callback_methods

Methods included from TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Method Details

#api_token ⇒ Object



21
22
23
24
25
26
27
# File 'src/foobara/ai/ollama_api/base_command.rb', line 21

def api_token
  key = ENV["OLLAMA_API_KEY"]

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

#build_request_headers ⇒ Object



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

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