kobold_max_length
Retrieve the maximum text generation length setting from KoboldAI's API to control output size and manage computational resources during AI-powered text creation.
Instructions
Get current max length setting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 |
Implementation Reference
- src/index.ts:307-324 (handler)Dispatches the kobold_max_length tool call by making a GET request to the KoboldAI API at /api/v1/config/max_length and returns the JSON response as text content.const getEndpoints: Record<string, string> = { kobold_max_context_length: '/api/v1/config/max_context_length', kobold_max_length: '/api/v1/config/max_length', kobold_generate_check: '/api/extra/generate/check', kobold_model_info: '/api/v1/model', kobold_version: '/api/v1/info/version', kobold_perf_info: '/api/extra/perf', kobold_sd_models: '/sdapi/v1/sd-models', kobold_sd_samplers: '/sdapi/v1/samplers', }; if (getEndpoints[name]) { const result = await makeRequest(`${apiUrl}${getEndpoints[name]}`); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false, }; }
- src/index.ts:173-176 (registration)Registers the kobold_max_length tool in the ListTools response with its name, description, and input schema.name: "kobold_max_length", description: "Get current max length setting", inputSchema: zodToJsonSchema(MaxLengthSchema), },
- src/index.ts:17-17 (schema)Defines the input schema for kobold_max_length tool as BaseConfigSchema (apiUrl optional). BaseConfigSchema is defined at lines 11-13.const MaxLengthSchema = BaseConfigSchema;
- src/index.ts:146-162 (helper)Helper function used by the handler to make HTTP requests to the KoboldAI API.async function makeRequest(url: string, method = 'GET', body: Record<string, unknown> | null = null) { const options: RequestInit = { method, headers: body ? { 'Content-Type': 'application/json' } : undefined, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { throw new Error(`KoboldAI API error: ${response.statusText}`); } return response.json(); }