@assemble-dev/providers 0.2.0 → 0.3.1
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/index.cjs +1530 -266
- package/dist/index.d.cts +174 -6
- package/dist/index.d.ts +174 -6
- package/dist/index.js +1474 -244
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { JsonValue } from '@assemble-dev/shared-types/json';
|
|
2
|
+
import { JsonValue, JsonObject } from '@assemble-dev/shared-types/json';
|
|
3
3
|
import { TokenUsage } from '@assemble-dev/shared-types/runs';
|
|
4
4
|
import { AppError } from '@assemble-dev/shared-utils/errors';
|
|
5
5
|
import * as _assemble_dev_shared_types from '@assemble-dev/shared-types';
|
|
@@ -104,10 +104,14 @@ type ChatCompletionResult = {
|
|
|
104
104
|
latencyMs: number;
|
|
105
105
|
toolCalls?: ModelToolCall[];
|
|
106
106
|
stopReason?: ChatStopReason;
|
|
107
|
+
thinkingText?: string;
|
|
107
108
|
};
|
|
108
109
|
type ChatStreamEvent = {
|
|
109
110
|
type: "text_delta";
|
|
110
111
|
text: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: "thinking_delta";
|
|
114
|
+
text: string;
|
|
111
115
|
} | {
|
|
112
116
|
type: "tool_call_started";
|
|
113
117
|
id: string;
|
|
@@ -227,6 +231,12 @@ type AnthropicToolChoice = {
|
|
|
227
231
|
type: "tool";
|
|
228
232
|
name: string;
|
|
229
233
|
};
|
|
234
|
+
type AnthropicOutputConfig = {
|
|
235
|
+
format: {
|
|
236
|
+
type: "json_schema";
|
|
237
|
+
schema: JsonObject;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
230
240
|
type AnthropicRequestBody = {
|
|
231
241
|
model: string;
|
|
232
242
|
max_tokens: number;
|
|
@@ -239,6 +249,7 @@ type AnthropicRequestBody = {
|
|
|
239
249
|
};
|
|
240
250
|
tools?: AnthropicToolDefinition[];
|
|
241
251
|
tool_choice?: AnthropicToolChoice;
|
|
252
|
+
output_config?: AnthropicOutputConfig;
|
|
242
253
|
stream?: true;
|
|
243
254
|
};
|
|
244
255
|
type AnthropicRequestInput = {
|
|
@@ -247,6 +258,7 @@ type AnthropicRequestInput = {
|
|
|
247
258
|
maxOutputTokens?: number;
|
|
248
259
|
tools?: ModelToolDefinition[];
|
|
249
260
|
toolChoice?: ModelToolChoice;
|
|
261
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
250
262
|
abortSignal?: AbortSignal;
|
|
251
263
|
extraBody?: Record<string, JsonValue>;
|
|
252
264
|
};
|
|
@@ -344,6 +356,21 @@ declare function isAbortError(error: Error): boolean;
|
|
|
344
356
|
declare function buildProviderCanceledError(providerLabel: string): AppError;
|
|
345
357
|
declare function executeAbortableProviderFetch(providerLabel: string, performFetch: () => Promise<Response>): Promise<Response>;
|
|
346
358
|
|
|
359
|
+
declare const openAiStructuredOutputSchemaName = "structured_output";
|
|
360
|
+
declare function isZodV4Schema<T>(schema: z.ZodType<T>): boolean;
|
|
361
|
+
declare function convertZodSchemaToJsonSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
362
|
+
declare function buildAnthropicStructuredOutputJsonSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
363
|
+
declare function sanitizeJsonSchemaForAnthropicStructuredOutput(jsonSchema: JsonObject): JsonObject;
|
|
364
|
+
declare function buildOpenAiStructuredOutputJsonSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
365
|
+
declare function sanitizeJsonSchemaForOpenAiStructuredOutput(jsonSchema: JsonObject): JsonObject;
|
|
366
|
+
|
|
367
|
+
declare const structuredOutputJsonOnlySystemInstruction = "Respond with a single JSON object that satisfies the caller's requested structure. Output only valid JSON with no surrounding text.";
|
|
368
|
+
declare const structuredOutputJsonOnlySystemMessage: ChatMessage;
|
|
369
|
+
declare function prependStructuredOutputJsonOnlySystemMessage(messages: ChatMessage[]): ChatMessage[];
|
|
370
|
+
|
|
371
|
+
declare function buildGeminiResponseSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
372
|
+
declare function sanitizeJsonSchemaForGeminiResponseSchema(jsonSchema: JsonObject): JsonObject;
|
|
373
|
+
|
|
347
374
|
declare const AnthropicUsageSchema: z.ZodObject<{
|
|
348
375
|
input_tokens: z.ZodNumber;
|
|
349
376
|
output_tokens: z.ZodNumber;
|
|
@@ -379,6 +406,7 @@ declare const AnthropicMessagesResponseSchema: z.ZodObject<{
|
|
|
379
406
|
type AnthropicMessagesResponse = z.infer<typeof AnthropicMessagesResponseSchema>;
|
|
380
407
|
declare function mapAnthropicResponseToChatCompletionResult(response: AnthropicMessagesResponse, latencyMs: number): ChatCompletionResult;
|
|
381
408
|
declare function extractAnthropicToolCalls(response: AnthropicMessagesResponse): ModelToolCall[];
|
|
409
|
+
declare function extractAnthropicThinkingText(response: AnthropicMessagesResponse): string;
|
|
382
410
|
declare function extractAnthropicTextContent(response: AnthropicMessagesResponse, allowEmptyText: boolean): string;
|
|
383
411
|
declare function normalizeAnthropicStopReason(providerStopReason: string): ChatStopReason;
|
|
384
412
|
declare function mapAnthropicUsageToTokenUsage(usage: AnthropicUsage): TokenUsage;
|
|
@@ -411,6 +439,12 @@ declare const AnthropicStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
411
439
|
content_block: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
412
440
|
type: z.ZodLiteral<"text">;
|
|
413
441
|
text: z.ZodOptional<z.ZodString>;
|
|
442
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
443
|
+
type: z.ZodLiteral<"thinking">;
|
|
444
|
+
thinking: z.ZodOptional<z.ZodString>;
|
|
445
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
446
|
+
type: z.ZodLiteral<"redacted_thinking">;
|
|
447
|
+
data: z.ZodOptional<z.ZodString>;
|
|
414
448
|
}, z.core.$strip>, z.ZodObject<{
|
|
415
449
|
type: z.ZodLiteral<"tool_use">;
|
|
416
450
|
id: z.ZodString;
|
|
@@ -422,6 +456,12 @@ declare const AnthropicStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
422
456
|
delta: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
423
457
|
type: z.ZodLiteral<"text_delta">;
|
|
424
458
|
text: z.ZodString;
|
|
459
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
460
|
+
type: z.ZodLiteral<"thinking_delta">;
|
|
461
|
+
thinking: z.ZodString;
|
|
462
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
463
|
+
type: z.ZodLiteral<"signature_delta">;
|
|
464
|
+
signature: z.ZodString;
|
|
425
465
|
}, z.core.$strip>, z.ZodObject<{
|
|
426
466
|
type: z.ZodLiteral<"input_json_delta">;
|
|
427
467
|
partial_json: z.ZodString;
|
|
@@ -489,14 +529,23 @@ type OpenAiToolChoice = "auto" | "required" | "none" | {
|
|
|
489
529
|
name: string;
|
|
490
530
|
};
|
|
491
531
|
};
|
|
532
|
+
type OpenAiResponseFormat = {
|
|
533
|
+
type: "json_object";
|
|
534
|
+
} | {
|
|
535
|
+
type: "json_schema";
|
|
536
|
+
json_schema: {
|
|
537
|
+
name: string;
|
|
538
|
+
strict: true;
|
|
539
|
+
schema: JsonObject;
|
|
540
|
+
};
|
|
541
|
+
};
|
|
492
542
|
type OpenAiRequestBody = {
|
|
493
543
|
model: string;
|
|
494
544
|
messages: OpenAiRequestMessage[];
|
|
495
545
|
temperature?: number;
|
|
496
546
|
max_tokens?: number;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
};
|
|
547
|
+
max_completion_tokens?: number;
|
|
548
|
+
response_format?: OpenAiResponseFormat;
|
|
500
549
|
tools?: OpenAiToolDefinition[];
|
|
501
550
|
tool_choice?: OpenAiToolChoice;
|
|
502
551
|
};
|
|
@@ -504,12 +553,21 @@ type OpenAiCallInput = {
|
|
|
504
553
|
messages: ChatMessage[];
|
|
505
554
|
temperature?: number;
|
|
506
555
|
maxOutputTokens?: number;
|
|
507
|
-
|
|
556
|
+
reasoningModel?: boolean;
|
|
557
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
558
|
+
requireJsonObjectResponse?: boolean;
|
|
508
559
|
tools?: ModelToolDefinition[];
|
|
509
560
|
toolChoice?: ModelToolChoice;
|
|
510
561
|
abortSignal?: AbortSignal;
|
|
511
562
|
extraBody?: Record<string, JsonValue>;
|
|
512
563
|
};
|
|
564
|
+
type OpenAiStructuredOutputMode = {
|
|
565
|
+
messages: ChatMessage[];
|
|
566
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
567
|
+
requireJsonObjectResponse?: boolean;
|
|
568
|
+
};
|
|
569
|
+
declare function isOpenAiReasoningModel(model: string): boolean;
|
|
570
|
+
declare function resolveOpenAiStructuredOutputMode<T>(messages: ChatMessage[], schema: z.ZodType<T>): OpenAiStructuredOutputMode;
|
|
513
571
|
declare function buildOpenAiRequestBody(model: string, input: OpenAiCallInput): OpenAiRequestBody;
|
|
514
572
|
declare function mapModelToolDefinitionToOpenAiTool(tool: ModelToolDefinition): OpenAiToolDefinition;
|
|
515
573
|
declare function mapModelToolChoiceToOpenAiToolChoice(toolChoice: ModelToolChoice): OpenAiToolChoice;
|
|
@@ -524,6 +582,7 @@ type AnthropicBatchMessageRequest = {
|
|
|
524
582
|
temperature?: number;
|
|
525
583
|
promptCaching?: AnthropicBatchPromptCachingMode;
|
|
526
584
|
requireJsonResponse?: boolean;
|
|
585
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
527
586
|
};
|
|
528
587
|
type AnthropicBatchApiRequestMessage = {
|
|
529
588
|
role: "user" | "assistant";
|
|
@@ -542,6 +601,7 @@ type AnthropicBatchApiRequestParams = {
|
|
|
542
601
|
messages: AnthropicBatchApiRequestMessage[];
|
|
543
602
|
system?: string | AnthropicBatchSystemContentBlock[];
|
|
544
603
|
temperature?: number;
|
|
604
|
+
output_config?: AnthropicOutputConfig;
|
|
545
605
|
};
|
|
546
606
|
type AnthropicBatchApiRequest = {
|
|
547
607
|
custom_id: string;
|
|
@@ -638,4 +698,112 @@ declare function createAnthropicBatchClient(options: AnthropicBatchClientOptions
|
|
|
638
698
|
declare const anthropicBatchJsonOnlySystemInstruction = "Respond with a single JSON object that satisfies the caller's requested structure. Output only valid JSON with no surrounding text.";
|
|
639
699
|
declare function parseAnthropicBatchStructuredContent<T>(content: string, schema: ValidationSchema<T>): T;
|
|
640
700
|
|
|
641
|
-
|
|
701
|
+
declare const defaultAzureOpenAiApiVersion = "2024-10-21";
|
|
702
|
+
type AzureOpenAiAdapterOptions = {
|
|
703
|
+
deployment: string;
|
|
704
|
+
resourceName?: string;
|
|
705
|
+
baseURL?: string;
|
|
706
|
+
apiVersion?: string;
|
|
707
|
+
apiKey?: string;
|
|
708
|
+
apiKeyName?: string;
|
|
709
|
+
fetchImplementation?: typeof fetch;
|
|
710
|
+
temperature?: number;
|
|
711
|
+
maxOutputTokens?: number;
|
|
712
|
+
reasoningModel?: boolean;
|
|
713
|
+
retry?: ProviderRetryOptions;
|
|
714
|
+
extraBody?: Record<string, JsonValue>;
|
|
715
|
+
};
|
|
716
|
+
type AzureOpenAiChatRequestBody = Omit<OpenAiRequestBody, "model">;
|
|
717
|
+
declare function azureOpenai(options: AzureOpenAiAdapterOptions): ModelAdapter;
|
|
718
|
+
declare function buildAzureOpenAiChatCompletionsUrl(options: AzureOpenAiAdapterOptions): string;
|
|
719
|
+
declare function buildAzureOpenAiChatRequestBody(input: OpenAiCallInput): AzureOpenAiChatRequestBody;
|
|
720
|
+
|
|
721
|
+
declare const AzureOpenAiUsageSchema: z.ZodObject<{
|
|
722
|
+
prompt_tokens: z.ZodNumber;
|
|
723
|
+
completion_tokens: z.ZodNumber;
|
|
724
|
+
total_tokens: z.ZodNumber;
|
|
725
|
+
}, z.core.$strip>;
|
|
726
|
+
type AzureOpenAiUsage = z.infer<typeof AzureOpenAiUsageSchema>;
|
|
727
|
+
declare const AzureOpenAiChatCompletionResponseSchema: z.ZodObject<{
|
|
728
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
729
|
+
message: z.ZodObject<{
|
|
730
|
+
content: z.ZodNullable<z.ZodString>;
|
|
731
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
732
|
+
id: z.ZodString;
|
|
733
|
+
function: z.ZodObject<{
|
|
734
|
+
name: z.ZodString;
|
|
735
|
+
arguments: z.ZodString;
|
|
736
|
+
}, z.core.$strip>;
|
|
737
|
+
}, z.core.$strip>>>;
|
|
738
|
+
}, z.core.$strip>;
|
|
739
|
+
finish_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
740
|
+
}, z.core.$strip>>;
|
|
741
|
+
usage: z.ZodObject<{
|
|
742
|
+
prompt_tokens: z.ZodNumber;
|
|
743
|
+
completion_tokens: z.ZodNumber;
|
|
744
|
+
total_tokens: z.ZodNumber;
|
|
745
|
+
}, z.core.$strip>;
|
|
746
|
+
}, z.core.$strip>;
|
|
747
|
+
type AzureOpenAiChatCompletionResponse = z.infer<typeof AzureOpenAiChatCompletionResponseSchema>;
|
|
748
|
+
declare function mapAzureOpenAiResponseToChatCompletionResult(response: AzureOpenAiChatCompletionResponse, latencyMs: number): ChatCompletionResult;
|
|
749
|
+
declare function parseAzureOpenAiToolArgumentsJson(argumentsJsonText: string): JsonValue;
|
|
750
|
+
declare function normalizeAzureOpenAiFinishReason(finishReason: string): ChatStopReason;
|
|
751
|
+
declare function mapAzureOpenAiUsageToTokenUsage(usage: AzureOpenAiUsage): TokenUsage;
|
|
752
|
+
|
|
753
|
+
type AzureOpenAiStreamRequestBody = Omit<OpenAiRequestBody, "model"> & {
|
|
754
|
+
stream: true;
|
|
755
|
+
stream_options: {
|
|
756
|
+
include_usage: boolean;
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
type AzureOpenAiStreamRequestInput = {
|
|
760
|
+
url: string;
|
|
761
|
+
headers: Record<string, string>;
|
|
762
|
+
body: AzureOpenAiStreamRequestBody;
|
|
763
|
+
fetchImplementation: typeof fetch;
|
|
764
|
+
retry?: ProviderRetryOptions;
|
|
765
|
+
abortSignal?: AbortSignal;
|
|
766
|
+
};
|
|
767
|
+
declare function streamAzureOpenAiChatCompletion(input: AzureOpenAiStreamRequestInput): AsyncGenerator<ChatStreamEvent, void, void>;
|
|
768
|
+
declare function parseAzureOpenAiStreamEvents(body: ReadableStream<Uint8Array>, startedAt: number, abortSignal: AbortSignal | undefined): AsyncGenerator<ChatStreamEvent, void, void>;
|
|
769
|
+
|
|
770
|
+
declare const awsSigV4Algorithm = "AWS4-HMAC-SHA256";
|
|
771
|
+
type AwsCredentials = {
|
|
772
|
+
accessKeyId: string;
|
|
773
|
+
secretAccessKey: string;
|
|
774
|
+
sessionToken?: string;
|
|
775
|
+
};
|
|
776
|
+
type AwsSigV4SigningInput = {
|
|
777
|
+
method: string;
|
|
778
|
+
url: URL;
|
|
779
|
+
headers: Record<string, string>;
|
|
780
|
+
bodyText: string;
|
|
781
|
+
region: string;
|
|
782
|
+
service: string;
|
|
783
|
+
credentials: AwsCredentials;
|
|
784
|
+
signingDate?: Date;
|
|
785
|
+
};
|
|
786
|
+
declare function signAwsRequestWithSigV4(input: AwsSigV4SigningInput): Promise<Record<string, string>>;
|
|
787
|
+
|
|
788
|
+
declare const bedrockAnthropicVersion = "bedrock-2023-05-31";
|
|
789
|
+
declare const defaultBedrockMaxOutputTokens = 1024;
|
|
790
|
+
type BedrockCredentials = AwsCredentials;
|
|
791
|
+
type BedrockAdapterOptions = {
|
|
792
|
+
region: string;
|
|
793
|
+
modelId: string;
|
|
794
|
+
credentials?: BedrockCredentials;
|
|
795
|
+
fetchImplementation?: typeof fetch;
|
|
796
|
+
temperature?: number;
|
|
797
|
+
maxOutputTokens?: number;
|
|
798
|
+
retry?: ProviderRetryOptions;
|
|
799
|
+
extraBody?: Record<string, JsonValue>;
|
|
800
|
+
};
|
|
801
|
+
type BedrockInvokeModelRequestBody = Omit<AnthropicRequestBody, "model" | "stream"> & {
|
|
802
|
+
anthropic_version: string;
|
|
803
|
+
};
|
|
804
|
+
declare function bedrock(options: BedrockAdapterOptions): ModelAdapter;
|
|
805
|
+
declare function buildBedrockInvokeModelUrl(region: string, modelId: string): string;
|
|
806
|
+
declare function resolveBedrockCredentials(options: BedrockAdapterOptions): BedrockCredentials;
|
|
807
|
+
declare function buildBedrockInvokeModelRequestBody(input: AnthropicRequestInput): BedrockInvokeModelRequestBody;
|
|
808
|
+
|
|
809
|
+
export { type AnthropicAdapterOptions, type AnthropicBatchApiRequest, type AnthropicBatchApiRequestMessage, type AnthropicBatchApiRequestParams, type AnthropicBatchCanceledOutcome, type AnthropicBatchClient, type AnthropicBatchClientOptions, type AnthropicBatchErroredOutcome, type AnthropicBatchExpiredOutcome, type AnthropicBatchMessageRequest, type AnthropicBatchPromptCachingMode, type AnthropicBatchResult, type AnthropicBatchResultOutcome, type AnthropicBatchSubmittedRequestSummary, type AnthropicBatchSucceededOutcome, type AnthropicBatchSystemContentBlock, type AnthropicBatchTraceEventHandler, type AnthropicBatchWaitOptions, type AnthropicCacheControl, type AnthropicCacheTtl, type AnthropicMessageBatch, type AnthropicMessageBatchProcessingStatus, type AnthropicMessageBatchRequestCounts, type AnthropicMessagesResponse, AnthropicMessagesResponseSchema, type AnthropicOutputConfig, type AnthropicPromptCachingMode, type AnthropicPromptCachingOptions, type AnthropicPromptCachingSettings, type AnthropicRequestBody, type AnthropicRequestContentBlock, type AnthropicRequestInput, type AnthropicRequestMessage, type AnthropicRequestSettings, type AnthropicStreamEvent, AnthropicStreamEventSchema, type AnthropicStreamRequestInput, type AnthropicStreamStartUsage, type AnthropicSystemContentBlock, type AnthropicThinkingOptions, type AnthropicToolChoice, type AnthropicToolDefinition, type AnthropicUsage, type AwsCredentials, type AwsSigV4SigningInput, type AzureOpenAiAdapterOptions, type AzureOpenAiChatCompletionResponse, AzureOpenAiChatCompletionResponseSchema, type AzureOpenAiChatRequestBody, type AzureOpenAiStreamRequestBody, type AzureOpenAiStreamRequestInput, type AzureOpenAiUsage, type BedrockAdapterOptions, type BedrockCredentials, type BedrockInvokeModelRequestBody, type ChatCompletionRequest, type ChatCompletionResult, type ChatMessage, type ChatMessageCacheControl, ChatMessageCacheControlSchema, type ChatMessageRole, ChatMessageRoleSchema, ChatMessageSchema, type ChatStopReason, ChatStopReasonSchema, type ChatStreamEvent, type GeminiAdapterOptions, type MessageContentBlock, MessageContentBlockSchema, type MockModelOptions, type ModelAdapter, type ModelPricingUsdPerMillionTokens, type ModelToolCall, ModelToolCallSchema, type ModelToolChoice, type ModelToolDefinition, type OpenAiAdapterOptions, type OpenAiCallInput, type OpenAiContentPart, type OpenAiRequestBody, type OpenAiRequestMessage, type OpenAiRequestToolCall, type OpenAiResponseFormat, type OpenAiStructuredOutputMode, type OpenAiToolChoice, type OpenAiToolDefinition, type ProviderExtraBody, type ProviderRetryOptions, type ResolveProviderApiKeyInput, type StructuredOutputRequest, type StructuredOutputResult, anthropic, anthropicBatchJsonOnlySystemInstruction, anthropicBatchTraceWorkflowName, applyCacheControlToLastContentBlock, awsSigV4Algorithm, azureOpenai, bedrock, bedrockAnthropicVersion, buildAnthropicCacheControl, buildAnthropicRequestBody, buildAnthropicStructuredOutputJsonSchema, buildAzureOpenAiChatCompletionsUrl, buildAzureOpenAiChatRequestBody, buildBedrockInvokeModelRequestBody, buildBedrockInvokeModelUrl, buildGeminiResponseSchema, buildOpenAiRequestBody, buildOpenAiStructuredOutputJsonSchema, buildProviderCanceledError, calculateProviderRetryDelayMs, convertZodSchemaToJsonSchema, createAnthropicBatchClient, defaultAnthropicBaseUrl, defaultAnthropicBatchPollIntervalMs, defaultAnthropicBatchTimeoutMs, defaultAnthropicMaxOutputTokens, defaultAzureOpenAiApiVersion, defaultBedrockMaxOutputTokens, defaultGeminiBaseUrl, defaultOpenAiBaseUrl, defaultProviderRetryInitialDelayMs, defaultProviderRetryMaxAttempts, defaultProviderRetryMaxDelayMs, estimateModelCallCostUsd, executeAbortableProviderFetch, executeProviderCallWithModelFallback, executeProviderCallWithRetry, extractAnthropicTextContent, extractAnthropicThinkingText, extractAnthropicToolCalls, extractMessageText, gemini, isAbortError, isOpenAiReasoningModel, isRetryableProviderAppError, isZodV4Schema, joinSystemMessageText, mapAnthropicResponseToChatCompletionResult, mapAnthropicUsageToTokenUsage, mapAzureOpenAiResponseToChatCompletionResult, mapAzureOpenAiUsageToTokenUsage, mapChatMessageToAnthropicRequestMessage, mapChatMessageToOpenAiRequestMessage, mapModelToolChoiceToAnthropicToolChoice, mapModelToolChoiceToOpenAiToolChoice, mapModelToolDefinitionToOpenAiTool, mapModelToolDefinitionsToAnthropicTools, mergeProviderRequestExtraBody, mockModel, normalizeAnthropicStopReason, normalizeAzureOpenAiFinishReason, openAiStructuredOutputSchemaName, openai, parseAnthropicBatchStructuredContent, parseAnthropicStreamEvents, parseAnthropicToolInputJson, parseAzureOpenAiStreamEvents, parseAzureOpenAiToolArgumentsJson, prependStructuredOutputJsonOnlySystemMessage, resolveAnthropicPromptCachingSettings, resolveBedrockCredentials, resolveOpenAiStructuredOutputMode, resolveProviderApiKey, sanitizeJsonSchemaForAnthropicStructuredOutput, sanitizeJsonSchemaForGeminiResponseSchema, sanitizeJsonSchemaForOpenAiStructuredOutput, signAwsRequestWithSigV4, streamAnthropicChatCompletion, streamAzureOpenAiChatCompletion, structuredOutputJsonOnlySystemInstruction, structuredOutputJsonOnlySystemMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { JsonValue } from '@assemble-dev/shared-types/json';
|
|
2
|
+
import { JsonValue, JsonObject } from '@assemble-dev/shared-types/json';
|
|
3
3
|
import { TokenUsage } from '@assemble-dev/shared-types/runs';
|
|
4
4
|
import { AppError } from '@assemble-dev/shared-utils/errors';
|
|
5
5
|
import * as _assemble_dev_shared_types from '@assemble-dev/shared-types';
|
|
@@ -104,10 +104,14 @@ type ChatCompletionResult = {
|
|
|
104
104
|
latencyMs: number;
|
|
105
105
|
toolCalls?: ModelToolCall[];
|
|
106
106
|
stopReason?: ChatStopReason;
|
|
107
|
+
thinkingText?: string;
|
|
107
108
|
};
|
|
108
109
|
type ChatStreamEvent = {
|
|
109
110
|
type: "text_delta";
|
|
110
111
|
text: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: "thinking_delta";
|
|
114
|
+
text: string;
|
|
111
115
|
} | {
|
|
112
116
|
type: "tool_call_started";
|
|
113
117
|
id: string;
|
|
@@ -227,6 +231,12 @@ type AnthropicToolChoice = {
|
|
|
227
231
|
type: "tool";
|
|
228
232
|
name: string;
|
|
229
233
|
};
|
|
234
|
+
type AnthropicOutputConfig = {
|
|
235
|
+
format: {
|
|
236
|
+
type: "json_schema";
|
|
237
|
+
schema: JsonObject;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
230
240
|
type AnthropicRequestBody = {
|
|
231
241
|
model: string;
|
|
232
242
|
max_tokens: number;
|
|
@@ -239,6 +249,7 @@ type AnthropicRequestBody = {
|
|
|
239
249
|
};
|
|
240
250
|
tools?: AnthropicToolDefinition[];
|
|
241
251
|
tool_choice?: AnthropicToolChoice;
|
|
252
|
+
output_config?: AnthropicOutputConfig;
|
|
242
253
|
stream?: true;
|
|
243
254
|
};
|
|
244
255
|
type AnthropicRequestInput = {
|
|
@@ -247,6 +258,7 @@ type AnthropicRequestInput = {
|
|
|
247
258
|
maxOutputTokens?: number;
|
|
248
259
|
tools?: ModelToolDefinition[];
|
|
249
260
|
toolChoice?: ModelToolChoice;
|
|
261
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
250
262
|
abortSignal?: AbortSignal;
|
|
251
263
|
extraBody?: Record<string, JsonValue>;
|
|
252
264
|
};
|
|
@@ -344,6 +356,21 @@ declare function isAbortError(error: Error): boolean;
|
|
|
344
356
|
declare function buildProviderCanceledError(providerLabel: string): AppError;
|
|
345
357
|
declare function executeAbortableProviderFetch(providerLabel: string, performFetch: () => Promise<Response>): Promise<Response>;
|
|
346
358
|
|
|
359
|
+
declare const openAiStructuredOutputSchemaName = "structured_output";
|
|
360
|
+
declare function isZodV4Schema<T>(schema: z.ZodType<T>): boolean;
|
|
361
|
+
declare function convertZodSchemaToJsonSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
362
|
+
declare function buildAnthropicStructuredOutputJsonSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
363
|
+
declare function sanitizeJsonSchemaForAnthropicStructuredOutput(jsonSchema: JsonObject): JsonObject;
|
|
364
|
+
declare function buildOpenAiStructuredOutputJsonSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
365
|
+
declare function sanitizeJsonSchemaForOpenAiStructuredOutput(jsonSchema: JsonObject): JsonObject;
|
|
366
|
+
|
|
367
|
+
declare const structuredOutputJsonOnlySystemInstruction = "Respond with a single JSON object that satisfies the caller's requested structure. Output only valid JSON with no surrounding text.";
|
|
368
|
+
declare const structuredOutputJsonOnlySystemMessage: ChatMessage;
|
|
369
|
+
declare function prependStructuredOutputJsonOnlySystemMessage(messages: ChatMessage[]): ChatMessage[];
|
|
370
|
+
|
|
371
|
+
declare function buildGeminiResponseSchema<T>(schema: z.ZodType<T>): JsonObject;
|
|
372
|
+
declare function sanitizeJsonSchemaForGeminiResponseSchema(jsonSchema: JsonObject): JsonObject;
|
|
373
|
+
|
|
347
374
|
declare const AnthropicUsageSchema: z.ZodObject<{
|
|
348
375
|
input_tokens: z.ZodNumber;
|
|
349
376
|
output_tokens: z.ZodNumber;
|
|
@@ -379,6 +406,7 @@ declare const AnthropicMessagesResponseSchema: z.ZodObject<{
|
|
|
379
406
|
type AnthropicMessagesResponse = z.infer<typeof AnthropicMessagesResponseSchema>;
|
|
380
407
|
declare function mapAnthropicResponseToChatCompletionResult(response: AnthropicMessagesResponse, latencyMs: number): ChatCompletionResult;
|
|
381
408
|
declare function extractAnthropicToolCalls(response: AnthropicMessagesResponse): ModelToolCall[];
|
|
409
|
+
declare function extractAnthropicThinkingText(response: AnthropicMessagesResponse): string;
|
|
382
410
|
declare function extractAnthropicTextContent(response: AnthropicMessagesResponse, allowEmptyText: boolean): string;
|
|
383
411
|
declare function normalizeAnthropicStopReason(providerStopReason: string): ChatStopReason;
|
|
384
412
|
declare function mapAnthropicUsageToTokenUsage(usage: AnthropicUsage): TokenUsage;
|
|
@@ -411,6 +439,12 @@ declare const AnthropicStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
411
439
|
content_block: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
412
440
|
type: z.ZodLiteral<"text">;
|
|
413
441
|
text: z.ZodOptional<z.ZodString>;
|
|
442
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
443
|
+
type: z.ZodLiteral<"thinking">;
|
|
444
|
+
thinking: z.ZodOptional<z.ZodString>;
|
|
445
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
446
|
+
type: z.ZodLiteral<"redacted_thinking">;
|
|
447
|
+
data: z.ZodOptional<z.ZodString>;
|
|
414
448
|
}, z.core.$strip>, z.ZodObject<{
|
|
415
449
|
type: z.ZodLiteral<"tool_use">;
|
|
416
450
|
id: z.ZodString;
|
|
@@ -422,6 +456,12 @@ declare const AnthropicStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
422
456
|
delta: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
423
457
|
type: z.ZodLiteral<"text_delta">;
|
|
424
458
|
text: z.ZodString;
|
|
459
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
460
|
+
type: z.ZodLiteral<"thinking_delta">;
|
|
461
|
+
thinking: z.ZodString;
|
|
462
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
463
|
+
type: z.ZodLiteral<"signature_delta">;
|
|
464
|
+
signature: z.ZodString;
|
|
425
465
|
}, z.core.$strip>, z.ZodObject<{
|
|
426
466
|
type: z.ZodLiteral<"input_json_delta">;
|
|
427
467
|
partial_json: z.ZodString;
|
|
@@ -489,14 +529,23 @@ type OpenAiToolChoice = "auto" | "required" | "none" | {
|
|
|
489
529
|
name: string;
|
|
490
530
|
};
|
|
491
531
|
};
|
|
532
|
+
type OpenAiResponseFormat = {
|
|
533
|
+
type: "json_object";
|
|
534
|
+
} | {
|
|
535
|
+
type: "json_schema";
|
|
536
|
+
json_schema: {
|
|
537
|
+
name: string;
|
|
538
|
+
strict: true;
|
|
539
|
+
schema: JsonObject;
|
|
540
|
+
};
|
|
541
|
+
};
|
|
492
542
|
type OpenAiRequestBody = {
|
|
493
543
|
model: string;
|
|
494
544
|
messages: OpenAiRequestMessage[];
|
|
495
545
|
temperature?: number;
|
|
496
546
|
max_tokens?: number;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
};
|
|
547
|
+
max_completion_tokens?: number;
|
|
548
|
+
response_format?: OpenAiResponseFormat;
|
|
500
549
|
tools?: OpenAiToolDefinition[];
|
|
501
550
|
tool_choice?: OpenAiToolChoice;
|
|
502
551
|
};
|
|
@@ -504,12 +553,21 @@ type OpenAiCallInput = {
|
|
|
504
553
|
messages: ChatMessage[];
|
|
505
554
|
temperature?: number;
|
|
506
555
|
maxOutputTokens?: number;
|
|
507
|
-
|
|
556
|
+
reasoningModel?: boolean;
|
|
557
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
558
|
+
requireJsonObjectResponse?: boolean;
|
|
508
559
|
tools?: ModelToolDefinition[];
|
|
509
560
|
toolChoice?: ModelToolChoice;
|
|
510
561
|
abortSignal?: AbortSignal;
|
|
511
562
|
extraBody?: Record<string, JsonValue>;
|
|
512
563
|
};
|
|
564
|
+
type OpenAiStructuredOutputMode = {
|
|
565
|
+
messages: ChatMessage[];
|
|
566
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
567
|
+
requireJsonObjectResponse?: boolean;
|
|
568
|
+
};
|
|
569
|
+
declare function isOpenAiReasoningModel(model: string): boolean;
|
|
570
|
+
declare function resolveOpenAiStructuredOutputMode<T>(messages: ChatMessage[], schema: z.ZodType<T>): OpenAiStructuredOutputMode;
|
|
513
571
|
declare function buildOpenAiRequestBody(model: string, input: OpenAiCallInput): OpenAiRequestBody;
|
|
514
572
|
declare function mapModelToolDefinitionToOpenAiTool(tool: ModelToolDefinition): OpenAiToolDefinition;
|
|
515
573
|
declare function mapModelToolChoiceToOpenAiToolChoice(toolChoice: ModelToolChoice): OpenAiToolChoice;
|
|
@@ -524,6 +582,7 @@ type AnthropicBatchMessageRequest = {
|
|
|
524
582
|
temperature?: number;
|
|
525
583
|
promptCaching?: AnthropicBatchPromptCachingMode;
|
|
526
584
|
requireJsonResponse?: boolean;
|
|
585
|
+
structuredOutputJsonSchema?: JsonObject;
|
|
527
586
|
};
|
|
528
587
|
type AnthropicBatchApiRequestMessage = {
|
|
529
588
|
role: "user" | "assistant";
|
|
@@ -542,6 +601,7 @@ type AnthropicBatchApiRequestParams = {
|
|
|
542
601
|
messages: AnthropicBatchApiRequestMessage[];
|
|
543
602
|
system?: string | AnthropicBatchSystemContentBlock[];
|
|
544
603
|
temperature?: number;
|
|
604
|
+
output_config?: AnthropicOutputConfig;
|
|
545
605
|
};
|
|
546
606
|
type AnthropicBatchApiRequest = {
|
|
547
607
|
custom_id: string;
|
|
@@ -638,4 +698,112 @@ declare function createAnthropicBatchClient(options: AnthropicBatchClientOptions
|
|
|
638
698
|
declare const anthropicBatchJsonOnlySystemInstruction = "Respond with a single JSON object that satisfies the caller's requested structure. Output only valid JSON with no surrounding text.";
|
|
639
699
|
declare function parseAnthropicBatchStructuredContent<T>(content: string, schema: ValidationSchema<T>): T;
|
|
640
700
|
|
|
641
|
-
|
|
701
|
+
declare const defaultAzureOpenAiApiVersion = "2024-10-21";
|
|
702
|
+
type AzureOpenAiAdapterOptions = {
|
|
703
|
+
deployment: string;
|
|
704
|
+
resourceName?: string;
|
|
705
|
+
baseURL?: string;
|
|
706
|
+
apiVersion?: string;
|
|
707
|
+
apiKey?: string;
|
|
708
|
+
apiKeyName?: string;
|
|
709
|
+
fetchImplementation?: typeof fetch;
|
|
710
|
+
temperature?: number;
|
|
711
|
+
maxOutputTokens?: number;
|
|
712
|
+
reasoningModel?: boolean;
|
|
713
|
+
retry?: ProviderRetryOptions;
|
|
714
|
+
extraBody?: Record<string, JsonValue>;
|
|
715
|
+
};
|
|
716
|
+
type AzureOpenAiChatRequestBody = Omit<OpenAiRequestBody, "model">;
|
|
717
|
+
declare function azureOpenai(options: AzureOpenAiAdapterOptions): ModelAdapter;
|
|
718
|
+
declare function buildAzureOpenAiChatCompletionsUrl(options: AzureOpenAiAdapterOptions): string;
|
|
719
|
+
declare function buildAzureOpenAiChatRequestBody(input: OpenAiCallInput): AzureOpenAiChatRequestBody;
|
|
720
|
+
|
|
721
|
+
declare const AzureOpenAiUsageSchema: z.ZodObject<{
|
|
722
|
+
prompt_tokens: z.ZodNumber;
|
|
723
|
+
completion_tokens: z.ZodNumber;
|
|
724
|
+
total_tokens: z.ZodNumber;
|
|
725
|
+
}, z.core.$strip>;
|
|
726
|
+
type AzureOpenAiUsage = z.infer<typeof AzureOpenAiUsageSchema>;
|
|
727
|
+
declare const AzureOpenAiChatCompletionResponseSchema: z.ZodObject<{
|
|
728
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
729
|
+
message: z.ZodObject<{
|
|
730
|
+
content: z.ZodNullable<z.ZodString>;
|
|
731
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
732
|
+
id: z.ZodString;
|
|
733
|
+
function: z.ZodObject<{
|
|
734
|
+
name: z.ZodString;
|
|
735
|
+
arguments: z.ZodString;
|
|
736
|
+
}, z.core.$strip>;
|
|
737
|
+
}, z.core.$strip>>>;
|
|
738
|
+
}, z.core.$strip>;
|
|
739
|
+
finish_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
740
|
+
}, z.core.$strip>>;
|
|
741
|
+
usage: z.ZodObject<{
|
|
742
|
+
prompt_tokens: z.ZodNumber;
|
|
743
|
+
completion_tokens: z.ZodNumber;
|
|
744
|
+
total_tokens: z.ZodNumber;
|
|
745
|
+
}, z.core.$strip>;
|
|
746
|
+
}, z.core.$strip>;
|
|
747
|
+
type AzureOpenAiChatCompletionResponse = z.infer<typeof AzureOpenAiChatCompletionResponseSchema>;
|
|
748
|
+
declare function mapAzureOpenAiResponseToChatCompletionResult(response: AzureOpenAiChatCompletionResponse, latencyMs: number): ChatCompletionResult;
|
|
749
|
+
declare function parseAzureOpenAiToolArgumentsJson(argumentsJsonText: string): JsonValue;
|
|
750
|
+
declare function normalizeAzureOpenAiFinishReason(finishReason: string): ChatStopReason;
|
|
751
|
+
declare function mapAzureOpenAiUsageToTokenUsage(usage: AzureOpenAiUsage): TokenUsage;
|
|
752
|
+
|
|
753
|
+
type AzureOpenAiStreamRequestBody = Omit<OpenAiRequestBody, "model"> & {
|
|
754
|
+
stream: true;
|
|
755
|
+
stream_options: {
|
|
756
|
+
include_usage: boolean;
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
type AzureOpenAiStreamRequestInput = {
|
|
760
|
+
url: string;
|
|
761
|
+
headers: Record<string, string>;
|
|
762
|
+
body: AzureOpenAiStreamRequestBody;
|
|
763
|
+
fetchImplementation: typeof fetch;
|
|
764
|
+
retry?: ProviderRetryOptions;
|
|
765
|
+
abortSignal?: AbortSignal;
|
|
766
|
+
};
|
|
767
|
+
declare function streamAzureOpenAiChatCompletion(input: AzureOpenAiStreamRequestInput): AsyncGenerator<ChatStreamEvent, void, void>;
|
|
768
|
+
declare function parseAzureOpenAiStreamEvents(body: ReadableStream<Uint8Array>, startedAt: number, abortSignal: AbortSignal | undefined): AsyncGenerator<ChatStreamEvent, void, void>;
|
|
769
|
+
|
|
770
|
+
declare const awsSigV4Algorithm = "AWS4-HMAC-SHA256";
|
|
771
|
+
type AwsCredentials = {
|
|
772
|
+
accessKeyId: string;
|
|
773
|
+
secretAccessKey: string;
|
|
774
|
+
sessionToken?: string;
|
|
775
|
+
};
|
|
776
|
+
type AwsSigV4SigningInput = {
|
|
777
|
+
method: string;
|
|
778
|
+
url: URL;
|
|
779
|
+
headers: Record<string, string>;
|
|
780
|
+
bodyText: string;
|
|
781
|
+
region: string;
|
|
782
|
+
service: string;
|
|
783
|
+
credentials: AwsCredentials;
|
|
784
|
+
signingDate?: Date;
|
|
785
|
+
};
|
|
786
|
+
declare function signAwsRequestWithSigV4(input: AwsSigV4SigningInput): Promise<Record<string, string>>;
|
|
787
|
+
|
|
788
|
+
declare const bedrockAnthropicVersion = "bedrock-2023-05-31";
|
|
789
|
+
declare const defaultBedrockMaxOutputTokens = 1024;
|
|
790
|
+
type BedrockCredentials = AwsCredentials;
|
|
791
|
+
type BedrockAdapterOptions = {
|
|
792
|
+
region: string;
|
|
793
|
+
modelId: string;
|
|
794
|
+
credentials?: BedrockCredentials;
|
|
795
|
+
fetchImplementation?: typeof fetch;
|
|
796
|
+
temperature?: number;
|
|
797
|
+
maxOutputTokens?: number;
|
|
798
|
+
retry?: ProviderRetryOptions;
|
|
799
|
+
extraBody?: Record<string, JsonValue>;
|
|
800
|
+
};
|
|
801
|
+
type BedrockInvokeModelRequestBody = Omit<AnthropicRequestBody, "model" | "stream"> & {
|
|
802
|
+
anthropic_version: string;
|
|
803
|
+
};
|
|
804
|
+
declare function bedrock(options: BedrockAdapterOptions): ModelAdapter;
|
|
805
|
+
declare function buildBedrockInvokeModelUrl(region: string, modelId: string): string;
|
|
806
|
+
declare function resolveBedrockCredentials(options: BedrockAdapterOptions): BedrockCredentials;
|
|
807
|
+
declare function buildBedrockInvokeModelRequestBody(input: AnthropicRequestInput): BedrockInvokeModelRequestBody;
|
|
808
|
+
|
|
809
|
+
export { type AnthropicAdapterOptions, type AnthropicBatchApiRequest, type AnthropicBatchApiRequestMessage, type AnthropicBatchApiRequestParams, type AnthropicBatchCanceledOutcome, type AnthropicBatchClient, type AnthropicBatchClientOptions, type AnthropicBatchErroredOutcome, type AnthropicBatchExpiredOutcome, type AnthropicBatchMessageRequest, type AnthropicBatchPromptCachingMode, type AnthropicBatchResult, type AnthropicBatchResultOutcome, type AnthropicBatchSubmittedRequestSummary, type AnthropicBatchSucceededOutcome, type AnthropicBatchSystemContentBlock, type AnthropicBatchTraceEventHandler, type AnthropicBatchWaitOptions, type AnthropicCacheControl, type AnthropicCacheTtl, type AnthropicMessageBatch, type AnthropicMessageBatchProcessingStatus, type AnthropicMessageBatchRequestCounts, type AnthropicMessagesResponse, AnthropicMessagesResponseSchema, type AnthropicOutputConfig, type AnthropicPromptCachingMode, type AnthropicPromptCachingOptions, type AnthropicPromptCachingSettings, type AnthropicRequestBody, type AnthropicRequestContentBlock, type AnthropicRequestInput, type AnthropicRequestMessage, type AnthropicRequestSettings, type AnthropicStreamEvent, AnthropicStreamEventSchema, type AnthropicStreamRequestInput, type AnthropicStreamStartUsage, type AnthropicSystemContentBlock, type AnthropicThinkingOptions, type AnthropicToolChoice, type AnthropicToolDefinition, type AnthropicUsage, type AwsCredentials, type AwsSigV4SigningInput, type AzureOpenAiAdapterOptions, type AzureOpenAiChatCompletionResponse, AzureOpenAiChatCompletionResponseSchema, type AzureOpenAiChatRequestBody, type AzureOpenAiStreamRequestBody, type AzureOpenAiStreamRequestInput, type AzureOpenAiUsage, type BedrockAdapterOptions, type BedrockCredentials, type BedrockInvokeModelRequestBody, type ChatCompletionRequest, type ChatCompletionResult, type ChatMessage, type ChatMessageCacheControl, ChatMessageCacheControlSchema, type ChatMessageRole, ChatMessageRoleSchema, ChatMessageSchema, type ChatStopReason, ChatStopReasonSchema, type ChatStreamEvent, type GeminiAdapterOptions, type MessageContentBlock, MessageContentBlockSchema, type MockModelOptions, type ModelAdapter, type ModelPricingUsdPerMillionTokens, type ModelToolCall, ModelToolCallSchema, type ModelToolChoice, type ModelToolDefinition, type OpenAiAdapterOptions, type OpenAiCallInput, type OpenAiContentPart, type OpenAiRequestBody, type OpenAiRequestMessage, type OpenAiRequestToolCall, type OpenAiResponseFormat, type OpenAiStructuredOutputMode, type OpenAiToolChoice, type OpenAiToolDefinition, type ProviderExtraBody, type ProviderRetryOptions, type ResolveProviderApiKeyInput, type StructuredOutputRequest, type StructuredOutputResult, anthropic, anthropicBatchJsonOnlySystemInstruction, anthropicBatchTraceWorkflowName, applyCacheControlToLastContentBlock, awsSigV4Algorithm, azureOpenai, bedrock, bedrockAnthropicVersion, buildAnthropicCacheControl, buildAnthropicRequestBody, buildAnthropicStructuredOutputJsonSchema, buildAzureOpenAiChatCompletionsUrl, buildAzureOpenAiChatRequestBody, buildBedrockInvokeModelRequestBody, buildBedrockInvokeModelUrl, buildGeminiResponseSchema, buildOpenAiRequestBody, buildOpenAiStructuredOutputJsonSchema, buildProviderCanceledError, calculateProviderRetryDelayMs, convertZodSchemaToJsonSchema, createAnthropicBatchClient, defaultAnthropicBaseUrl, defaultAnthropicBatchPollIntervalMs, defaultAnthropicBatchTimeoutMs, defaultAnthropicMaxOutputTokens, defaultAzureOpenAiApiVersion, defaultBedrockMaxOutputTokens, defaultGeminiBaseUrl, defaultOpenAiBaseUrl, defaultProviderRetryInitialDelayMs, defaultProviderRetryMaxAttempts, defaultProviderRetryMaxDelayMs, estimateModelCallCostUsd, executeAbortableProviderFetch, executeProviderCallWithModelFallback, executeProviderCallWithRetry, extractAnthropicTextContent, extractAnthropicThinkingText, extractAnthropicToolCalls, extractMessageText, gemini, isAbortError, isOpenAiReasoningModel, isRetryableProviderAppError, isZodV4Schema, joinSystemMessageText, mapAnthropicResponseToChatCompletionResult, mapAnthropicUsageToTokenUsage, mapAzureOpenAiResponseToChatCompletionResult, mapAzureOpenAiUsageToTokenUsage, mapChatMessageToAnthropicRequestMessage, mapChatMessageToOpenAiRequestMessage, mapModelToolChoiceToAnthropicToolChoice, mapModelToolChoiceToOpenAiToolChoice, mapModelToolDefinitionToOpenAiTool, mapModelToolDefinitionsToAnthropicTools, mergeProviderRequestExtraBody, mockModel, normalizeAnthropicStopReason, normalizeAzureOpenAiFinishReason, openAiStructuredOutputSchemaName, openai, parseAnthropicBatchStructuredContent, parseAnthropicStreamEvents, parseAnthropicToolInputJson, parseAzureOpenAiStreamEvents, parseAzureOpenAiToolArgumentsJson, prependStructuredOutputJsonOnlySystemMessage, resolveAnthropicPromptCachingSettings, resolveBedrockCredentials, resolveOpenAiStructuredOutputMode, resolveProviderApiKey, sanitizeJsonSchemaForAnthropicStructuredOutput, sanitizeJsonSchemaForGeminiResponseSchema, sanitizeJsonSchemaForOpenAiStructuredOutput, signAwsRequestWithSigV4, streamAnthropicChatCompletion, streamAzureOpenAiChatCompletion, structuredOutputJsonOnlySystemInstruction, structuredOutputJsonOnlySystemMessage };
|