Skip to content

Commit b2bb2cc

Browse files
committed
feat: add method documentation to all tools using ToolMetadata
1 parent 8772f37 commit b2bb2cc

5 files changed

+26
-0
lines changed

lib/tools/calculate_tool.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
require_relative "tool"
2+
require_relative "tool_metadata"
23

34
class CalculateTool < Tool
5+
extend ToolMetadata
6+
7+
describe :call, "Evaluates mathematical expressions with support for basic operators (+, -, *, /, %, **) and parentheses."
8+
49
def initialize
510
super("calculate")
611
end

lib/tools/google_search_tool.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
require "http"
22
require "json"
33
require_relative "tool"
4+
require_relative "tool_metadata"
45

56
class GoogleSearchTool < Tool
7+
extend ToolMetadata
8+
9+
describe :call, "Performs a Google search using Custom Search API and returns detailed results including titles, URLs, descriptions, and metadata for up to 10 results."
10+
611
def initialize
712
super("google_search")
813
@api_key = ENV["GOOGLE_SEARCH_API_KEY"]

lib/tools/tool.rb

+6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
# # Return a string result
1818
# end
1919
# end
20+
require_relative "tool_metadata"
21+
2022
class Tool
23+
extend ToolMetadata
24+
25+
describe :call, "Base method that all tools must implement to process input and return a result. This method should be overridden by subclasses."
26+
2127
# The name of the tool, used to identify it in prompts and commands
2228
attr_reader :name
2329

lib/tools/tool_registry.rb

+5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414
require "singleton"
1515
require "pathname"
1616
require_relative "tool"
17+
require_relative "tool_metadata"
1718

1819
class ToolRegistry
1920
include Singleton
21+
extend ToolMetadata
22+
23+
describe :fetch, "Retrieves a tool instance by its name, raising an error if the tool doesn't exist."
24+
describe :tools, "Returns a hash of all registered tools, mapping tool names to their instances."
2025

2126
# Initialize the registry and load all available tools
2227
def initialize

lib/tools/wikipedia_tool.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
require "http"
22
require "json"
33
require_relative "tool"
4+
require_relative "tool_metadata"
45

56
class WikipediaTool < Tool
7+
extend ToolMetadata
8+
9+
describe :call, "Searches Wikipedia for the given query and returns the snippet of the most relevant article match."
10+
611
def initialize
712
super("wikipedia")
813
end

0 commit comments

Comments
 (0)