Module: OllamaChat::Tools

Defined in:
lib/ollama_chat/tools.rb

Overview

A module that provides tool registration and management for OllamaChat.

The Tools module serves as a registry for available tools that can be invoked during chat conversations. It maintains a collection of registered tools and provides methods for registering new tools and accessing the complete set of available tools for use in chat interactions.

Defined Under Namespace

Modules: Concern Classes: RunTests

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.registeredHash

The registered attribute reader

Returns:

  • (Hash)

    the registered tools hash containing all available tools



14
15
16
# File 'lib/ollama_chat/tools.rb', line 14

def registered
  @registered
end

Class Method Details

.register(tool) ⇒ OllamaChat::Tools

The register method adds a new tool to the registry.

Parameters:

  • tool (Object)

    the tool to be registered

Returns:



20
21
22
23
24
25
26
27
# File 'lib/ollama_chat/tools.rb', line 20

def register(tool)
  name = tool.register_name.to_s
  name.present? or raise ArgumentError, 'tool needs a name'
  registered.key?(name) and
    raise ArgumentError, 'tool %s already registered' % name
  registered[name] = tool.new
  self
end

.registered?(register_name) ⇒ TrueClass, FalseClass

Checks if a tool with the given name is registered.

Parameters:

  • register_name (String, #to_s)

    the name of the tool to check

Returns:

  • (TrueClass, FalseClass)

    true if the tool is registered, false otherwise



35
36
37
# File 'lib/ollama_chat/tools.rb', line 35

def registered?(register_name)
  registered.key?(register_name.to_s)
end