@absolutejs/ai 0.0.27 → 0.0.28
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/ai/index.js
CHANGED
|
@@ -1601,9 +1601,11 @@ var cacheLastContentBlock = (msg) => {
|
|
|
1601
1601
|
};
|
|
1602
1602
|
return { content: blocks, role: msg.role };
|
|
1603
1603
|
};
|
|
1604
|
-
var buildRequestBody4 = (params, configuredMax,
|
|
1604
|
+
var buildRequestBody4 = (params, configuredMax, configCaching) => {
|
|
1605
|
+
const caching = params.promptCaching ?? configCaching;
|
|
1606
|
+
const cacheSystem = params.cacheSystemPrompt ?? caching;
|
|
1605
1607
|
const messages = params.messages.filter((msg) => msg.role !== "system").map(mapMessage);
|
|
1606
|
-
if (
|
|
1608
|
+
if (caching && messages.length > 1) {
|
|
1607
1609
|
const last = messages[messages.length - 1];
|
|
1608
1610
|
if (last) {
|
|
1609
1611
|
messages[messages.length - 1] = cacheLastContentBlock(last);
|
|
@@ -1617,7 +1619,7 @@ var buildRequestBody4 = (params, configuredMax, promptCaching) => {
|
|
|
1617
1619
|
stream: true
|
|
1618
1620
|
};
|
|
1619
1621
|
if (params.systemPrompt) {
|
|
1620
|
-
body.system =
|
|
1622
|
+
body.system = cacheSystem ? [
|
|
1621
1623
|
{
|
|
1622
1624
|
cache_control: { type: "ephemeral" },
|
|
1623
1625
|
text: params.systemPrompt,
|
|
@@ -1627,7 +1629,7 @@ var buildRequestBody4 = (params, configuredMax, promptCaching) => {
|
|
|
1627
1629
|
}
|
|
1628
1630
|
if (params.tools && params.tools.length > 0) {
|
|
1629
1631
|
const tools = params.tools.map(mapToolDefinition2);
|
|
1630
|
-
if (
|
|
1632
|
+
if (caching) {
|
|
1631
1633
|
tools[tools.length - 1] = {
|
|
1632
1634
|
...tools[tools.length - 1],
|
|
1633
1635
|
cache_control: { type: "ephemeral" }
|
|
@@ -2521,8 +2523,10 @@ var processToolTurn = async (socket, options, state, messageId, conversationId,
|
|
|
2521
2523
|
});
|
|
2522
2524
|
const toolDefs = options.tools ? buildToolDefinitions(options.tools) : undefined;
|
|
2523
2525
|
const stream = options.provider.stream({
|
|
2526
|
+
cacheSystemPrompt: options.cacheSystemPrompt,
|
|
2524
2527
|
messages: state.currentMessages,
|
|
2525
2528
|
model: options.model,
|
|
2529
|
+
promptCaching: options.promptCaching,
|
|
2526
2530
|
reasoning: options.reasoning,
|
|
2527
2531
|
signal,
|
|
2528
2532
|
systemPrompt: options.systemPrompt,
|
|
@@ -2605,8 +2609,10 @@ var processStreamTextChunk = async (chunk, options, socket, messageId, conversat
|
|
|
2605
2609
|
var processStream = async (socket, options, messages, messageId, conversationId, signal, startTime) => {
|
|
2606
2610
|
const toolDefs = options.tools ? buildToolDefinitions(options.tools) : undefined;
|
|
2607
2611
|
const stream = options.provider.stream({
|
|
2612
|
+
cacheSystemPrompt: options.cacheSystemPrompt,
|
|
2608
2613
|
messages,
|
|
2609
2614
|
model: options.model,
|
|
2615
|
+
promptCaching: options.promptCaching,
|
|
2610
2616
|
reasoning: options.reasoning,
|
|
2611
2617
|
signal,
|
|
2612
2618
|
systemPrompt: options.systemPrompt,
|
|
@@ -2954,9 +2960,11 @@ var streamTurns = async function* (options, renderers, messages, signal, startTi
|
|
|
2954
2960
|
usage: undefined
|
|
2955
2961
|
};
|
|
2956
2962
|
const stream = options.provider.stream({
|
|
2963
|
+
cacheSystemPrompt: options.cacheSystemPrompt,
|
|
2957
2964
|
maxTokens: options.maxTokens,
|
|
2958
2965
|
messages: turnState.currentMessages,
|
|
2959
2966
|
model: options.model,
|
|
2967
|
+
promptCaching: options.promptCaching,
|
|
2960
2968
|
reasoning: options.reasoning,
|
|
2961
2969
|
signal,
|
|
2962
2970
|
systemPrompt: options.systemPrompt,
|
|
@@ -3331,6 +3339,7 @@ var generateAI = async (options) => {
|
|
|
3331
3339
|
maxTokens: options.maxTokens,
|
|
3332
3340
|
messages: options.messages,
|
|
3333
3341
|
model: options.model,
|
|
3342
|
+
promptCaching: options.promptCaching,
|
|
3334
3343
|
reasoning: options.reasoning,
|
|
3335
3344
|
responseFormat: options.responseFormat,
|
|
3336
3345
|
signal: options.signal,
|
|
@@ -3435,6 +3444,7 @@ var generateObjectAI = async (options) => {
|
|
|
3435
3444
|
maxTokens: options.maxTokens,
|
|
3436
3445
|
messages: options.messages,
|
|
3437
3446
|
model: options.model,
|
|
3447
|
+
promptCaching: options.promptCaching,
|
|
3438
3448
|
provider: options.provider,
|
|
3439
3449
|
reasoning: options.reasoning,
|
|
3440
3450
|
signal: options.signal,
|
|
@@ -4410,5 +4420,5 @@ export {
|
|
|
4410
4420
|
PROVIDER_STATUS_PAGES
|
|
4411
4421
|
};
|
|
4412
4422
|
|
|
4413
|
-
//# debugId=
|
|
4423
|
+
//# debugId=CE76A2131808230464756E2164756E21
|
|
4414
4424
|
//# sourceMappingURL=index.js.map
|