Class: Async::Ollama::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/async/ollama/toolbox.rb

Overview

Represents a tool that can be registered and called by the Toolbox.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, schema, &block) ⇒ Tool

Initializes a new tool with the given name, schema, and block.



14
15
16
17
18
# File 'lib/async/ollama/toolbox.rb', line 14

def initialize(name, schema, &block)
	@name = name
	@schema = schema
	@block = block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/async/ollama/toolbox.rb', line 21

def name
  @name
end

#schemaObject (readonly)

Returns the value of attribute schema.



24
25
26
# File 'lib/async/ollama/toolbox.rb', line 24

def schema
  @schema
end

#The name of the tool.(nameofthetool.) ⇒ Object (readonly)



21
# File 'lib/async/ollama/toolbox.rb', line 21

attr :name

Instance Method Details

#call(message) ⇒ Object

Calls the tool with the given message.



29
30
31
# File 'lib/async/ollama/toolbox.rb', line 29

def call(message)
	@block.call(message)
end

#explainObject



34
35
36
37
38
39
# File 'lib/async/ollama/toolbox.rb', line 34

def explain
	{
		type: "function",
		function: @schema,
	}
end

#The schema for the tool.=(schema) ⇒ Object



24
# File 'lib/async/ollama/toolbox.rb', line 24

attr :schema