Module: CompletionKit::McpTools::Runs
- Extended by:
- Base
- Defined in:
- app/services/completion_kit/mcp_tools/runs.rb
Constant Summary collapse
- TOOLS =
{ "runs_list" => { description: "List all runs", inputSchema: {type: "object", properties: {}, required: []}, handler: :list }, "runs_get" => { description: "Get a run by ID", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :get }, "runs_create" => { description: "Create a run", inputSchema: { type: "object", properties: { name: {type: "string"}, prompt_id: {type: "integer"}, dataset_id: {type: "integer"}, judge_model: {type: "string"}, metric_ids: {type: "array", items: {type: "integer"}}, tag_names: {type: "array", items: {type: "string"}} }, required: ["name", "prompt_id"] }, handler: :create }, "runs_update" => { description: "Update a run", inputSchema: { type: "object", properties: { id: {type: "integer"}, name: {type: "string"}, dataset_id: {type: "integer"}, judge_model: {type: "string"}, metric_ids: {type: "array", items: {type: "integer"}}, tag_names: {type: "array", items: {type: "string"}} }, required: ["id"] }, handler: :update }, "runs_delete" => { description: "Delete a run", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :delete }, "runs_generate" => { description: "Generate responses for a run using its prompt and dataset", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :generate } }.freeze
Class Method Summary collapse
- .create(args) ⇒ Object
- .delete(args) ⇒ Object
- .generate(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
65 66 67 68 69 70 71 72 73 74 |
# File 'app/services/completion_kit/mcp_tools/runs.rb', line 65 def self.create(args) run = Run.new(args.slice("name", "prompt_id", "dataset_id", "judge_model")) if run.save run.replace_metrics!(args["metric_ids"]) run.update!(tag_names: args["tag_names"]) if args.key?("tag_names") text_result(run.reload.as_json) else error_result(run.errors..join(", ")) end end |
.delete(args) ⇒ Object
87 88 89 90 |
# File 'app/services/completion_kit/mcp_tools/runs.rb', line 87 def self.delete(args) Run.find(args["id"]).destroy! text_result("Run #{args["id"]} deleted") end |
.generate(args) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'app/services/completion_kit/mcp_tools/runs.rb', line 92 def self.generate(args) run = Run.find(args["id"]) if run.start! text_result(run.reload.as_json) else text_result(run.failure_summary || run.errors..to_sentence) end end |
.get(args) ⇒ Object
61 62 63 |
# File 'app/services/completion_kit/mcp_tools/runs.rb', line 61 def self.get(args) text_result(Run.find(args["id"]).as_json) end |
.list(_args) ⇒ Object
57 58 59 |
# File 'app/services/completion_kit/mcp_tools/runs.rb', line 57 def self.list(_args) text_result(Run.order(created_at: :desc).map(&:as_json)) end |
.update(args) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'app/services/completion_kit/mcp_tools/runs.rb', line 76 def self.update(args) run = Run.find(args["id"]) if run.update(args.except("id", "metric_ids", "tag_names").slice("name", "dataset_id", "judge_model")) run.replace_metrics!(args["metric_ids"]) if args.key?("metric_ids") run.update!(tag_names: args["tag_names"]) if args.key?("tag_names") text_result(run.reload.as_json) else error_result(run.errors..join(", ")) end end |