Skip to main content
Glama

kobold_last_logprobs

Retrieve token log probabilities from the most recent text generation request to analyze model confidence and token-level predictions.

Instructions

Get token logprobs from the last request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiUrlNohttp://localhost:5001

Implementation Reference

  • Handler dispatch table mapping 'kobold_last_logprobs' to endpoint '/api/extra/last_logprobs' and execution logic that proxies POST requests to the KoboldAI API after schema validation.
    const postEndpoints: Record<string, { endpoint: string; schema: z.ZodTypeAny }> = { kobold_multiplayer_status: { endpoint: '/api/extra/multiplayer/status', schema: MultiplayerStatusSchema }, kobold_multiplayer_get_story: { endpoint: '/api/extra/multiplayer/getstory', schema: MultiplayerGetStorySchema }, kobold_multiplayer_set_story: { endpoint: '/api/extra/multiplayer/setstory', schema: MultiplayerSetStorySchema }, kobold_generate_check_multiuser: { endpoint: '/api/extra/generate/check', schema: GenerateCheckMultiuserSchema }, kobold_generate: { endpoint: '/api/v1/generate', schema: GenerateSchema }, kobold_token_count: { endpoint: '/api/extra/tokencount', schema: TokenCountSchema }, kobold_detokenize: { endpoint: '/api/extra/detokenize', schema: DetokenizeSchema }, kobold_transcribe: { endpoint: '/api/extra/transcribe', schema: TranscribeSchema }, kobold_web_search: { endpoint: '/api/extra/websearch', schema: WebSearchSchema }, kobold_tts: { endpoint: '/api/extra/tts', schema: TTSSchema }, kobold_abort: { endpoint: '/api/extra/abort', schema: AbortSchema }, kobold_last_logprobs: { endpoint: '/api/extra/last_logprobs', schema: LastLogProbsSchema }, kobold_txt2img: { endpoint: '/sdapi/v1/txt2img', schema: Txt2ImgSchema }, kobold_img2img: { endpoint: '/sdapi/v1/img2img', schema: Img2ImgSchema }, kobold_interrogate: { endpoint: '/sdapi/v1/interrogate', schema: InterrogateSchema }, kobold_complete: { endpoint: '/v1/completions', schema: CompletionSchema }, }; if (postEndpoints[name]) { const { endpoint, schema } = postEndpoints[name]; const parsed = schema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments: ${parsed.error}`); } const result = await makeRequest(`${apiUrl}${endpoint}`, 'POST', requestData); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false, };
  • BaseConfigSchema defining the common apiUrl parameter, used by LastLogProbsSchema for input validation.
    const BaseConfigSchema = z.object({ apiUrl: z.string().default('http://localhost:5001'), });
  • LastLogProbsSchema definition, aliasing BaseConfigSchema for the tool's input schema.
    const LastLogProbsSchema = BaseConfigSchema;
  • src/index.ts:228-232 (registration)
    Registration of the 'kobold_last_logprobs' tool in the ListTools response, specifying name, description, and input schema.
    { name: "kobold_last_logprobs", description: "Get token logprobs from the last request", inputSchema: zodToJsonSchema(LastLogProbsSchema), },
  • makeRequest helper function that performs the HTTP request proxying to the KoboldAI backend, used by the tool handler.
    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(); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PhialsBasement/KoboldCPP-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server