Class: Foobara::Ai::AnswerBot::DomainMappers::OllamaApi::ChatToGenerateChatCompletion

Inherits:
DomainMapper
  • Object
show all
Defined in:
foobara-ai-1.0.6/src/foobara/ai/answer_bot/domain_mappers/ollama_api/chat_to_generate_chat_completion.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Method Summary collapse

Methods inherited from DomainMapper

applicable?, applicable_score, #execute, foobara_on_register, from, #from, from_type, install!, map, map!, matches?, to, to_type

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

#chat ⇒ Object



37
38
39
# File 'src/foobara/ai/answer_bot/domain_mappers/ollama_api/chat_to_generate_chat_completion.rb', line 37

def chat
  from[:chat]
end

#map ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'src/foobara/ai/answer_bot/domain_mappers/ollama_api/chat_to_generate_chat_completion.rb', line 17

def map
  inputs = {
    messages: chat.messages.map do |message|
      { role: message.role, content: message.content }
    end
  }

  if temperature
    inputs[:options] = {
      temperature:
    }
  end

  if model
    inputs[:model] = model
  end

  inputs
end

#model ⇒ Object



45
46
47
# File 'src/foobara/ai/answer_bot/domain_mappers/ollama_api/chat_to_generate_chat_completion.rb', line 45

def model
  from[:model]
end

#temperature ⇒ Object



41
42
43
# File 'src/foobara/ai/answer_bot/domain_mappers/ollama_api/chat_to_generate_chat_completion.rb', line 41

def temperature
  from[:temperature]
end