ToolDefinitionSchema (chatML/types.ts)

langfuse · packages/shared/src/utils/IORepresentation/chatML/types.ts · typescript · MIT
ai

Module exposing: ToolDefinitionSchema, ToolCallSchema, ParsedMediaReferenceSchema, MEDIA_REFERENCE_PATTERN, MediaReferenceStringSchema, ThinkingContentPartSchema, RedactedThinkingContentPartSchema, OpenAIUrlImageUrl

// Source: https://github.com/langfuse/langfuse | License: MIT | Copyright 2023-2026 ClickHouse, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from "zod";

/**
 * Schema for tool/function definitions in ChatML.
 * Used to define available tools for LLM function calling.
 */
export const ToolDefinitionSchema = z.object({
  name: z.string(),
  description: z.string().optional(),
  parameters: z.record(z.string(), z.any()).optional(),
});

/**
 * Schema for tool/function call invocations in ChatML.
 * Represents an LLM's request to call a specific tool.
 */
export const ToolCallSchema = z.object({
  id: z.string(),
  name: z.string(),
  arguments: z.string(), // JSON string of arguments
  type: z.string().optional(),
  index: z.number().optional(),
});

/**

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key