@27works/chat-core 0.1.0 → 0.2.0

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 CHANGED
@@ -195,7 +195,8 @@ export async function POST(req) {
195
195
  userContent: messageText,
196
196
  assistantContent: ctx.cached_answer,
197
197
  inputTokens: 0,
198
- outputTokens: 0
198
+ outputTokens: 0,
199
+ fromCache: true
199
200
  })
200
201
  .catch(err =>
201
202
  console.error(
@@ -230,7 +231,8 @@ export async function POST(req) {
230
231
  assistantContent: text,
231
232
  modelId: AI_CHAT_MODEL,
232
233
  inputTokens: usage?.promptTokens,
233
- outputTokens: usage?.completionTokens
234
+ outputTokens: usage?.completionTokens,
235
+ cachedTokens: usage?.cachedInputTokens
234
236
  })
235
237
  .catch(err =>
236
238
  console.error('[chat] Failed to persist turn:', err?.message)
@@ -15430,13 +15430,14 @@ Content: ${parentDoc.properties.content}`;
15430
15430
  parts: [{ type: "text", text }],
15431
15431
  metadata: potentialQuestionId ? { questionId: potentialQuestionId } : void 0
15432
15432
  };
15433
+ const cachedInputTokens = usage.cachedInputTokens ?? usage.inputTokenDetails?.cacheReadTokens ?? 0;
15433
15434
  await saveChat({
15434
15435
  chatId: id,
15435
15436
  messages: sanitizeMessagesForStorage([
15436
15437
  ...originalMessages,
15437
15438
  assistantMessage
15438
15439
  ]),
15439
- usage,
15440
+ usage: { ...usage, cachedInputTokens },
15440
15441
  ownerId,
15441
15442
  projectId
15442
15443
  });
@@ -15510,10 +15511,8 @@ function createLinkClickHandler() {
15510
15511
  return new Response(null, { status: 204 });
15511
15512
  }
15512
15513
  const { conversationId, url: url2, linkLabel, messageIndex } = parsed.data;
15513
- const projectId = await getProjectId();
15514
15514
  await caruutoAdmin.ai.trackLinkClick({
15515
15515
  conversationId,
15516
- projectId,
15517
15516
  url: url2,
15518
15517
  linkLabel,
15519
15518
  messageIndex
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@27works/chat-core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Core utilities and components for 27works chat applications.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -69,4 +69,4 @@
69
69
  "tsup": "^8.5.1",
70
70
  "typescript": "^5"
71
71
  }
72
- }
72
+ }