|
1 | | -<div class="card"> |
2 | | - <h2>1) Register a tool service</h2> |
3 | | - <p>Paste a Ruby class that extends <code>ToolMeta</code> and has a Sorbet signature. The controller will evaluate it and register both RubyLLM and FastMCP tool wrappers.</p> |
4 | | - <%= form_with url: playground_register_path, method: :post do %> |
5 | | - <label for="source">Tool class source code</label><br> |
6 | | - <%= text_area_tag :source, params[:source], placeholder: "class Tools::EchoService\n extend T::Sig\n extend ToolMeta\n\n tool_description 'Echoes the provided payload'\n tool_param :message, description: 'Message to return'\n\n sig { params(message: String).returns(String) }\n def call(message:)\n message\n end\nend" %> |
7 | | - <div class="actions"> |
8 | | - <%= submit_tag 'Register tool' %> |
9 | | - </div> |
10 | | - <% end %> |
11 | | - |
12 | | - <% if @register_result.present? %> |
13 | | - <h3>Registration response</h3> |
14 | | - <pre><%= JSON.pretty_generate(@register_result) %></pre> |
15 | | - <% end %> |
16 | | -</div> |
17 | | - |
18 | | -<div class="card"> |
19 | | - <h2>2) Run a tool</h2> |
20 | | - <p>Select a tool and provide JSON arguments to send through the generated RubyLLM wrapper.</p> |
21 | | - <%= form_with url: playground_run_path, method: :post do %> |
22 | | - <label for="tool_name">Tool name</label><br> |
23 | | - <%= select_tag :tool_name, options_for_select(@tools.map { |schema| [schema[:name], schema[:name]] }, params[:tool_name]), prompt: 'Choose a tool' %> |
24 | | - <br><br> |
25 | | - <label for="arguments">Arguments (JSON)</label><br> |
26 | | - <%= text_area_tag :arguments, params[:arguments], placeholder: '{"message": "Hello"}' %> |
27 | | - <div class="actions"> |
28 | | - <%= submit_tag 'Run tool' %> |
29 | | - </div> |
30 | | - <% end %> |
31 | | - |
32 | | - <% if @test_result.present? %> |
33 | | - <h3>Execution response</h3> |
34 | | - <pre><%= JSON.pretty_generate(@test_result) %></pre> |
35 | | - <% end %> |
36 | | -</div> |
37 | 1 |
|
38 | 2 | <div class="card"> |
39 | 3 | <h2>Registered tools</h2> |
|
121 | 85 | <% end %> |
122 | 86 | </div> |
123 | 87 |
|
| 88 | +<div class="card"> |
| 89 | + <h2>Register a tool service</h2> |
| 90 | + <p>Paste a Ruby class that extends <code>ToolMeta</code> and has a Sorbet signature. The controller will evaluate it and register both RubyLLM and FastMCP tool wrappers.</p> |
| 91 | + <%= form_with url: playground_register_path, method: :post do %> |
| 92 | + <label for="source">Tool class source code</label><br> |
| 93 | + <%= text_area_tag :source, params[:source], placeholder: "class Tools::EchoService\n extend T::Sig\n extend ToolMeta\n\n tool_description 'Echoes the provided payload'\n tool_param :message, description: 'Message to return'\n\n sig { params(message: String).returns(String) }\n def call(message:)\n message\n end\nend" %> |
| 94 | + <div class="actions"> |
| 95 | + <%= submit_tag 'Register tool' %> |
| 96 | + </div> |
| 97 | + <% end %> |
| 98 | + |
| 99 | + <% if @register_result.present? %> |
| 100 | + <h3>Registration response</h3> |
| 101 | + <pre><%= JSON.pretty_generate(@register_result) %></pre> |
| 102 | + <% end %> |
| 103 | +</div> |
| 104 | + |
| 105 | +<div class="card"> |
| 106 | + <h2>Run a tool</h2> |
| 107 | + <p>Select a tool and provide JSON arguments to send through the generated RubyLLM wrapper.</p> |
| 108 | + <%= form_with url: playground_run_path, method: :post do %> |
| 109 | + <label for="tool_name">Tool name</label><br> |
| 110 | + <%= select_tag :tool_name, options_for_select(@tools.map { |schema| [schema[:name], schema[:name]] }, params[:tool_name]), prompt: 'Choose a tool' %> |
| 111 | + <br><br> |
| 112 | + <label for="arguments">Arguments (JSON)</label><br> |
| 113 | + <%= text_area_tag :arguments, params[:arguments], placeholder: '{"message": "Hello"}' %> |
| 114 | + <div class="actions"> |
| 115 | + <%= submit_tag 'Run tool' %> |
| 116 | + </div> |
| 117 | + <% end %> |
| 118 | + |
| 119 | + <% if @test_result.present? %> |
| 120 | + <h3>Execution response</h3> |
| 121 | + <pre><%= JSON.pretty_generate(@test_result) %></pre> |
| 122 | + <% end %> |
| 123 | +</div> |
| 124 | + |
124 | 125 | <script> |
125 | 126 | function toggleToolDetails(index) { |
126 | 127 | const details = document.getElementById('tool-details-' + index); |
|
0 commit comments