Last active
June 30, 2025 18:59
-
-
Save nofxx/4f522cd67174161c2aba268369e2624d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddNewFun < RubyLLM::Tool | |
description "Adds a new fun event or place to the system. Requires a link and a location description. Name is optional. Returns a JSON object confirming the addition and echoing the event details." | |
param :link, desc: "Link to the fun event or place (e.g., URL to an event page).", required: true | |
param :name, desc: "Name of the fun event or place. Optional, but recommended.", required: false | |
param :location_description, desc: "Textual description of the location (e.g., '123 Main St, Anytown' or 'Central Park Bandshell').", required: true | |
param :date, desc: "Date of the fun event (DD/MM format, e.g., '25/12'). Optional.", required: false | |
param :type, desc: "Type of the fun event (e.g., 'music', 'theater', 'sports'). Optional.", required: false | |
param :price, desc: "Price of the fun event (e.g., 'R$50', 'Free'). Optional.", required: false | |
def execute(link: nil, name: nil, location_description: nil, date: nil, type: nil, price: nil) | |
return { error: "Link is required." } if link.nil? || link.empty? | |
# Name is optional as per param definition (required: false). | |
return { error: "Location description is required." } if location_description.nil? || location_description.empty? | |
# Simulate adding a new fun event | |
{ | |
status: "Fun event added successfully", | |
link: link, | |
name: name, | |
location: location_description, | |
date: date || Time.now.strftime("%d/%m"), | |
type: type || "general", | |
price: cash || "Free" | |
} | |
rescue => e | |
{ error: e.message } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment