Class: VectorMCP::Definitions::Prompt
- Inherits:
-
Struct
- Object
- Struct
- VectorMCP::Definitions::Prompt
- Defined in:
- lib/vector_mcp/definitions.rb
Overview
Represents a prompt or templated message workflow for users or AI models.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Array<Hash> An array of argument definitions for the prompt, where each hash can contain ‘:name`, `:description`, and `:required` (Boolean).
-
#description ⇒ Object
String A human-readable description of the prompt.
-
#handler ⇒ Object
Proc A callable that generates the prompt content.
-
#name ⇒ Object
String The unique name of the prompt.
Class Method Summary collapse
-
.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) ⇒ Prompt
Class method to create an image-enabled prompt with common image argument patterns.
Instance Method Summary collapse
-
#as_mcp_definition ⇒ Hash
Converts the prompt to its MCP definition hash.
-
#supports_image_arguments? ⇒ Boolean
Checks if this prompt supports image arguments.
Instance Attribute Details
#arguments ⇒ Object
Array<Hash> An array of argument definitions for the prompt, where each hash can contain ‘:name`, `:description`, and `:required` (Boolean).
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/vector_mcp/definitions.rb', line 202 Prompt = Struct.new(:name, :description, :arguments, :handler) do # Converts the prompt to its MCP definition hash. # @return [Hash] A hash representing the prompt in MCP format. def as_mcp_definition { name: name, description: description, arguments: arguments # Expected to be an array of { name:, description:, required: } hashes }.compact end # Checks if this prompt supports image arguments. # @return [Boolean] True if any of the prompt arguments are configured for images. def supports_image_arguments? return false unless arguments.is_a?(Array) arguments.any? do |arg| arg.is_a?(Hash) && ( arg["type"] == "image" || arg[:type] == "image" || (arg["description"] || arg[:description])&.downcase&.include?("image") ) end end # Class method to create an image-enabled prompt with common image argument patterns. # @param name [String] The unique name of the prompt. # @param description [String] A human-readable description. # @param image_argument_name [String] Name of the image argument (default: "image"). # @param additional_arguments [Array<Hash>] Additional prompt arguments. # @param handler [Proc] The prompt handler. # @return [Prompt] A new Prompt instance configured for image input. def self.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) image_arg = { name: image_argument_name, description: "Image file path or image data to include in the prompt", required: false, type: "image" } all_arguments = [image_arg] + additional_arguments new(name, description, all_arguments, handler) end end |
#description ⇒ Object
String A human-readable description of the prompt.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/vector_mcp/definitions.rb', line 202 Prompt = Struct.new(:name, :description, :arguments, :handler) do # Converts the prompt to its MCP definition hash. # @return [Hash] A hash representing the prompt in MCP format. def as_mcp_definition { name: name, description: description, arguments: arguments # Expected to be an array of { name:, description:, required: } hashes }.compact end # Checks if this prompt supports image arguments. # @return [Boolean] True if any of the prompt arguments are configured for images. def supports_image_arguments? return false unless arguments.is_a?(Array) arguments.any? do |arg| arg.is_a?(Hash) && ( arg["type"] == "image" || arg[:type] == "image" || (arg["description"] || arg[:description])&.downcase&.include?("image") ) end end # Class method to create an image-enabled prompt with common image argument patterns. # @param name [String] The unique name of the prompt. # @param description [String] A human-readable description. # @param image_argument_name [String] Name of the image argument (default: "image"). # @param additional_arguments [Array<Hash>] Additional prompt arguments. # @param handler [Proc] The prompt handler. # @return [Prompt] A new Prompt instance configured for image input. def self.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) image_arg = { name: image_argument_name, description: "Image file path or image data to include in the prompt", required: false, type: "image" } all_arguments = [image_arg] + additional_arguments new(name, description, all_arguments, handler) end end |
#handler ⇒ Object
Proc A callable that generates the prompt content. It receives a hash of arguments, validated against the prompt’s argument definitions.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/vector_mcp/definitions.rb', line 202 Prompt = Struct.new(:name, :description, :arguments, :handler) do # Converts the prompt to its MCP definition hash. # @return [Hash] A hash representing the prompt in MCP format. def as_mcp_definition { name: name, description: description, arguments: arguments # Expected to be an array of { name:, description:, required: } hashes }.compact end # Checks if this prompt supports image arguments. # @return [Boolean] True if any of the prompt arguments are configured for images. def supports_image_arguments? return false unless arguments.is_a?(Array) arguments.any? do |arg| arg.is_a?(Hash) && ( arg["type"] == "image" || arg[:type] == "image" || (arg["description"] || arg[:description])&.downcase&.include?("image") ) end end # Class method to create an image-enabled prompt with common image argument patterns. # @param name [String] The unique name of the prompt. # @param description [String] A human-readable description. # @param image_argument_name [String] Name of the image argument (default: "image"). # @param additional_arguments [Array<Hash>] Additional prompt arguments. # @param handler [Proc] The prompt handler. # @return [Prompt] A new Prompt instance configured for image input. def self.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) image_arg = { name: image_argument_name, description: "Image file path or image data to include in the prompt", required: false, type: "image" } all_arguments = [image_arg] + additional_arguments new(name, description, all_arguments, handler) end end |
#name ⇒ Object
String The unique name of the prompt.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/vector_mcp/definitions.rb', line 202 Prompt = Struct.new(:name, :description, :arguments, :handler) do # Converts the prompt to its MCP definition hash. # @return [Hash] A hash representing the prompt in MCP format. def as_mcp_definition { name: name, description: description, arguments: arguments # Expected to be an array of { name:, description:, required: } hashes }.compact end # Checks if this prompt supports image arguments. # @return [Boolean] True if any of the prompt arguments are configured for images. def supports_image_arguments? return false unless arguments.is_a?(Array) arguments.any? do |arg| arg.is_a?(Hash) && ( arg["type"] == "image" || arg[:type] == "image" || (arg["description"] || arg[:description])&.downcase&.include?("image") ) end end # Class method to create an image-enabled prompt with common image argument patterns. # @param name [String] The unique name of the prompt. # @param description [String] A human-readable description. # @param image_argument_name [String] Name of the image argument (default: "image"). # @param additional_arguments [Array<Hash>] Additional prompt arguments. # @param handler [Proc] The prompt handler. # @return [Prompt] A new Prompt instance configured for image input. def self.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) image_arg = { name: image_argument_name, description: "Image file path or image data to include in the prompt", required: false, type: "image" } all_arguments = [image_arg] + additional_arguments new(name, description, all_arguments, handler) end end |
Class Method Details
.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) ⇒ Prompt
Class method to create an image-enabled prompt with common image argument patterns.
234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/vector_mcp/definitions.rb', line 234 def self.with_image_support(name:, description:, image_argument_name: "image", additional_arguments: [], &handler) image_arg = { name: image_argument_name, description: "Image file path or image data to include in the prompt", required: false, type: "image" } all_arguments = [image_arg] + additional_arguments new(name, description, all_arguments, handler) end |
Instance Method Details
#as_mcp_definition ⇒ Hash
Converts the prompt to its MCP definition hash.
205 206 207 208 209 210 211 |
# File 'lib/vector_mcp/definitions.rb', line 205 def as_mcp_definition { name: name, description: description, arguments: arguments # Expected to be an array of { name:, description:, required: } hashes }.compact end |
#supports_image_arguments? ⇒ Boolean
Checks if this prompt supports image arguments.
215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/vector_mcp/definitions.rb', line 215 def supports_image_arguments? return false unless arguments.is_a?(Array) arguments.any? do |arg| arg.is_a?(Hash) && ( arg["type"] == "image" || arg[:type] == "image" || (arg["description"] || arg[:description])&.downcase&.include?("image") ) end end |