Module: CompletionKit::McpTools::Metrics
- Extended by:
- Base
- Defined in:
- app/services/completion_kit/mcp_tools/metrics.rb
Constant Summary collapse
- TOOLS =
{ "metrics_list" => { description: "List all metrics", inputSchema: {type: "object", properties: {}, required: []}, handler: :list }, "metrics_get" => { description: "Get a metric by ID", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :get }, "metrics_create" => { description: "Create a metric with evaluation criteria", inputSchema: { type: "object", properties: { name: {type: "string"}, instruction: {type: "string"}, rubric_bands: {type: "array", items: {type: "object", properties: {stars: {type: "integer"}, description: {type: "string"}}}}, tag_names: {type: "array", items: {type: "string"}} }, required: ["name"] }, handler: :create }, "metrics_update" => { description: "Update a metric", inputSchema: { type: "object", properties: { id: {type: "integer"}, name: {type: "string"}, instruction: {type: "string"}, rubric_bands: {type: "array", items: {type: "object", properties: {stars: {type: "integer"}, description: {type: "string"}}}}, tag_names: {type: "array", items: {type: "string"}} }, required: ["id"] }, handler: :update }, "metrics_delete" => { description: "Delete a metric", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :delete } }.freeze
Class Method Summary collapse
- .create(args) ⇒ Object
- .delete(args) ⇒ Object
- .get(args) ⇒ Object
- .list(_args) ⇒ Object
- .update(args) ⇒ Object
Methods included from Base
call, definitions, error_result, text_result
Class Method Details
.create(args) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'app/services/completion_kit/mcp_tools/metrics.rb', line 58 def self.create(args) metric = Metric.new(args.slice("name", "instruction", "rubric_bands")) metric.tag_names = args["tag_names"] if args.key?("tag_names") if metric.save text_result(metric.reload.as_json) else error_result(metric.errors..join(", ")) end end |
.delete(args) ⇒ Object
78 79 80 81 |
# File 'app/services/completion_kit/mcp_tools/metrics.rb', line 78 def self.delete(args) Metric.find(args["id"]).destroy! text_result("Metric #{args["id"]} deleted") end |
.get(args) ⇒ Object
54 55 56 |
# File 'app/services/completion_kit/mcp_tools/metrics.rb', line 54 def self.get(args) text_result(Metric.find(args["id"]).as_json) end |
.list(_args) ⇒ Object
50 51 52 |
# File 'app/services/completion_kit/mcp_tools/metrics.rb', line 50 def self.list(_args) text_result(Metric.order(created_at: :desc).map(&:as_json)) end |
.update(args) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'app/services/completion_kit/mcp_tools/metrics.rb', line 68 def self.update(args) metric = Metric.find(args["id"]) if metric.update(args.except("id").slice("name", "instruction", "rubric_bands")) metric.update!(tag_names: args["tag_names"]) if args.key?("tag_names") text_result(metric.reload.as_json) else error_result(metric.errors..join(", ")) end end |