@yourgpt/llm-sdk 2.5.1-beta.1 → 2.5.1-beta.3
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/README.md +1 -19
- package/dist/adapters/index.d.mts +4 -4
- package/dist/adapters/index.d.ts +4 -4
- package/dist/adapters/index.js +15 -139
- package/dist/adapters/index.mjs +15 -139
- package/dist/{base-Cxq3ni0t.d.ts → base-C58Dsr9p.d.ts} +1 -5
- package/dist/{base-BYQKp9TW.d.mts → base-tNgbBaSo.d.mts} +1 -5
- package/dist/fallback/index.d.mts +4 -4
- package/dist/fallback/index.d.ts +4 -4
- package/dist/index.d.mts +8 -60
- package/dist/index.d.ts +8 -60
- package/dist/index.js +0 -59
- package/dist/index.mjs +0 -59
- package/dist/providers/anthropic/index.d.mts +3 -3
- package/dist/providers/anthropic/index.d.ts +3 -3
- package/dist/providers/anthropic/index.js +10 -91
- package/dist/providers/anthropic/index.mjs +10 -91
- package/dist/providers/azure/index.d.mts +3 -3
- package/dist/providers/azure/index.d.ts +3 -3
- package/dist/providers/azure/index.js +1 -0
- package/dist/providers/azure/index.mjs +1 -0
- package/dist/providers/fireworks/index.d.mts +67 -2
- package/dist/providers/fireworks/index.d.ts +67 -2
- package/dist/providers/fireworks/index.js +721 -1
- package/dist/providers/fireworks/index.mjs +719 -1
- package/dist/providers/google/index.d.mts +3 -3
- package/dist/providers/google/index.d.ts +3 -3
- package/dist/providers/google/index.js +4 -51
- package/dist/providers/google/index.mjs +4 -51
- package/dist/providers/ollama/index.d.mts +4 -4
- package/dist/providers/ollama/index.d.ts +4 -4
- package/dist/providers/ollama/index.js +1 -0
- package/dist/providers/ollama/index.mjs +1 -0
- package/dist/providers/openai/index.d.mts +3 -3
- package/dist/providers/openai/index.d.ts +3 -3
- package/dist/providers/openai/index.js +4 -51
- package/dist/providers/openai/index.mjs +4 -51
- package/dist/providers/openrouter/index.d.mts +3 -3
- package/dist/providers/openrouter/index.d.ts +3 -3
- package/dist/providers/openrouter/index.js +4 -51
- package/dist/providers/openrouter/index.mjs +4 -51
- package/dist/providers/togetherai/index.d.mts +3 -3
- package/dist/providers/togetherai/index.d.ts +3 -3
- package/dist/providers/togetherai/index.js +4 -51
- package/dist/providers/togetherai/index.mjs +4 -51
- package/dist/providers/xai/index.d.mts +3 -3
- package/dist/providers/xai/index.d.ts +3 -3
- package/dist/providers/xai/index.js +4 -51
- package/dist/providers/xai/index.mjs +4 -51
- package/dist/{types-mwMhCwOq.d.mts → types-B6dhnguR.d.mts} +1 -1
- package/dist/{types-TMilS-Dz.d.ts → types-BQ31QIsA.d.ts} +2 -2
- package/dist/{types-BvkiJ1dd.d.mts → types-BSSiJW2o.d.mts} +2 -2
- package/dist/{types-D774b0dg.d.mts → types-BkQCSiIt.d.mts} +2 -57
- package/dist/{types-D774b0dg.d.ts → types-BkQCSiIt.d.ts} +2 -57
- package/dist/{types-ChORafYS.d.ts → types-CCxPmkmK.d.ts} +1 -1
- package/dist/yourgpt/index.d.mts +1 -1
- package/dist/yourgpt/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -87,63 +87,6 @@ function toAnthropicOutputConfig(rf) {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
function toAnthropicMcp(mcpServers) {
|
|
91
|
-
if (!mcpServers || mcpServers.length === 0) {
|
|
92
|
-
return { mcpServers: [], tools: [], betas: [] };
|
|
93
|
-
}
|
|
94
|
-
const serverEntries = [];
|
|
95
|
-
const toolEntries = [];
|
|
96
|
-
for (const mcp of mcpServers) {
|
|
97
|
-
const authHeader = mcp.headers?.Authorization ?? mcp.headers?.authorization;
|
|
98
|
-
const token = authHeader?.replace(/^Bearer\s+/i, "");
|
|
99
|
-
serverEntries.push({
|
|
100
|
-
type: "url",
|
|
101
|
-
url: mcp.url,
|
|
102
|
-
name: mcp.label,
|
|
103
|
-
...token ? { authorization_token: token } : {}
|
|
104
|
-
});
|
|
105
|
-
if (mcp.allowedTools && mcp.allowedTools.length > 0) {
|
|
106
|
-
toolEntries.push({
|
|
107
|
-
type: "mcp_toolset",
|
|
108
|
-
mcp_server_name: mcp.label,
|
|
109
|
-
configs: Object.fromEntries(
|
|
110
|
-
mcp.allowedTools.map((toolName) => [toolName, {}])
|
|
111
|
-
)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
mcpServers: serverEntries,
|
|
117
|
-
tools: toolEntries,
|
|
118
|
-
betas: ["mcp-client-2025-11-20"]
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function isStringEffort(effort) {
|
|
122
|
-
return typeof effort === "string" && (effort === "minimal" || effort === "low" || effort === "medium" || effort === "high");
|
|
123
|
-
}
|
|
124
|
-
var ANTHROPIC_ADAPTIVE_MODELS = /(claude-opus-4-7|claude-opus-4-6|claude-sonnet-4-6)/i;
|
|
125
|
-
function toAnthropicThinking(effort, modelId) {
|
|
126
|
-
if (!effort) return {};
|
|
127
|
-
if (typeof effort === "object" && "raw" in effort) {
|
|
128
|
-
return { thinking: effort.raw };
|
|
129
|
-
}
|
|
130
|
-
const isAdaptive = !!modelId && ANTHROPIC_ADAPTIVE_MODELS.test(modelId);
|
|
131
|
-
if (typeof effort === "object" && "budgetTokens" in effort) {
|
|
132
|
-
return {
|
|
133
|
-
thinking: { type: "enabled", budget_tokens: effort.budgetTokens }
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
if (!isStringEffort(effort)) return {};
|
|
137
|
-
if (isAdaptive) {
|
|
138
|
-
const mapped = effort === "minimal" ? "low" : effort;
|
|
139
|
-
return {
|
|
140
|
-
thinking: { type: "adaptive" },
|
|
141
|
-
outputConfigEffort: mapped
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
const budget = effort === "high" ? 16e3 : effort === "medium" ? 8e3 : effort === "low" ? 4e3 : 2048;
|
|
145
|
-
return { thinking: { type: "enabled", budget_tokens: budget } };
|
|
146
|
-
}
|
|
147
90
|
function hasMediaAttachments(message) {
|
|
148
91
|
const attachments = message.metadata?.attachments;
|
|
149
92
|
return attachments?.some(
|
|
@@ -979,58 +922,36 @@ var AnthropicAdapter = class {
|
|
|
979
922
|
if (serverToolConfiguration) {
|
|
980
923
|
options.server_tool_configuration = serverToolConfiguration;
|
|
981
924
|
}
|
|
982
|
-
const modelForThinking = request.config?.model || this.model;
|
|
983
|
-
const thinkingTranslation = toAnthropicThinking(
|
|
984
|
-
request.config?.reasoningEffort,
|
|
985
|
-
modelForThinking
|
|
986
|
-
);
|
|
987
925
|
const outputConfig = toAnthropicOutputConfig(responseFormat);
|
|
988
|
-
if (outputConfig
|
|
989
|
-
options.output_config =
|
|
990
|
-
...outputConfig ?? {},
|
|
991
|
-
...thinkingTranslation.outputConfigEffort ? { effort: thinkingTranslation.outputConfigEffort } : {}
|
|
992
|
-
};
|
|
926
|
+
if (outputConfig) {
|
|
927
|
+
options.output_config = outputConfig;
|
|
993
928
|
}
|
|
994
|
-
if (
|
|
995
|
-
options.thinking = thinkingTranslation.thinking;
|
|
996
|
-
} else if (this.config.thinking?.type === "enabled") {
|
|
929
|
+
if (this.config.thinking?.type === "enabled") {
|
|
997
930
|
options.thinking = {
|
|
998
931
|
type: "enabled",
|
|
999
932
|
budget_tokens: this.config.thinking.budgetTokens || 1e4
|
|
1000
933
|
};
|
|
1001
934
|
}
|
|
1002
|
-
|
|
1003
|
-
const betas = [];
|
|
1004
|
-
if (mcp.mcpServers.length > 0) {
|
|
1005
|
-
options.mcp_servers = mcp.mcpServers;
|
|
1006
|
-
betas.push(...mcp.betas);
|
|
1007
|
-
if (mcp.tools.length > 0) {
|
|
1008
|
-
const existingTools = Array.isArray(options.tools) ? options.tools : [];
|
|
1009
|
-
options.tools = [...existingTools, ...mcp.tools];
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
return { options, messages, betas };
|
|
935
|
+
return { options, messages };
|
|
1013
936
|
}
|
|
1014
937
|
/**
|
|
1015
938
|
* Non-streaming completion (for debugging/comparison with original studio-ai)
|
|
1016
939
|
*/
|
|
1017
940
|
async complete(request) {
|
|
1018
941
|
const client = await this.getClient();
|
|
1019
|
-
const { options
|
|
942
|
+
const { options } = this.buildRequestOptions(request);
|
|
1020
943
|
const nonStreamingOptions = {
|
|
1021
944
|
...options,
|
|
1022
945
|
stream: false
|
|
1023
946
|
};
|
|
1024
947
|
try {
|
|
1025
|
-
const finalOptions = betas.length > 0 ? { ...nonStreamingOptions, betas } : nonStreamingOptions;
|
|
1026
|
-
const messagesApi = betas.length > 0 ? client.beta.messages : client.messages;
|
|
1027
948
|
logProviderPayload(
|
|
1028
949
|
"anthropic",
|
|
1029
950
|
"request payload",
|
|
1030
|
-
|
|
951
|
+
nonStreamingOptions,
|
|
1031
952
|
request.debug
|
|
1032
953
|
);
|
|
1033
|
-
const response = await
|
|
954
|
+
const response = await client.messages.create(nonStreamingOptions);
|
|
1034
955
|
logProviderPayload(
|
|
1035
956
|
"anthropic",
|
|
1036
957
|
"response payload",
|
|
@@ -1065,19 +986,17 @@ var AnthropicAdapter = class {
|
|
|
1065
986
|
}
|
|
1066
987
|
async *stream(request) {
|
|
1067
988
|
const client = await this.getClient();
|
|
1068
|
-
const { options
|
|
989
|
+
const { options } = this.buildRequestOptions(request);
|
|
1069
990
|
const messageId = generateMessageId();
|
|
1070
991
|
yield { type: "message:start", id: messageId };
|
|
1071
992
|
try {
|
|
1072
|
-
const finalOptions = betas.length > 0 ? { ...options, betas } : options;
|
|
1073
|
-
const streamApi = betas.length > 0 ? client.beta.messages : client.messages;
|
|
1074
993
|
logProviderPayload(
|
|
1075
994
|
"anthropic",
|
|
1076
995
|
"request payload",
|
|
1077
|
-
|
|
996
|
+
options,
|
|
1078
997
|
request.debug
|
|
1079
998
|
);
|
|
1080
|
-
const stream = await
|
|
999
|
+
const stream = await client.messages.stream(options);
|
|
1081
1000
|
let currentToolUse = null;
|
|
1082
1001
|
let isInThinkingBlock = false;
|
|
1083
1002
|
const collectedCitations = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as AzureProviderConfig, A as AIProvider } from '../../types-
|
|
2
|
-
import '../../types-
|
|
1
|
+
import { b as AzureProviderConfig, A as AIProvider } from '../../types-BSSiJW2o.mjs';
|
|
2
|
+
import '../../types-BkQCSiIt.mjs';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import '../../base-
|
|
4
|
+
import '../../base-tNgbBaSo.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Azure OpenAI Provider
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as AzureProviderConfig, A as AIProvider } from '../../types-
|
|
2
|
-
import '../../types-
|
|
1
|
+
import { b as AzureProviderConfig, A as AIProvider } from '../../types-BQ31QIsA.js';
|
|
2
|
+
import '../../types-BkQCSiIt.js';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import '../../base-
|
|
4
|
+
import '../../base-C58Dsr9p.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Azure OpenAI Provider
|
|
@@ -112,6 +112,7 @@ function normalizeObjectJsonSchema(schema) {
|
|
|
112
112
|
function toOpenAIResponseFormat(rf) {
|
|
113
113
|
if (!rf) return void 0;
|
|
114
114
|
if (rf.type === "json_object") return { type: "json_object" };
|
|
115
|
+
if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
|
|
115
116
|
return {
|
|
116
117
|
type: "json_schema",
|
|
117
118
|
json_schema: {
|
|
@@ -110,6 +110,7 @@ function normalizeObjectJsonSchema(schema) {
|
|
|
110
110
|
function toOpenAIResponseFormat(rf) {
|
|
111
111
|
if (!rf) return void 0;
|
|
112
112
|
if (rf.type === "json_object") return { type: "json_object" };
|
|
113
|
+
if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
|
|
113
114
|
return {
|
|
114
115
|
type: "json_schema",
|
|
115
116
|
json_schema: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { L as LanguageModel } from '../../types-
|
|
1
|
+
import { L as LanguageModel } from '../../types-BkQCSiIt.mjs';
|
|
2
|
+
import { A as AIProvider } from '../../types-BSSiJW2o.mjs';
|
|
2
3
|
import 'zod';
|
|
4
|
+
import '../../base-tNgbBaSo.mjs';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Fireworks Provider
|
|
@@ -46,4 +48,67 @@ interface FireworksProviderOptions {
|
|
|
46
48
|
*/
|
|
47
49
|
declare function fireworks(modelId: string, options?: FireworksProviderOptions): LanguageModel;
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Fireworks Provider
|
|
53
|
+
*
|
|
54
|
+
* Fireworks.ai is a high-performance inference platform for open-source models
|
|
55
|
+
* (Llama, DeepSeek, Qwen, Mixtral, Gemma, and more).
|
|
56
|
+
*
|
|
57
|
+
* Uses an OpenAI-compatible API — set FIREWORKS_API_KEY in your environment.
|
|
58
|
+
*
|
|
59
|
+
* @see https://fireworks.ai/docs
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* // Modern pattern — returns LanguageModel directly
|
|
64
|
+
* import { fireworks } from '@yourgpt/llm-sdk/fireworks';
|
|
65
|
+
* import { generateText } from '@yourgpt/llm-sdk';
|
|
66
|
+
*
|
|
67
|
+
* const result = await generateText({
|
|
68
|
+
* model: fireworks('accounts/fireworks/models/llama-v3p1-70b-instruct'),
|
|
69
|
+
* prompt: 'Hello!',
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Runtime pattern — returns AIProvider for createRuntime / fallback chain
|
|
73
|
+
* import { createFireworks } from '@yourgpt/llm-sdk/fireworks';
|
|
74
|
+
* import { createRuntime } from '@yourgpt/llm-sdk';
|
|
75
|
+
*
|
|
76
|
+
* const provider = createFireworks({ apiKey: '...' });
|
|
77
|
+
* const runtime = createRuntime({ provider, model: 'accounts/fireworks/models/deepseek-v3p1' });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
interface FireworksProviderConfig {
|
|
82
|
+
/** API key (defaults to FIREWORKS_API_KEY env var) */
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
/** Base URL for API */
|
|
85
|
+
baseUrl?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a Fireworks provider (callable, for use with createRuntime).
|
|
89
|
+
*
|
|
90
|
+
* Fireworks exposes an OpenAI-compatible API, so this reuses the OpenAI adapter
|
|
91
|
+
* pointed at the Fireworks base URL — the same approach used by Together AI and
|
|
92
|
+
* OpenRouter. The adapter speaks the runtime's API (generate/stream, rawMessages,
|
|
93
|
+
* message:delta/end events) and sets `stream_options.include_usage`, so streaming
|
|
94
|
+
* usage is reported correctly for credit accounting.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* import { createFireworks } from '@yourgpt/llm-sdk/fireworks';
|
|
99
|
+
* import { createRuntime } from '@yourgpt/llm-sdk';
|
|
100
|
+
*
|
|
101
|
+
* const fireworks = createFireworks({ apiKey: '...' });
|
|
102
|
+
* const runtime = createRuntime({
|
|
103
|
+
* provider: fireworks,
|
|
104
|
+
* model: 'accounts/fireworks/models/deepseek-v3p1',
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Handle incoming chat requests
|
|
108
|
+
* return runtime.handleRequest(request);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare function createFireworks(config?: FireworksProviderConfig): AIProvider;
|
|
112
|
+
declare const createFireworksProvider: typeof createFireworks;
|
|
113
|
+
|
|
114
|
+
export { type FireworksProviderConfig, type FireworksProviderOptions, createFireworks, fireworks as createFireworksModel, createFireworksProvider, fireworks };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { L as LanguageModel } from '../../types-
|
|
1
|
+
import { L as LanguageModel } from '../../types-BkQCSiIt.js';
|
|
2
|
+
import { A as AIProvider } from '../../types-BQ31QIsA.js';
|
|
2
3
|
import 'zod';
|
|
4
|
+
import '../../base-C58Dsr9p.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Fireworks Provider
|
|
@@ -46,4 +48,67 @@ interface FireworksProviderOptions {
|
|
|
46
48
|
*/
|
|
47
49
|
declare function fireworks(modelId: string, options?: FireworksProviderOptions): LanguageModel;
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Fireworks Provider
|
|
53
|
+
*
|
|
54
|
+
* Fireworks.ai is a high-performance inference platform for open-source models
|
|
55
|
+
* (Llama, DeepSeek, Qwen, Mixtral, Gemma, and more).
|
|
56
|
+
*
|
|
57
|
+
* Uses an OpenAI-compatible API — set FIREWORKS_API_KEY in your environment.
|
|
58
|
+
*
|
|
59
|
+
* @see https://fireworks.ai/docs
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* // Modern pattern — returns LanguageModel directly
|
|
64
|
+
* import { fireworks } from '@yourgpt/llm-sdk/fireworks';
|
|
65
|
+
* import { generateText } from '@yourgpt/llm-sdk';
|
|
66
|
+
*
|
|
67
|
+
* const result = await generateText({
|
|
68
|
+
* model: fireworks('accounts/fireworks/models/llama-v3p1-70b-instruct'),
|
|
69
|
+
* prompt: 'Hello!',
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Runtime pattern — returns AIProvider for createRuntime / fallback chain
|
|
73
|
+
* import { createFireworks } from '@yourgpt/llm-sdk/fireworks';
|
|
74
|
+
* import { createRuntime } from '@yourgpt/llm-sdk';
|
|
75
|
+
*
|
|
76
|
+
* const provider = createFireworks({ apiKey: '...' });
|
|
77
|
+
* const runtime = createRuntime({ provider, model: 'accounts/fireworks/models/deepseek-v3p1' });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
interface FireworksProviderConfig {
|
|
82
|
+
/** API key (defaults to FIREWORKS_API_KEY env var) */
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
/** Base URL for API */
|
|
85
|
+
baseUrl?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a Fireworks provider (callable, for use with createRuntime).
|
|
89
|
+
*
|
|
90
|
+
* Fireworks exposes an OpenAI-compatible API, so this reuses the OpenAI adapter
|
|
91
|
+
* pointed at the Fireworks base URL — the same approach used by Together AI and
|
|
92
|
+
* OpenRouter. The adapter speaks the runtime's API (generate/stream, rawMessages,
|
|
93
|
+
* message:delta/end events) and sets `stream_options.include_usage`, so streaming
|
|
94
|
+
* usage is reported correctly for credit accounting.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* import { createFireworks } from '@yourgpt/llm-sdk/fireworks';
|
|
99
|
+
* import { createRuntime } from '@yourgpt/llm-sdk';
|
|
100
|
+
*
|
|
101
|
+
* const fireworks = createFireworks({ apiKey: '...' });
|
|
102
|
+
* const runtime = createRuntime({
|
|
103
|
+
* provider: fireworks,
|
|
104
|
+
* model: 'accounts/fireworks/models/deepseek-v3p1',
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Handle incoming chat requests
|
|
108
|
+
* return runtime.handleRequest(request);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare function createFireworks(config?: FireworksProviderConfig): AIProvider;
|
|
112
|
+
declare const createFireworksProvider: typeof createFireworks;
|
|
113
|
+
|
|
114
|
+
export { type FireworksProviderConfig, type FireworksProviderOptions, createFireworks, fireworks as createFireworksModel, createFireworksProvider, fireworks };
|