Internal Release v0.1.1

- implement `Prompt`
- adjust Tool approach
- update readme for tool calling
- document usage of `Prompt`
This commit is contained in:
Topher Bullock 2025-02-27 10:33:57 -05:00
commit a4df3b8688

View file

@ -0,0 +1,29 @@
# frozen_string_literal: true
module ModelContextProtocol
module JsonRPC
class Response
attr_reader :version, :result, :error, :id
def initialize(result: nil, error: nil, id: nil)
@version = VERSION
@result = result
@error = error
@id = id
validate!
end
def to_h
{ id:, result:, jsonrpc: @version, error: @error&.to_h }.compact
end
private
def validate!
raise InvalidResponse, "Result and error cannot both be present" if @result && @error
raise InvalidResponse, "Either result or error must be present" if @result.nil? && @error.nil?
end
end
end
end