Class: Ollama::Commands::Chat
- Inherits:
-
Object
- Object
- Ollama::Commands::Chat
- Includes:
- DTO
- Defined in:
- lib/ollama/commands/chat.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
writeonly
Sets the attribute client.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#keep_alive ⇒ Object
readonly
Returns the value of attribute keep_alive.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model:, messages:, tools: nil, format: nil, options: nil, stream: nil, keep_alive: nil) ⇒ Chat
constructor
A new instance of Chat.
- #perform(handler) ⇒ Object
Methods included from DTO
#as_array_of_hashes, #as_json, #empty?, #to_json
Constructor Details
#initialize(model:, messages:, tools: nil, format: nil, options: nil, stream: nil, keep_alive: nil) ⇒ Chat
Returns a new instance of Chat.
8 9 10 11 12 |
# File 'lib/ollama/commands/chat.rb', line 8 def initialize(model:, messages:, tools: nil, format: nil, options: nil, stream: nil, keep_alive: nil) @model, @messages, @tools, @format, @options, @stream, @keep_alive = model, as_array_of_hashes(), as_array_of_hashes(tools), format, , stream, keep_alive end |
Instance Attribute Details
#client=(value) ⇒ Object (writeonly)
Sets the attribute client
16 17 18 |
# File 'lib/ollama/commands/chat.rb', line 16 def client=(value) @client = value end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def format @format end |
#keep_alive ⇒ Object (readonly)
Returns the value of attribute keep_alive.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def keep_alive @keep_alive end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def @messages end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def @options end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def stream @stream end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
14 15 16 |
# File 'lib/ollama/commands/chat.rb', line 14 def tools @tools end |
Class Method Details
.path ⇒ Object
4 5 6 |
# File 'lib/ollama/commands/chat.rb', line 4 def self.path '/api/chat' end |
Instance Method Details
#perform(handler) ⇒ Object
18 19 20 |
# File 'lib/ollama/commands/chat.rb', line 18 def perform(handler) @client.request(method: :post, path: self.class.path, body: to_json, stream:, handler:) end |