Class: OpenAI::Assistant::Replyer

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/assistant/replyer.rb

Instance Method Summary collapse

Constructor Details

#initialize(model: "gpt-3.5-turbo", incoming_mail: "", reply_summary: "", situation: 'formal', other_request: "") ⇒ Replyer

Returns a new instance of Replyer.



4
5
6
7
8
# File 'lib/openai/assistant/replyer.rb', line 4

def initialize(model: "gpt-3.5-turbo", incoming_mail: "", reply_summary: "", situation: 'formal', other_request: "")
  return if incoming_mail.empty? || reply_summary.empty?

  @prompt_data = prompt_data(model:model, incoming_mail: incoming_mail, reply_summary: reply_summary, situation: situation, other_request: other_request)
end

Instance Method Details

#get_prompt_data(model:, incoming_mail:, reply_summary:, situation:, other_request:) ⇒ Object



20
21
22
# File 'lib/openai/assistant/replyer.rb', line 20

def get_prompt_data(model:, incoming_mail:, reply_summary:, situation:, other_request:)
  @prompt_data
end

#parametersObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/openai/assistant/replyer.rb', line 31

def parameters
  {
    model: @prompt_data[:model],
    messages: [
      { role: "system", content: system_prompt },
      # { role: "user", content: user_prompt }
    ],
    temperature: 0.7,
  }
end

#prompt_data(model:, incoming_mail:, reply_summary:, situation:, other_request:) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/openai/assistant/replyer.rb', line 10

def prompt_data(model:, incoming_mail:, reply_summary:, situation:, other_request:)
  {
    model: model,
    incoming_mail: incoming_mail,
    reply_summary: reply_summary,
    situation: situation,
    other_request: other_request
  }
end

#set_prompt_data(model:, incoming_mail:, reply_summary:, situation:, other_request:) ⇒ Object



24
25
26
27
28
29
# File 'lib/openai/assistant/replyer.rb', line 24

def set_prompt_data(model:, incoming_mail:, reply_summary:, situation:, other_request:)
  @prompt_data[:incoming_mail] = incoming_mail if !incoming_mail.empty?
  @prompt_data[:reply_summary] = reply_summary if !reply_summary.empty?
  @prompt_data[:situation] = situation if !situation.empty?
  @prompt_data[:other_request] = other_request if !other_request.empty?
end