@providerprotocol/ai 0.0.31 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anthropic/index.d.ts +1 -1
- package/dist/anthropic/index.js +8 -3
- package/dist/anthropic/index.js.map +1 -1
- package/dist/{chunk-73IIE3QT.js → chunk-6S222DHN.js} +11 -1
- package/dist/chunk-6S222DHN.js.map +1 -0
- package/dist/{embedding-k7g-BcSY.d.ts → embedding-D2BYIehX.d.ts} +8 -1
- package/dist/google/index.d.ts +1 -1
- package/dist/google/index.js +8 -3
- package/dist/google/index.js.map +1 -1
- package/dist/http/index.d.ts +2 -2
- package/dist/index.d.ts +118 -6
- package/dist/index.js +629 -83
- package/dist/index.js.map +1 -1
- package/dist/{llm-DgDEy9il.d.ts → llm-BQJZj3cD.d.ts} +277 -10
- package/dist/ollama/index.d.ts +1 -1
- package/dist/ollama/index.js +8 -3
- package/dist/ollama/index.js.map +1 -1
- package/dist/openai/index.d.ts +1 -1
- package/dist/openai/index.js +13 -4
- package/dist/openai/index.js.map +1 -1
- package/dist/openrouter/index.d.ts +1 -1
- package/dist/openrouter/index.js +13 -4
- package/dist/openrouter/index.js.map +1 -1
- package/dist/proxy/index.d.ts +2 -2
- package/dist/proxy/index.js +7 -4
- package/dist/proxy/index.js.map +1 -1
- package/dist/{retry-CyAwm_KZ.d.ts → retry-8Ch-WWgX.d.ts} +1 -1
- package/dist/xai/index.d.ts +1 -1
- package/dist/xai/index.js +18 -5
- package/dist/xai/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-73IIE3QT.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { L as LLMOptions, a as LLMInstance, I as ImageOptions, b as ImageInstance, c as LLMHandler, E as EmbeddingHandler, d as ImageHandler, P as Provider, M as ModelReference, D as DocumentSource, e as DocumentBlock, A as AudioBlock, V as VideoBlock } from './llm-
|
|
2
|
-
export {
|
|
3
|
-
import { E as EmbeddingOptions, a as EmbeddingInstance } from './embedding-
|
|
4
|
-
export { b as EmbedOptions, c as Embedding, h as EmbeddingInputType, g as EmbeddingModelInput, e as EmbeddingProgress, d as EmbeddingResult, f as EmbeddingStream } from './embedding-
|
|
5
|
-
export { D as DynamicKey, E as ExponentialBackoff, L as LinearBackoff, N as NoRetry, a as RetryAfterStrategy, R as RoundRobinKeys, T as TokenBucket, W as WeightedKeys } from './retry-
|
|
1
|
+
import { L as LLMOptions, a as LLMInstance, I as ImageOptions, b as ImageInstance, c as LLMHandler, E as EmbeddingHandler, d as ImageHandler, P as Provider, M as ModelReference, D as DocumentSource, e as DocumentBlock, A as AudioBlock, V as VideoBlock, f as Middleware, g as EventDelta, S as StreamEvent } from './llm-BQJZj3cD.js';
|
|
2
|
+
export { Y as AfterCallResult, b2 as AnyRequest, b3 as AnyResponse, q as AssistantContent, a0 as AssistantMessage, X as BeforeCallResult, B as BinaryBlock, aA as BoundEmbeddingModel, aZ as BoundImageModel, aK as BoundLLMModel, C as ContentBlock, r as ContentBlockType, t as DocumentSourceType, aF as EmbeddingInput, ay as EmbeddingProvider, aB as EmbeddingRequest, aC as EmbeddingResponse, aE as EmbeddingUsage, aD as EmbeddingVector, i as ErrorCode, aP as GeneratedImage, h as Image, n as ImageBlock, aU as ImageCapabilities, aN as ImageEditInput, aW as ImageEditRequest, aO as ImageGenerateOptions, aM as ImageInput, a_ as ImageModelInput, az as ImageProvider, aY as ImageProviderStreamResult, aV as ImageRequest, aX as ImageResponse, aR as ImageResult, o as ImageSource, s as ImageSourceType, aS as ImageStreamEvent, aT as ImageStreamResult, aQ as ImageUsage, aL as InferenceInput, J as JSONSchema, l as JSONSchemaProperty, m as JSONSchemaPropertyType, av as KeyStrategy, aG as LLMCapabilities, ax as LLMProvider, aH as LLMRequest, aI as LLMResponse, aJ as LLMStreamResult, _ as Message, ag as MessageJSON, a7 as MessageMetadata, a8 as MessageOptions, a2 as MessageRole, a6 as MessageType, a$ as MiddlewareContext, b1 as MiddlewareModality, k as Modality, j as ModalityType, au as ProviderConfig, at as ProviderIdentity, R as ReasoningBlock, aw as RetryStrategy, b0 as StreamContext, ai as StreamEventType, ah as StreamResult, T as TextBlock, ae as Thread, af as ThreadJSON, aa as TokenUsage, K as Tool, N as ToolCall, Z as ToolExecution, Q as ToolMetadata, O as ToolResult, a1 as ToolResultMessage, W as ToolUseStrategy, a9 as Turn, U as UPPError, p as UserContent, $ as UserMessage, ad as aggregateUsage, ap as contentBlockStart, aq as contentBlockStop, aj as createStreamResult, ab as createTurn, ac as emptyUsage, a4 as isAssistantMessage, F as isAudioBlock, H as isBinaryBlock, z as isDocumentBlock, y as isImageBlock, x as isReasoningBlock, w as isTextBlock, a5 as isToolResultMessage, a3 as isUserMessage, G as isVideoBlock, an as messageStart, ao as messageStop, am as objectDelta, v as reasoning, u as text, ak as textDelta, al as toolCallDelta, as as toolExecutionEnd, ar as toolExecutionStart } from './llm-BQJZj3cD.js';
|
|
3
|
+
import { E as EmbeddingOptions, a as EmbeddingInstance } from './embedding-D2BYIehX.js';
|
|
4
|
+
export { b as EmbedOptions, c as Embedding, h as EmbeddingInputType, g as EmbeddingModelInput, e as EmbeddingProgress, d as EmbeddingResult, f as EmbeddingStream } from './embedding-D2BYIehX.js';
|
|
5
|
+
export { D as DynamicKey, E as ExponentialBackoff, L as LinearBackoff, N as NoRetry, a as RetryAfterStrategy, R as RoundRobinKeys, T as TokenBucket, W as WeightedKeys } from './retry-8Ch-WWgX.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @fileoverview LLM instance factory and streaming logic for the Universal Provider Protocol.
|
|
@@ -680,6 +680,118 @@ declare class Video {
|
|
|
680
680
|
static fromBlock(block: VideoBlock): Video;
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
/**
|
|
684
|
+
* @fileoverview Parsed object middleware for incremental JSON parsing.
|
|
685
|
+
*
|
|
686
|
+
* This middleware parses partial JSON from ObjectDelta and ToolCallDelta
|
|
687
|
+
* stream events, providing incremental structured data during streaming.
|
|
688
|
+
*
|
|
689
|
+
* @module middleware/parsed-object
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Event delta with parsed JSON data.
|
|
694
|
+
* Extended by parsedObjectMiddleware when parsing is enabled.
|
|
695
|
+
*/
|
|
696
|
+
interface ParsedEventDelta extends EventDelta {
|
|
697
|
+
/** Incrementally parsed JSON value */
|
|
698
|
+
parsed?: unknown;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Stream event with parsed JSON data.
|
|
702
|
+
* Returned by parsedObjectMiddleware for ObjectDelta and ToolCallDelta events.
|
|
703
|
+
*/
|
|
704
|
+
interface ParsedStreamEvent extends Omit<StreamEvent, 'delta'> {
|
|
705
|
+
delta: ParsedEventDelta;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Options for parsed object middleware.
|
|
709
|
+
*/
|
|
710
|
+
interface ParsedObjectOptions {
|
|
711
|
+
/**
|
|
712
|
+
* Parse ObjectDelta events (structured output responses).
|
|
713
|
+
* @default true
|
|
714
|
+
*/
|
|
715
|
+
parseObjects?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* Parse ToolCallDelta events (tool call arguments).
|
|
718
|
+
* @default true
|
|
719
|
+
*/
|
|
720
|
+
parseToolCalls?: boolean;
|
|
721
|
+
}
|
|
722
|
+
declare function parsedObjectMiddleware(options?: ParsedObjectOptions): Middleware;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* @fileoverview Logging middleware for request/response visibility.
|
|
726
|
+
*
|
|
727
|
+
* Provides configurable logging for LLM, embedding, and image operations,
|
|
728
|
+
* including timing, error tracking, and optional event logging.
|
|
729
|
+
*
|
|
730
|
+
* @module middleware/logging
|
|
731
|
+
*/
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Log levels for filtering output.
|
|
735
|
+
*/
|
|
736
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
737
|
+
/**
|
|
738
|
+
* Options for logging middleware.
|
|
739
|
+
*/
|
|
740
|
+
interface LoggingOptions {
|
|
741
|
+
/**
|
|
742
|
+
* Minimum log level to output.
|
|
743
|
+
* @default 'info'
|
|
744
|
+
*/
|
|
745
|
+
level?: LogLevel;
|
|
746
|
+
/**
|
|
747
|
+
* Log individual stream events.
|
|
748
|
+
* @default false
|
|
749
|
+
*/
|
|
750
|
+
logStreamEvents?: boolean;
|
|
751
|
+
/**
|
|
752
|
+
* Log tool calls and results.
|
|
753
|
+
* @default true
|
|
754
|
+
*/
|
|
755
|
+
logToolCalls?: boolean;
|
|
756
|
+
/**
|
|
757
|
+
* Custom logger function. If not provided, uses console.log.
|
|
758
|
+
* @param level - The log level
|
|
759
|
+
* @param message - The log message
|
|
760
|
+
* @param data - Optional additional data
|
|
761
|
+
*/
|
|
762
|
+
logger?(level: LogLevel, message: string, data?: Record<string, unknown>): void;
|
|
763
|
+
/**
|
|
764
|
+
* Prefix for all log messages.
|
|
765
|
+
* @default '[PP]'
|
|
766
|
+
*/
|
|
767
|
+
prefix?: string;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Creates a logging middleware for visibility into request lifecycle.
|
|
771
|
+
*
|
|
772
|
+
* This middleware logs the start, end, and errors of requests,
|
|
773
|
+
* with optional logging of stream events and tool calls.
|
|
774
|
+
*
|
|
775
|
+
* @param options - Configuration options
|
|
776
|
+
* @returns A middleware that logs request lifecycle events
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```typescript
|
|
780
|
+
* import { llm, loggingMiddleware } from '@providerprotocol/ai';
|
|
781
|
+
* import { anthropic } from '@providerprotocol/ai/anthropic';
|
|
782
|
+
*
|
|
783
|
+
* const model = llm({
|
|
784
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
785
|
+
* middleware: [loggingMiddleware({ level: 'debug' })],
|
|
786
|
+
* });
|
|
787
|
+
*
|
|
788
|
+
* // Logs: [PP] [anthropic] Starting llm request (streaming)
|
|
789
|
+
* // Logs: [PP] [anthropic] Completed in 1234ms
|
|
790
|
+
* const result = await model.generate('Hello');
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
793
|
+
declare function loggingMiddleware(options?: LoggingOptions): Middleware;
|
|
794
|
+
|
|
683
795
|
/**
|
|
684
796
|
* @fileoverview Unified Provider Protocol (UPP) - A unified interface for AI model inference
|
|
685
797
|
*
|
|
@@ -738,4 +850,4 @@ declare const ai: {
|
|
|
738
850
|
image: typeof image;
|
|
739
851
|
};
|
|
740
852
|
|
|
741
|
-
export { Audio, AudioBlock, Document, DocumentBlock, DocumentSource, EmbeddingHandler, EmbeddingInstance, EmbeddingOptions, ImageHandler, ImageInstance, ImageOptions, LLMHandler, LLMInstance, LLMOptions, ModelReference, Provider, Video, VideoBlock, ai, createProvider, embedding, image, llm };
|
|
853
|
+
export { Audio, AudioBlock, Document, DocumentBlock, DocumentSource, EmbeddingHandler, EmbeddingInstance, EmbeddingOptions, EventDelta, ImageHandler, ImageInstance, ImageOptions, LLMHandler, LLMInstance, LLMOptions, type LogLevel, type LoggingOptions, Middleware, ModelReference, type ParsedEventDelta, type ParsedObjectOptions, type ParsedStreamEvent, Provider, StreamEvent, Video, VideoBlock, ai, createProvider, embedding, image, llm, loggingMiddleware, parsedObjectMiddleware };
|