Class: Foobara::Ai::AnswerBot::DomainMappers::OpenAiApi::QuestionToCreateChatCompletion

Inherits:
DomainMapper
  • Object
show all
Defined in:
foobara-ai-1.0.4/src/foobara/ai/answer_bot/domain_mappers/open_ai_api/question_to_create_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

#instructionsObject



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

def instructions
  from[:instructions]
end

#mapObject



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/open_ai_api/question_to_create_chat_completion.rb', line 17

def map
  {
    messages: [
      {
        role: "system",
        content: instructions
      },
      {
        role: "user",
        content: question
      }
    ]
  }.tap do |inputs|
    if model
      inputs[:model] = model
    end
  end
end

#modelObject



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

def model
  from[:model]
end

#questionObject



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

def question
  from[:question]
end