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
51
test/model_context_protocol/prompt_test.rb
Normal file
51
test/model_context_protocol/prompt_test.rb
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
module ModelContextProtocol
|
||||
class PromptTest < ActiveSupport::TestCase
|
||||
test "#template validates arguments" do
|
||||
prompt = Prompt.new(
|
||||
name: "test_prompt",
|
||||
description: "Test prompt",
|
||||
arguments: [
|
||||
Prompt::Argument.new(name: "test_argument", description: "Test argument", required: true),
|
||||
],
|
||||
)
|
||||
assert_raises(ArgumentError) do
|
||||
prompt.template({})
|
||||
end
|
||||
end
|
||||
|
||||
test "#template returns a Result with description and messages when arguments are valid" do
|
||||
prompt = Prompt.new(
|
||||
name: "test_prompt",
|
||||
description: "Test prompt",
|
||||
arguments: [
|
||||
Prompt::Argument.new(name: "test_argument", description: "Test argument", required: true),
|
||||
],
|
||||
) do |_|
|
||||
Prompt::Result.new(
|
||||
description: "Hello, world!",
|
||||
messages: [
|
||||
Prompt::Message.new(role: "user", content: Content::Text.new("Hello, world!")),
|
||||
Prompt::Message.new(role: "assistant", content: Content::Text.new("Hello, friend!")),
|
||||
],
|
||||
)
|
||||
end
|
||||
|
||||
expected = {
|
||||
description: "Hello, world!",
|
||||
messages: [
|
||||
{ role: "user", content: { text: "Hello, world!" } },
|
||||
{ role: "assistant", content: { text: "Hello, friend!" } },
|
||||
],
|
||||
}
|
||||
|
||||
result = prompt.template({ "test_argument" => "Hello, friend!" })
|
||||
|
||||
assert_equal expected, result.to_h
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue