Class: Copilot2GPT::ChatRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/copilot2gpt/chat_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ChatRequest

Returns a new instance of ChatRequest.



5
6
7
8
9
10
11
12
13
14
# File 'lib/copilot2gpt/chat_request.rb', line 5

def initialize(args)
  @messages = args[:messages]
  @model = args[:model]
  @temperature = args[:temperature]
  @top_p = args[:top_p]
  @n = args[:n]
  @stream = args[:stream]
  @intent = args[:intent]
  @one_time_return = args[:one_time_return]
end

Instance Attribute Details

#intentObject

Returns the value of attribute intent.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def intent
  @intent
end

#messagesObject

Returns the value of attribute messages.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def messages
  @messages
end

#modelObject

Returns the value of attribute model.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def model
  @model
end

#nObject

Returns the value of attribute n.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def n
  @n
end

#one_time_returnObject

Returns the value of attribute one_time_return.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def one_time_return
  @one_time_return
end

#streamObject

Returns the value of attribute stream.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def stream
  @stream
end

#temperatureObject

Returns the value of attribute temperature.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def temperature
  @temperature
end

#top_pObject

Returns the value of attribute top_p.



3
4
5
# File 'lib/copilot2gpt/chat_request.rb', line 3

def top_p
  @top_p
end

Class Method Details

.with_default(content, params) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/copilot2gpt/chat_request.rb', line 30

def with_default(content, params)
  default = {
    messages: [
      {"role" => "system", "content" => "\nYou are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2021-09\nCurrent model: gpt-4\nCurrent time: 2023/11/7 11: 39: 14\n"},
      {"role" => "user", "content" => content}
    ],
    model: "gpt-4", temperature: 0.5,
    top_p: 1, n: 1,
    stream: true, intent: true,
    one_time_return: false
  }.merge(params)
  new(default)
end

Instance Method Details

#to_jsonObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/copilot2gpt/chat_request.rb', line 16

def to_json
  {
    messages: @messages,
    model: @model,
    temperature: @temperature,
    top_p: @top_p,
    n: @n,
    stream: @stream,
    intent: @intent,
    one_time_return: @one_time_return
  }.to_json
end