Module: OllamaChat::Tools::Concern
Overview
A module that provides common functionality for OllamaChat tools.
This module serves as a base class for all tool implementations in the OllamaChat application, providing shared behavior and methods that tools can inherit from. It includes delegation to the tool name and registration functionality to integrate tools into the chat system’s tool registry.
Instance Method Summary collapse
-
#name ⇒ String
The name method returns the registered name of the tool.
-
#to_hash ⇒ Hash
The to_hash method converts the tool to a hash representation.
-
#valid_json? ⇒ Proc
The valid_json? method returns a proc that validates JSON data from a temporary file.
Instance Method Details
#name ⇒ String
The name method returns the registered name of the tool.
35 36 37 |
# File 'lib/ollama_chat/tools/concern.rb', line 35 def name self.class.register_name end |
#to_hash ⇒ Hash
The to_hash method converts the tool to a hash representation.
58 59 60 |
# File 'lib/ollama_chat/tools/concern.rb', line 58 def to_hash tool.to_hash end |
#valid_json? ⇒ Proc
The valid_json? method returns a proc that validates JSON data from a temporary file.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ollama_chat/tools/concern.rb', line 44 def valid_json? -> tmp { if data = tmp.read.full? JSON.parse(data) return data else raise JSON::ParserError, 'require JSON data' end } end |