@absolutejs/absolute 0.19.0-beta.530 → 0.19.0-beta.531

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
@@ -1823,7 +1823,13 @@ var defaultComplete = (usage, durationMs, model) => {
1823
1823
  var defaultError = (message) => `<div class="ai-error">${escapeHtml(message)}</div>`;
1824
1824
  var defaultCanceled = () => `<div class="ai-canceled">Canceled.</div>`;
1825
1825
  var defaultRAGRetrieving = () => `<div class="ai-retrieving">Retrieving sources...</div>`;
1826
- var defaultRAGRetrieved = (sources) => sources.length === 0 ? "" : `<div class="ai-sources">` + `<h4>Citations</h4>` + `<ul>` + `${sources.map((source) => `<li>[${source.chunkId}] ${escapeHtml(source.text)}${source.source ? ` (${escapeHtml(source.source)})` : ""}</li>`).join("")}` + `</ul>` + `</div>`;
1826
+ var renderTraceSummary = (trace) => {
1827
+ if (!trace) {
1828
+ return "";
1829
+ }
1830
+ return `<div class="ai-trace-summary">` + `Mode: ${escapeHtml(trace.mode)} \xB7 Final: ${trace.resultCounts.final} \xB7 Vector: ${trace.resultCounts.vector} \xB7 Lexical: ${trace.resultCounts.lexical}` + `</div>`;
1831
+ };
1832
+ var defaultRAGRetrieved = (sources, input) => sources.length === 0 ? "" : `<div class="ai-sources">` + `<h4>Citations</h4>` + renderTraceSummary(input?.trace) + `<ul>` + `${sources.map((source) => `<li>[${source.chunkId}] ${escapeHtml(source.text)}${source.source ? ` (${escapeHtml(source.source)})` : ""}</li>`).join("")}` + `</ul>` + `</div>`;
1827
1833
  var resolveRenderers = (custom) => ({
1828
1834
  chunk: custom?.chunk ?? defaultChunk,
1829
1835
  messageStart: custom?.messageStart ?? defaultMessageStart,
@@ -7514,7 +7520,7 @@ var ragChat = (config) => {
7514
7520
  event: "retrieval"
7515
7521
  };
7516
7522
  const provider = config.provider(providerName);
7517
- const { ragContext, sources } = await buildRAGContextFromQuery(config, topK, scoreThreshold, content, ragModel, config.embedding, config.embeddingModel);
7523
+ const { ragContext, sources, trace } = await buildRAGContextFromQuery(config, topK, scoreThreshold, content, ragModel, config.embedding, config.embeddingModel);
7518
7524
  const retrievedAt = Date.now();
7519
7525
  const retrievalDurationMs = retrievedAt - retrievalStartedAt;
7520
7526
  yield {
@@ -7527,7 +7533,8 @@ var ragChat = (config) => {
7527
7533
  messageId,
7528
7534
  retrievalDurationMs,
7529
7535
  retrievalStartedAt,
7530
- retrievedAt
7536
+ retrievedAt,
7537
+ trace
7531
7538
  }),
7532
7539
  event: "sources"
7533
7540
  };
@@ -10245,6 +10252,7 @@ var serverMessageToAction = (msg) => {
10245
10252
  retrievalStartedAt: msg.retrievalStartedAt,
10246
10253
  retrievedAt: msg.retrievedAt,
10247
10254
  sources: msg.sources,
10255
+ trace: msg.trace,
10248
10256
  type: "rag_retrieved"
10249
10257
  };
10250
10258
  case "error":
@@ -10512,6 +10520,7 @@ var handleRAGRetrieved = (state, action) => {
10512
10520
  message.retrievalStartedAt = action.retrievalStartedAt ?? message.retrievalStartedAt;
10513
10521
  message.retrievedAt = action.retrievedAt;
10514
10522
  message.retrievalDurationMs = action.retrievalDurationMs;
10523
+ message.retrievalTrace = action.trace;
10515
10524
  conversation.messages = [...conversation.messages];
10516
10525
  };
10517
10526
  var handleRAGRetrieving = (state, action) => {
@@ -11102,8 +11111,19 @@ var createRAGClient = (options) => {
11102
11111
  return parseJson(response);
11103
11112
  },
11104
11113
  async search(input) {
11105
- const result = await this.searchDetailed(input);
11106
- return result.results;
11114
+ const response = await fetchImpl(`${basePath}/search`, {
11115
+ body: JSON.stringify(input),
11116
+ headers: jsonHeaders,
11117
+ method: "POST"
11118
+ });
11119
+ if (!response.ok) {
11120
+ throw new Error(await toErrorMessage3(response));
11121
+ }
11122
+ const payload = await parseJson(response);
11123
+ if (!payload.ok) {
11124
+ throw new Error(payload.error ?? "RAG search failed");
11125
+ }
11126
+ return payload.results ?? [];
11107
11127
  },
11108
11128
  async searchDetailed(input) {
11109
11129
  const response = await fetchImpl(`${basePath}/search`, {
@@ -11283,5 +11303,5 @@ export {
11283
11303
  aiChat
11284
11304
  };
11285
11305
 
11286
- //# debugId=A637A580CF9E784264756E2164756E21
11306
+ //# debugId=09C2CE3CC04F038664756E2164756E21
11287
11307
  //# sourceMappingURL=index.js.map