Class: Luogu::OpenAI::Messages
- Inherits:
-
Object
- Object
- Luogu::OpenAI::Messages
- Defined in:
- lib/luogu/openai.rb
Class Method Summary collapse
Instance Method Summary collapse
- #assistant(text: nil, file: nil) ⇒ Object
-
#initialize ⇒ Messages
constructor
A new instance of Messages.
- #system(text: nil, file: nil) ⇒ Object
- #to_a ⇒ Object
- #user(text: nil, file: nil) ⇒ Object
Constructor Details
#initialize ⇒ Messages
Returns a new instance of Messages.
86 87 88 89 |
# File 'lib/luogu/openai.rb', line 86 def initialize @messages = [] @system = {} end |
Class Method Details
.create ⇒ Object
114 115 116 |
# File 'lib/luogu/openai.rb', line 114 def create self.new end |
Instance Method Details
#assistant(text: nil, file: nil) ⇒ Object
103 104 105 106 107 |
# File 'lib/luogu/openai.rb', line 103 def assistant(text: nil, file: nil) data = text || File.read(file) @messages << {role: "assistant", content: data} self end |
#system(text: nil, file: nil) ⇒ Object
91 92 93 94 95 |
# File 'lib/luogu/openai.rb', line 91 def system(text: nil, file: nil) data = text || File.read(file) @system = {role: "system", content: data} self end |
#to_a ⇒ Object
109 110 111 |
# File 'lib/luogu/openai.rb', line 109 def to_a @messages.unshift @system end |
#user(text: nil, file: nil) ⇒ Object
97 98 99 100 101 |
# File 'lib/luogu/openai.rb', line 97 def user(text: nil, file: nil) data = text || File.read(file) @messages << {role: "user", content: data} self end |