Class: Foobara::Ai::AnswerBot::DomainMappers::AnthropicApi::ChatToCreateMessage
- Inherits:
-
DomainMapper
- Object
- DomainMapper
- Foobara::Ai::AnswerBot::DomainMappers::AnthropicApi::ChatToCreateMessage
show all
- Defined in:
- foobara-ai-1.0.4/src/foobara/ai/answer_bot/domain_mappers/anthropic_api/chat_to_create_message.rb
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Method Summary
collapse
applicable?, applicable_score, #execute, foobara_on_register, from, #from, from_type, install!, map, map!, matches?, to, to_type
#inspect, truncating
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Instance Method Details
#chat ⇒ Object
40
41
42
|
# File 'src/foobara/ai/answer_bot/domain_mappers/anthropic_api/chat_to_create_message.rb', line 40
def chat
from[:chat]
end
|
#map ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'src/foobara/ai/answer_bot/domain_mappers/anthropic_api/chat_to_create_message.rb', line 16
def map
system_messages, non_system_messages = chat.messages.partition(&:system?)
inputs = {
messages: non_system_messages.map do |message|
{ role: message.role, content: message.content }
end
}
unless system_messages.empty?
inputs[:system] = system_messages.map(&:content).join("\n")
end
if temperature
inputs[:temperature] = temperature
end
if model
inputs[:model] = model
end
inputs
end
|
#model ⇒ Object
48
49
50
|
# File 'src/foobara/ai/answer_bot/domain_mappers/anthropic_api/chat_to_create_message.rb', line 48
def model
from[:model]
end
|
#temperature ⇒ Object
44
45
46
|
# File 'src/foobara/ai/answer_bot/domain_mappers/anthropic_api/chat_to_create_message.rb', line 44
def temperature
from[:temperature]
end
|