import type { Attributes } from "@opentelemetry/api"; import type { Document, Embedding, InputToAttributesFn, Message, OutputToAttributesFn, SpanInput, SpanOutput, TokenCount, Tool } from "./types"; /** * Converts function arguments into a standardized SpanInput format for tracing. * * This function processes variable arguments and determines the appropriate MIME type * based on the input. Single string arguments are preserved as text, while other * types are JSON stringified. * * @param args - The function arguments to process into span input format * @returns A SpanInput object with value and mimeType, or undefined if no args provided * * @example * ```typescript * // String input * toInputType("hello") // { value: "hello", mimeType: MimeType.TEXT } * * // Object input * toInputType({ key: "value" }) // { value: '{"key":"value"}', mimeType: MimeType.JSON } * * // Multiple arguments * toInputType("arg1", 42) // { value: '["arg1",42]', mimeType: MimeType.JSON } * ``` */ export declare function toInputType(...args: unknown[]): SpanInput | undefined; /** * Converts function output into a standardized SpanOutput format for tracing. * * This function processes the return value of a traced function and determines * the appropriate MIME type. String outputs are preserved as text, while other * types are JSON stringified. * * @param result - The function's return value to process into span output format * @returns A SpanOutput object with value and mimeType, or undefined if result is null/undefined * * @example * ```typescript * // String output * toOutputType("success") // { value: "success", mimeType: MimeType.TEXT } * * // Object output * toOutputType({ status: "ok" }) // { value: '{"status":"ok"}', mimeType: MimeType.JSON } * * // Null/undefined output * toOutputType(null) // undefined * ``` */ export declare function toOutputType(result: unknown): SpanOutput | undefined; /** * Default input processing function that converts function arguments to OpenTelemetry attributes. * * This is a convenience function that combines `toInputType` and `getInputAttributes` * to provide a complete input processing pipeline for tracing decorators. * * @param args - The function arguments to process * @returns OpenTelemetry attributes representing the input * * @example * ```typescript * const attrs = defaultProcessInput("hello", { key: "value" }); * // Returns: { [INPUT_VALUE]: '["hello",{"key":"value"}]', [INPUT_MIME_TYPE]: MimeType.JSON } * ``` */ export declare const defaultProcessInput: InputToAttributesFn; /** * Default output processing function that converts function results to OpenTelemetry attributes. * * This is a convenience function that combines `toOutputType` and `getOutputAttributes` * to provide a complete output processing pipeline for tracing decorators. * * @param res - The function's return value to process * @returns OpenTelemetry attributes representing the output * * @example * ```typescript * const attrs = defaultProcessOutput({ status: "success" }); * // Returns: { [OUTPUT_VALUE]: '{"status":"success"}', [OUTPUT_MIME_TYPE]: MimeType.JSON } * ``` */ export declare const defaultProcessOutput: OutputToAttributesFn; /** * Converts a SpanOutput object or string into OpenTelemetry attributes. * * This function transforms span output data into the standardized attribute format * used by OpenTelemetry, mapping values to the appropriate semantic convention keys. * * @param output - The SpanOutput object, string, or undefined to convert * @returns OpenTelemetry attributes with OUTPUT_VALUE and OUTPUT_MIME_TYPE keys * * @example * ```typescript * // SpanOutput object * getOutputAttributes({ value: "result", mimeType: MimeType.TEXT }) * // Returns: { [OUTPUT_VALUE]: "result", [OUTPUT_MIME_TYPE]: MimeType.TEXT } * * // String input * getOutputAttributes("simple string") * // Returns: { [OUTPUT_VALUE]: "simple string", [OUTPUT_MIME_TYPE]: MimeType.TEXT } * * // Undefined input * getOutputAttributes(undefined) // Returns: {} * ``` */ export declare function getOutputAttributes(output: SpanOutput | string | null | undefined): Attributes; /** * Converts a SpanInput object or string into OpenTelemetry attributes. * * This function transforms span input data into the standardized attribute format * used by OpenTelemetry, mapping values to the appropriate semantic convention keys. * * @param input - The SpanInput object, string, or undefined to convert * @returns OpenTelemetry attributes with INPUT_VALUE and INPUT_MIME_TYPE keys * * @example * ```typescript * // SpanInput object * getOutputAttributes({ value: "query", mimeType: MimeType.TEXT }) * // Returns: { [INPUT_VALUE]: "query", [INPUT_MIME_TYPE]: MimeType.TEXT } * * // String input * getOutputAttributes("simple string") * // Returns: { [INPUT_VALUE]: "simple string", [INPUT_MIME_TYPE]: MimeType.TEXT } * * // Undefined input * getOutputAttributes(undefined) // Returns: {} * ``` */ export declare function getInputAttributes(input: SpanInput | string | undefined): Attributes; /** * Generates attributes for embedding operations. * * Creates OpenTelemetry attributes for embedding-related data including * model name and embedding vectors with associated text. * * @param options - Configuration object for embedding attributes * @param options.modelName - The name of the embedding model used * @param options.embeddings - Array of embedding objects containing text and vector data * @returns OpenTelemetry attributes for embedding operations * * @example * ```typescript * const attrs = getEmbeddingAttributes({ * modelName: "text-embedding-ada-002", * embeddings: [ * { text: "hello world", vector: [0.1, 0.2, 0.3] }, * { text: "goodbye", vector: [0.4, 0.5, 0.6] } * ] * }); * ``` */ export declare function getEmbeddingAttributes(options: { modelName?: string; embeddings?: Embedding[]; }): Attributes; /** * Generates attributes for retriever operations. * * Creates OpenTelemetry attributes for document retrieval operations, * including document content, IDs, metadata, and scores. * * @param options - Configuration object for retriever attributes * @param options.documents - Array of documents retrieved * @returns OpenTelemetry attributes for retriever operations * * @example * ```typescript * const attrs = getRetrieverAttributes({ * documents: [ * { content: "Document 1", id: "doc1", score: 0.95 }, * { content: "Document 2", id: "doc2", metadata: { source: "web" } } * ] * }); * ``` */ export declare function getRetrieverAttributes(options: { documents: Document[]; }): Attributes; /** * Generates attributes for document operations. * * Creates OpenTelemetry attributes for individual document processing, * including content, ID, metadata, and score information. * * @param document - The document to generate attributes for * @param documentIndex - The index of the document in a collection * @param keyPrefix - The prefix for attribute keys (e.g., "reranker.input_documents") * @returns OpenTelemetry attributes for the document * * @example * ```typescript * const attrs = getDocumentAttributes( * { content: "Sample document", id: "doc123", score: 0.8 }, * 0, * "reranker.input_documents" * ); * ``` */ export declare function getDocumentAttributes(document: Document, documentIndex: number, keyPrefix: string): Attributes; /** * Generates attributes for metadata information. * * @param metadata - The metadata to include in attributes * @returns OpenTelemetry attributes containing the metadata * * @example * ```typescript * const attrs = getMetadataAttributes({ version: "1.0", env: "prod" }); * ``` */ export declare function getMetadataAttributes(metadata: Record): Attributes; /** * Generates attributes for tool definitions. * * Creates OpenTelemetry attributes for tool information including * name, description, and parameters schema. * * @param options - Configuration object for tool attributes * @param options.name - The name of the tool * @param options.description - Optional description of the tool * @param options.parameters - Tool parameters as string or object * @returns OpenTelemetry attributes for the tool * * @example * ```typescript * const attrs = getToolAttributes({ * name: "search_tool", * description: "Search for information", * parameters: { query: { type: "string" } } * }); * ``` */ export declare function getToolAttributes(options: { name: string; description?: string; parameters: Record; }): Attributes; /** * Generates attributes for LLM operations. * * Creates comprehensive OpenTelemetry attributes for LLM interactions * including provider, model, messages, token counts, and tools. * * @param options - Configuration object for LLM attributes * @param options.provider - The LLM provider (e.g., "openai", "anthropic") * @param options.system - The LLM system type * @param options.modelName - The name of the LLM model * @param options.invocationParameters - Parameters used for the LLM invocation * @param options.inputMessages - Input messages sent to the LLM * @param options.outputMessages - Output messages received from the LLM * @param options.tokenCount - Token usage information * @param options.tools - Tools available to the LLM * @returns OpenTelemetry attributes for LLM operations * * @example * ```typescript * const attrs = getLLMAttributes({ * provider: "openai", * modelName: "gpt-4", * inputMessages: [{ role: "user", content: "Hello" }], * outputMessages: [{ role: "assistant", content: "Hi there!" }], * tokenCount: { prompt: 10, completion: 5, total: 15 } * }); * ``` */ export declare function getLLMAttributes(options: { provider?: string; system?: string; modelName?: string; invocationParameters?: Record; inputMessages?: Message[]; outputMessages?: Message[]; tokenCount?: TokenCount; tools?: Tool[]; }): Attributes; //# sourceMappingURL=attributeHelpers.d.ts.map