Class: OmniAI::OpenAI::Thread::Messages
- Inherits:
-
Object
- Object
- OmniAI::OpenAI::Thread::Messages
- Defined in:
- lib/omniai/openai/thread/messages.rb
Overview
An OpenAI scope for establishing messages.
Instance Method Summary collapse
- #all(limit: nil) ⇒ Array<OmniAI::Thread::Message>
- #build(role: nil, content: nil, attachments: [], metadata: {}) ⇒ OmniAI::OpenAI::Thread::Message
- #destroy!(id:) ⇒ Hash
- #find(id:) ⇒ OmniAI::OpenAI::Thread::Message
-
#initialize(client:, thread:) ⇒ Messages
constructor
A new instance of Messages.
Constructor Details
#initialize(client:, thread:) ⇒ Messages
Returns a new instance of Messages.
10 11 12 13 |
# File 'lib/omniai/openai/thread/messages.rb', line 10 def initialize(client:, thread:) @client = client @thread = thread end |
Instance Method Details
#all(limit: nil) ⇒ Array<OmniAI::Thread::Message>
17 18 19 |
# File 'lib/omniai/openai/thread/messages.rb', line 17 def all(limit: nil) Message.all(thread_id: @thread.id, limit:, client: @client) end |
#build(role: nil, content: nil, attachments: [], metadata: {}) ⇒ OmniAI::OpenAI::Thread::Message
38 39 40 |
# File 'lib/omniai/openai/thread/messages.rb', line 38 def build(role: nil, content: nil, attachments: [], metadata: {}) Message.new(role:, content:, attachments:, metadata:, thread_id: @thread.id, client: @client) end |
#destroy!(id:) ⇒ Hash
29 30 31 |
# File 'lib/omniai/openai/thread/messages.rb', line 29 def destroy!(id:) Message.destroy!(id:, thread_id: @thread.id, client: @client) end |
#find(id:) ⇒ OmniAI::OpenAI::Thread::Message
23 24 25 |
# File 'lib/omniai/openai/thread/messages.rb', line 23 def find(id:) Message.find(id:, thread_id: @thread.id, client: @client) end |