mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
const express = require('express');
|
|
const { addTool } = require('@librechat/api');
|
|
const { callTool, verifyToolAuth, getToolCalls } = require('~/server/controllers/tools');
|
|
const { getAvailableTools } = require('~/server/controllers/PluginController');
|
|
const { toolCallLimiter } = require('~/server/middleware/limiters');
|
|
|
|
const router = express.Router();
|
|
|
|
/**
|
|
* Get a list of available tools for agents.
|
|
* @route GET /agents/tools
|
|
* @returns {TPlugin[]} 200 - application/json
|
|
*/
|
|
router.get('/', getAvailableTools);
|
|
|
|
/**
|
|
* Get a list of tool calls.
|
|
* @route GET /agents/tools/calls
|
|
* @returns {ToolCallData[]} 200 - application/json
|
|
*/
|
|
router.get('/calls', getToolCalls);
|
|
|
|
/**
|
|
* Verify authentication for a specific tool
|
|
* @route GET /agents/tools/:toolId/auth
|
|
* @param {string} toolId - The ID of the tool to verify
|
|
* @returns {{ authenticated?: boolean; message?: string }}
|
|
*/
|
|
router.get('/:toolId/auth', verifyToolAuth);
|
|
|
|
/**
|
|
* Execute code for a specific tool
|
|
* @route POST /agents/tools/:toolId/call
|
|
* @param {string} toolId - The ID of the tool to execute
|
|
* @param {object} req.body - Request body
|
|
* @returns {object} Result of code execution
|
|
*/
|
|
router.post('/:toolId/call', toolCallLimiter, callTool);
|
|
|
|
/**
|
|
* Add a new tool to the system
|
|
* @route POST /agents/tools/add
|
|
* @param {object} req.body - Request body containing tool data
|
|
* @returns {object} Created tool object
|
|
*/
|
|
router.post('/add', addTool);
|
|
|
|
module.exports = router;
|