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

Inherits:
DomainMapper
  • Object
show all
Defined in:
foobara-ai-1.0.4/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 TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Method Details

#chatObject



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

def chat
  from[:chat]
end

#mapObject



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

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

#modelObject



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

def model
  from[:model]
end

#temperatureObject



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

def temperature
  from[:temperature]
end