@absolutejs/ai 0.0.15 → 0.0.17

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
@@ -1221,7 +1221,13 @@ var buildRequestBody4 = (params) => {
1221
1221
  stream: true
1222
1222
  };
1223
1223
  if (params.systemPrompt) {
1224
- body.system = params.systemPrompt;
1224
+ body.system = params.cacheSystemPrompt ? [
1225
+ {
1226
+ cache_control: { type: "ephemeral" },
1227
+ text: params.systemPrompt,
1228
+ type: "text"
1229
+ }
1230
+ ] : params.systemPrompt;
1225
1231
  }
1226
1232
  if (params.tools && params.tools.length > 0) {
1227
1233
  body.tools = params.tools.map(mapToolDefinition2);
@@ -1383,6 +1389,8 @@ var extractUsage4 = (usageRecord, existingUsage) => {
1383
1389
  return existingUsage;
1384
1390
  }
1385
1391
  return {
1392
+ cacheReadInputTokens: getNumber(usageRecord, "cache_read_input_tokens") || existingUsage?.cacheReadInputTokens || 0,
1393
+ cacheWriteInputTokens: getNumber(usageRecord, "cache_creation_input_tokens") || existingUsage?.cacheWriteInputTokens || 0,
1386
1394
  inputTokens: getNumber(usageRecord, "input_tokens") || existingUsage?.inputTokens || 0,
1387
1395
  outputTokens: getNumber(usageRecord, "output_tokens") || existingUsage?.outputTokens || 0
1388
1396
  };
@@ -2783,7 +2791,7 @@ var aiChat = (config) => {
2783
2791
  return new Response(html || '<div class="empty">No conversations</div>', { headers: { "Content-Type": "text/html" } });
2784
2792
  });
2785
2793
  };
2786
- return new Elysia().ws(path, {
2794
+ const app = new Elysia().ws(path, {
2787
2795
  message: async (ws, raw) => {
2788
2796
  const msg = parseAIMessage(raw);
2789
2797
  if (!msg) {
@@ -2815,11 +2823,13 @@ var aiChat = (config) => {
2815
2823
  await store.remove(params.id);
2816
2824
  return { ok: true };
2817
2825
  }).use(htmxRoutes());
2826
+ return app;
2818
2827
  };
2819
2828
  // src/ai/generateAI.ts
2820
2829
  var DEFAULT_OBJECT_TOOL_NAME = "respond";
2821
2830
  var generateAI = async (options) => {
2822
2831
  const stream = options.provider.stream({
2832
+ cacheSystemPrompt: options.cacheSystemPrompt,
2823
2833
  maxTokens: options.maxTokens,
2824
2834
  messages: options.messages,
2825
2835
  model: options.model,
@@ -2854,6 +2864,7 @@ var generateObjectAI = async (options) => {
2854
2864
  name: toolName
2855
2865
  };
2856
2866
  const { toolCalls, usage } = await generateAI({
2867
+ cacheSystemPrompt: options.cacheSystemPrompt,
2857
2868
  maxTokens: options.maxTokens,
2858
2869
  messages: options.messages,
2859
2870
  model: options.model,
@@ -3724,5 +3735,5 @@ export {
3724
3735
  aiChat
3725
3736
  };
3726
3737
 
3727
- //# debugId=EABD04CAA079176164756E2164756E21
3738
+ //# debugId=C4E33CBC9F4AE7E764756E2164756E21
3728
3739
  //# sourceMappingURL=index.js.map