Internal Release v0.1.1
- implement `Prompt` - adjust Tool approach - update readme for tool calling - document usage of `Prompt`
This commit is contained in:
commit
a4df3b8688
1 changed files with 1530 additions and 0 deletions
29
lib/model_context_protocol/json_rpc/response.rb
Normal file
29
lib/model_context_protocol/json_rpc/response.rb
Normal 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
|
||||
Loading…
Reference in a new issue