@yourgpt/llm-sdk 2.1.4-alpha.2 → 2.1.5

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.
Files changed (49) hide show
  1. package/dist/adapters/index.d.mts +3 -2
  2. package/dist/adapters/index.d.ts +3 -2
  3. package/dist/{types-DoZX2k3v.d.mts → base-5n-UuPfS.d.mts} +1 -353
  4. package/dist/{types-DtPQaoJi.d.ts → base-Di31iy_8.d.ts} +1 -353
  5. package/dist/fallback/index.d.mts +96 -0
  6. package/dist/fallback/index.d.ts +96 -0
  7. package/dist/fallback/index.js +284 -0
  8. package/dist/fallback/index.mjs +280 -0
  9. package/dist/index.d.mts +5 -2
  10. package/dist/index.d.ts +5 -2
  11. package/dist/providers/anthropic/index.d.mts +2 -1
  12. package/dist/providers/anthropic/index.d.ts +2 -1
  13. package/dist/providers/azure/index.d.mts +2 -1
  14. package/dist/providers/azure/index.d.ts +2 -1
  15. package/dist/providers/google/index.d.mts +2 -1
  16. package/dist/providers/google/index.d.ts +2 -1
  17. package/dist/providers/ollama/index.d.mts +3 -2
  18. package/dist/providers/ollama/index.d.ts +3 -2
  19. package/dist/providers/openai/index.d.mts +2 -1
  20. package/dist/providers/openai/index.d.ts +2 -1
  21. package/dist/providers/openrouter/index.d.mts +2 -1
  22. package/dist/providers/openrouter/index.d.ts +2 -1
  23. package/dist/providers/xai/index.d.mts +2 -1
  24. package/dist/providers/xai/index.d.ts +2 -1
  25. package/dist/types-BQl1suAv.d.mts +212 -0
  26. package/dist/types-C0vLXzuw.d.ts +355 -0
  27. package/dist/types-CNL8ZRne.d.ts +212 -0
  28. package/dist/types-VDgiUvH2.d.mts +355 -0
  29. package/package.json +7 -1
  30. package/dist/adapters/index.js.map +0 -1
  31. package/dist/adapters/index.mjs.map +0 -1
  32. package/dist/index.js.map +0 -1
  33. package/dist/index.mjs.map +0 -1
  34. package/dist/providers/anthropic/index.js.map +0 -1
  35. package/dist/providers/anthropic/index.mjs.map +0 -1
  36. package/dist/providers/azure/index.js.map +0 -1
  37. package/dist/providers/azure/index.mjs.map +0 -1
  38. package/dist/providers/google/index.js.map +0 -1
  39. package/dist/providers/google/index.mjs.map +0 -1
  40. package/dist/providers/ollama/index.js.map +0 -1
  41. package/dist/providers/ollama/index.mjs.map +0 -1
  42. package/dist/providers/openai/index.js.map +0 -1
  43. package/dist/providers/openai/index.mjs.map +0 -1
  44. package/dist/providers/openrouter/index.js.map +0 -1
  45. package/dist/providers/openrouter/index.mjs.map +0 -1
  46. package/dist/providers/xai/index.js.map +0 -1
  47. package/dist/providers/xai/index.mjs.map +0 -1
  48. package/dist/yourgpt/index.js.map +0 -1
  49. package/dist/yourgpt/index.mjs.map +0 -1
@@ -1,5 +1,6 @@
1
- import { L as LLMAdapter, W as WebSearchConfig, C as ChatCompletionRequest, S as StreamEvent, N as CompletionResult, k as OllamaModelOptions } from '../types-DoZX2k3v.mjs';
2
- export { f as AdapterFactory, a4 as AnthropicContentBlock, a5 as OpenAIContentBlock, a2 as attachmentToAnthropicDocument, a1 as attachmentToAnthropicImage, a3 as attachmentToOpenAIImage, Q as formatMessages, V as formatMessagesForAnthropic, Y as formatMessagesForOpenAI, R as formatTools, $ as hasImageAttachments, a0 as hasMediaAttachments, Z as messageToAnthropicContent, _ as messageToOpenAIContent } from '../types-DoZX2k3v.mjs';
1
+ import { L as LLMAdapter, W as WebSearchConfig, C as ChatCompletionRequest, S as StreamEvent, o as CompletionResult } from '../base-5n-UuPfS.mjs';
2
+ export { e as AdapterFactory, B as AnthropicContentBlock, E as OpenAIContentBlock, y as attachmentToAnthropicDocument, x as attachmentToAnthropicImage, z as attachmentToOpenAIImage, p as formatMessages, r as formatMessagesForAnthropic, s as formatMessagesForOpenAI, q as formatTools, v as hasImageAttachments, w as hasMediaAttachments, t as messageToAnthropicContent, u as messageToOpenAIContent } from '../base-5n-UuPfS.mjs';
3
+ import { d as OllamaModelOptions } from '../types-VDgiUvH2.mjs';
3
4
  import '../types-CR8mi9I0.mjs';
4
5
  import 'zod';
5
6
 
@@ -1,5 +1,6 @@
1
- import { L as LLMAdapter, W as WebSearchConfig, C as ChatCompletionRequest, S as StreamEvent, N as CompletionResult, k as OllamaModelOptions } from '../types-DtPQaoJi.js';
2
- export { f as AdapterFactory, a4 as AnthropicContentBlock, a5 as OpenAIContentBlock, a2 as attachmentToAnthropicDocument, a1 as attachmentToAnthropicImage, a3 as attachmentToOpenAIImage, Q as formatMessages, V as formatMessagesForAnthropic, Y as formatMessagesForOpenAI, R as formatTools, $ as hasImageAttachments, a0 as hasMediaAttachments, Z as messageToAnthropicContent, _ as messageToOpenAIContent } from '../types-DtPQaoJi.js';
1
+ import { L as LLMAdapter, W as WebSearchConfig, C as ChatCompletionRequest, S as StreamEvent, o as CompletionResult } from '../base-Di31iy_8.js';
2
+ export { e as AdapterFactory, B as AnthropicContentBlock, E as OpenAIContentBlock, y as attachmentToAnthropicDocument, x as attachmentToAnthropicImage, z as attachmentToOpenAIImage, p as formatMessages, r as formatMessagesForAnthropic, s as formatMessagesForOpenAI, q as formatTools, v as hasImageAttachments, w as hasMediaAttachments, t as messageToAnthropicContent, u as messageToOpenAIContent } from '../base-Di31iy_8.js';
3
+ import { d as OllamaModelOptions } from '../types-C0vLXzuw.js';
3
4
  import '../types-CR8mi9I0.js';
4
5
  import 'zod';
5
6
 
@@ -765,356 +765,4 @@ type OpenAIMessage = {
765
765
  */
766
766
  declare function formatMessagesForOpenAI(messages: Message[], systemPrompt?: string): OpenAIMessage[];
767
767
 
768
- /**
769
- * Provider Types
770
- *
771
- * Defines interfaces for:
772
- * 1. Provider Formatters (for tool transformations in agent loop)
773
- * 2. Multi-provider architecture (AIProvider, capabilities, configs)
774
- */
775
-
776
- /**
777
- * Provider formatter interface
778
- *
779
- * Each provider implements this interface to handle:
780
- * - Tool definition transformation
781
- * - Tool call parsing from responses
782
- * - Tool result formatting
783
- * - Stop reason detection
784
- */
785
- interface ProviderFormatter {
786
- /**
787
- * Transform unified tool definitions to provider format
788
- */
789
- transformTools(tools: ToolDefinition[]): unknown[];
790
- /**
791
- * Parse tool calls from provider response
792
- */
793
- parseToolCalls(response: unknown): UnifiedToolCall[];
794
- /**
795
- * Format tool results for provider
796
- */
797
- formatToolResults(results: UnifiedToolResult[]): unknown[];
798
- /**
799
- * Check if response indicates tool use is requested
800
- */
801
- isToolUseStop(response: unknown): boolean;
802
- /**
803
- * Check if response indicates end of turn
804
- */
805
- isEndTurnStop(response: unknown): boolean;
806
- /**
807
- * Get stop reason string from response
808
- */
809
- getStopReason(response: unknown): string;
810
- /**
811
- * Extract text content from response
812
- */
813
- extractTextContent(response: unknown): string;
814
- /**
815
- * Build assistant message with tool calls for conversation history
816
- */
817
- buildAssistantToolMessage(toolCalls: UnifiedToolCall[], textContent?: string): unknown;
818
- /**
819
- * Build user message with tool results for conversation history
820
- */
821
- buildToolResultMessage(results: UnifiedToolResult[]): unknown;
822
- }
823
- /**
824
- * Anthropic tool definition format
825
- */
826
- interface AnthropicTool {
827
- name: string;
828
- description: string;
829
- input_schema: {
830
- type: "object";
831
- properties: Record<string, unknown>;
832
- required?: string[];
833
- };
834
- }
835
- /**
836
- * Anthropic tool_use block from response
837
- */
838
- interface AnthropicToolUse {
839
- type: "tool_use";
840
- id: string;
841
- name: string;
842
- input: Record<string, unknown>;
843
- }
844
- /**
845
- * Anthropic tool_result block
846
- */
847
- interface AnthropicToolResult {
848
- type: "tool_result";
849
- tool_use_id: string;
850
- content: string;
851
- }
852
- /**
853
- * OpenAI tool definition format
854
- */
855
- interface OpenAITool {
856
- type: "function";
857
- function: {
858
- name: string;
859
- description: string;
860
- parameters: {
861
- type: "object";
862
- properties: Record<string, unknown>;
863
- required?: string[];
864
- };
865
- };
866
- }
867
- /**
868
- * OpenAI tool call from response
869
- */
870
- interface OpenAIToolCall {
871
- id: string;
872
- type: "function";
873
- function: {
874
- name: string;
875
- arguments: string;
876
- };
877
- }
878
- /**
879
- * OpenAI tool result message
880
- */
881
- interface OpenAIToolResult {
882
- role: "tool";
883
- tool_call_id: string;
884
- content: string;
885
- }
886
- /**
887
- * Google Gemini function declaration
888
- */
889
- interface GeminiFunctionDeclaration {
890
- name: string;
891
- description: string;
892
- parameters?: {
893
- type: "object";
894
- properties: Record<string, unknown>;
895
- required?: string[];
896
- };
897
- }
898
- /**
899
- * Gemini function call from response
900
- */
901
- interface GeminiFunctionCall {
902
- name: string;
903
- args: Record<string, unknown>;
904
- }
905
- /**
906
- * Gemini function response
907
- */
908
- interface GeminiFunctionResponse {
909
- name: string;
910
- response: Record<string, unknown>;
911
- }
912
- /**
913
- * Capabilities of a model for UI feature flags
914
- * UI components can use this to enable/disable features
915
- */
916
- interface ProviderCapabilities {
917
- /** Supports image inputs */
918
- supportsVision: boolean;
919
- /** Supports tool/function calling */
920
- supportsTools: boolean;
921
- /** Supports extended thinking (Claude, DeepSeek) */
922
- supportsThinking: boolean;
923
- /** Supports streaming responses */
924
- supportsStreaming: boolean;
925
- /** Supports PDF document inputs */
926
- supportsPDF: boolean;
927
- /** Supports audio inputs */
928
- supportsAudio: boolean;
929
- /** Supports video inputs */
930
- supportsVideo: boolean;
931
- /** Maximum context tokens */
932
- maxTokens: number;
933
- /** Supported image MIME types */
934
- supportedImageTypes: string[];
935
- /** Supported audio MIME types */
936
- supportedAudioTypes?: string[];
937
- /** Supported video MIME types */
938
- supportedVideoTypes?: string[];
939
- /** Supports JSON mode / structured output */
940
- supportsJsonMode?: boolean;
941
- /** Supports system messages */
942
- supportsSystemMessages?: boolean;
943
- }
944
- /**
945
- * AI Provider interface (object form)
946
- *
947
- * Wraps existing LLMAdapter with additional metadata:
948
- * - Supported models list
949
- * - Per-model capabilities
950
- * - Provider name
951
- */
952
- interface AIProviderObject {
953
- /** Provider name (e.g., 'openai', 'anthropic') */
954
- readonly name: string;
955
- /** List of supported model IDs */
956
- readonly supportedModels: string[];
957
- /**
958
- * Get a language model adapter for the given model ID
959
- * Returns the existing LLMAdapter interface - no breaking changes
960
- */
961
- languageModel(modelId: string): LLMAdapter;
962
- /**
963
- * Get capabilities for a specific model
964
- * UI components use this to enable/disable features
965
- */
966
- getCapabilities(modelId: string): ProviderCapabilities;
967
- /**
968
- * Optional: Get an embedding model (future expansion)
969
- */
970
- embeddingModel?(modelId: string): EmbeddingModel;
971
- }
972
- /**
973
- * Callable AI Provider (Vercel AI SDK style)
974
- *
975
- * A function that returns a LanguageModel when called with a model ID,
976
- * but also has properties for provider metadata and methods.
977
- *
978
- * @example
979
- * ```typescript
980
- * const openai = createOpenAI({ apiKey: '...' });
981
- *
982
- * // Callable - returns LanguageModel directly (Vercel AI SDK style)
983
- * const model = openai('gpt-4o');
984
- *
985
- * // Also supports method calls (backward compatible)
986
- * const model2 = openai.languageModel('gpt-4o');
987
- *
988
- * // Check capabilities
989
- * const caps = openai.getCapabilities('gpt-4o');
990
- * if (caps.supportsVision) {
991
- * // Show image upload button
992
- * }
993
- * ```
994
- */
995
- interface AIProvider extends AIProviderObject {
996
- /**
997
- * Call the provider directly with a model ID to get a LanguageModel
998
- * This is the Vercel AI SDK style pattern
999
- */
1000
- (modelId: string): LLMAdapter;
1001
- }
1002
- /**
1003
- * Embedding model interface (for future expansion)
1004
- */
1005
- interface EmbeddingModel {
1006
- readonly provider: string;
1007
- readonly modelId: string;
1008
- embed(texts: string[]): Promise<number[][]>;
1009
- }
1010
- /**
1011
- * Base provider configuration
1012
- */
1013
- interface BaseProviderConfig {
1014
- /** API key (falls back to environment variable) */
1015
- apiKey?: string;
1016
- /** Custom base URL */
1017
- baseUrl?: string;
1018
- /** Request timeout in milliseconds */
1019
- timeout?: number;
1020
- /** Custom headers to include */
1021
- headers?: Record<string, string>;
1022
- }
1023
- /**
1024
- * OpenAI provider configuration
1025
- */
1026
- interface OpenAIProviderConfig extends BaseProviderConfig {
1027
- /** OpenAI organization ID */
1028
- organization?: string;
1029
- /** OpenAI project ID */
1030
- project?: string;
1031
- /** Vision detail level for images */
1032
- imageDetail?: "auto" | "low" | "high";
1033
- }
1034
- /**
1035
- * Anthropic provider configuration
1036
- */
1037
- interface AnthropicProviderConfig extends BaseProviderConfig {
1038
- /** Extended thinking budget in tokens (minimum 1024) */
1039
- thinkingBudget?: number;
1040
- /** Enable prompt caching */
1041
- cacheControl?: boolean;
1042
- }
1043
- /**
1044
- * Google provider configuration
1045
- */
1046
- interface GoogleProviderConfig extends BaseProviderConfig {
1047
- /** Safety settings */
1048
- safetySettings?: GoogleSafetySetting[];
1049
- /** Grounding configuration (for web search) */
1050
- groundingConfig?: GoogleGroundingConfig;
1051
- }
1052
- /**
1053
- * Google safety setting
1054
- */
1055
- interface GoogleSafetySetting {
1056
- category: "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT";
1057
- threshold: "BLOCK_NONE" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_HIGH_AND_ABOVE";
1058
- }
1059
- /**
1060
- * Google grounding configuration
1061
- */
1062
- interface GoogleGroundingConfig {
1063
- /** Enable Google Search grounding */
1064
- googleSearchRetrieval?: boolean;
1065
- }
1066
- /**
1067
- * xAI provider configuration
1068
- */
1069
- interface XAIProviderConfig extends BaseProviderConfig {
1070
- }
1071
- /**
1072
- * Azure OpenAI provider configuration
1073
- */
1074
- interface AzureProviderConfig extends BaseProviderConfig {
1075
- /** Azure resource name */
1076
- resourceName: string;
1077
- /** Deployment name */
1078
- deploymentName: string;
1079
- /** API version (default: 2024-02-15-preview) */
1080
- apiVersion?: string;
1081
- }
1082
- /**
1083
- * Ollama model-specific options
1084
- * These map to Ollama's native API options
1085
- */
1086
- interface OllamaModelOptions {
1087
- /** Context window size (default varies by model) */
1088
- num_ctx?: number;
1089
- /** Max tokens to predict (-1 = infinite, -2 = fill context) */
1090
- num_predict?: number;
1091
- /** Mirostat sampling (0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0) */
1092
- mirostat?: 0 | 1 | 2;
1093
- /** Mirostat learning rate (default: 0.1) */
1094
- mirostat_eta?: number;
1095
- /** Mirostat target entropy (default: 5.0) */
1096
- mirostat_tau?: number;
1097
- /** Repeat penalty (default: 1.1) */
1098
- repeat_penalty?: number;
1099
- /** Random seed for reproducibility (-1 = random) */
1100
- seed?: number;
1101
- /** Top-k sampling (default: 40) */
1102
- top_k?: number;
1103
- /** Top-p (nucleus) sampling (default: 0.9) */
1104
- top_p?: number;
1105
- /** Min-p sampling (default: 0.0) */
1106
- min_p?: number;
1107
- /** Stop sequences */
1108
- stop?: string[];
1109
- /** Temperature override (also available in config) */
1110
- temperature?: number;
1111
- }
1112
- /**
1113
- * Ollama provider configuration
1114
- */
1115
- interface OllamaProviderConfig extends BaseProviderConfig {
1116
- /** Default Ollama-specific model options */
1117
- options?: OllamaModelOptions;
1118
- }
1119
-
1120
- export { hasImageAttachments as $, type AIProvider as A, type BaseProviderConfig as B, type ChatCompletionRequest as C, type DoneEventMessage as D, type AnthropicToolSelectionHints as E, type ToolNativeProviderHints as F, type GoogleProviderConfig as G, type OpenAIProviderToolOptions as H, type AnthropicProviderToolOptions as I, type Citation as J, type KnowledgeBaseConfig as K, type LLMAdapter as L, type Message as M, type CompletionResult as N, type OpenAIProviderConfig as O, type ProviderToolRuntimeOptions as P, formatMessages as Q, formatTools as R, type StreamEvent as S, type ToolDefinition as T, type UnifiedToolCall as U, formatMessagesForAnthropic as V, type WebSearchConfig as W, type XAIProviderConfig as X, formatMessagesForOpenAI as Y, messageToAnthropicContent as Z, messageToOpenAIContent as _, type ActionDefinition as a, hasMediaAttachments as a0, attachmentToAnthropicImage as a1, attachmentToAnthropicDocument as a2, attachmentToOpenAIImage as a3, type AnthropicContentBlock as a4, type OpenAIContentBlock as a5, type ToolProfile as b, type ToolCallInfo as c, type TokenUsageRaw as d, type ToolResponse as e, type AdapterFactory as f, type ProviderCapabilities as g, type AnthropicProviderConfig as h, type AzureProviderConfig as i, type OllamaProviderConfig as j, type OllamaModelOptions as k, type ProviderFormatter as l, type AnthropicTool as m, type AnthropicToolUse as n, type AnthropicToolResult as o, type OpenAITool as p, type OpenAIToolCall as q, type OpenAIToolResult as r, type GeminiFunctionDeclaration as s, type GeminiFunctionCall as t, type GeminiFunctionResponse as u, type LLMConfig as v, type ToolLocation as w, type UnifiedToolResult as x, type ToolExecution as y, type OpenAIToolSelectionHints as z };
768
+ export { type ActionDefinition as A, type AnthropicContentBlock as B, type ChatCompletionRequest as C, type DoneEventMessage as D, type OpenAIContentBlock as E, type KnowledgeBaseConfig as K, type LLMAdapter as L, type Message as M, type OpenAIToolSelectionHints as O, type ProviderToolRuntimeOptions as P, type StreamEvent as S, type ToolDefinition as T, type UnifiedToolCall as U, type WebSearchConfig as W, type ToolProfile as a, type ToolCallInfo as b, type TokenUsageRaw as c, type ToolResponse as d, type AdapterFactory as e, type LLMConfig as f, type ToolLocation as g, type UnifiedToolResult as h, type ToolExecution as i, type AnthropicToolSelectionHints as j, type ToolNativeProviderHints as k, type OpenAIProviderToolOptions as l, type AnthropicProviderToolOptions as m, type Citation as n, type CompletionResult as o, formatMessages as p, formatTools as q, formatMessagesForAnthropic as r, formatMessagesForOpenAI as s, messageToAnthropicContent as t, messageToOpenAIContent as u, hasImageAttachments as v, hasMediaAttachments as w, attachmentToAnthropicImage as x, attachmentToAnthropicDocument as y, attachmentToOpenAIImage as z };