@epam/ai-dial-chat-hooks 1.1.0 → 1.1.2

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.
@@ -1,35 +1,42 @@
1
1
  import { MessageRole as e, messageAttachmentToDisplayAttachment as t } from "@epam/ai-dial-chat-shared";
2
- import { isReferenceOnlyAttachment as n, resolveMessageAnnotations as r } from "@epam/ai-dial-quotations";
3
- import { useMemo as i } from "react";
2
+ import { getAnnotationPdfPage as n, isReferenceOnlyAttachment as r, parsePdfPageReference as i, resolveMessageAnnotations as a } from "@epam/ai-dial-quotations";
3
+ import { useMemo as o } from "react";
4
4
  //#region src/conversation-sources/useConversationSources/useConversationSources.ts
5
- var a = {}, o = (o, s = a) => i(() => {
6
- let i = [], a = [], c = [], l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
7
- for (let f of o) {
8
- let o = f.custom_content?.attachments;
9
- if (f.role === e.User) for (let e of o ?? []) {
10
- let n = t(e, s);
11
- u.has(n.id) || (u.add(n.id), i.push(n));
5
+ var s = {}, c = (e, t) => {
6
+ let r = n(e);
7
+ if (r == null) return t;
8
+ let a = i(t);
9
+ return a == null || a.page != null ? t : `${t}#page=${r}`;
10
+ }, l = (n, i = s) => o(() => {
11
+ let o = [], s = [], l = [], u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
12
+ for (let p of n) {
13
+ let n = p.custom_content?.attachments;
14
+ if (p.role === e.User) for (let e of n ?? []) {
15
+ let n = t(e, i);
16
+ d.has(n.id) || (d.add(n.id), o.push(n));
12
17
  }
13
- else if (f.role === e.Assistant) {
14
- let e = o?.filter((e) => !n(e));
18
+ else if (p.role === e.Assistant) {
19
+ let e = n?.filter((e) => !r(e));
15
20
  for (let n of e ?? []) {
16
- let e = t(n, s);
17
- d.has(e.id) || (d.add(e.id), a.push(e));
21
+ let e = t(n, i);
22
+ f.has(e.id) || (f.add(e.id), s.push(e));
18
23
  }
19
- for (let e of o ?? []) {
20
- if (!n(e)) continue;
24
+ for (let e of n ?? []) {
25
+ if (!r(e)) continue;
21
26
  let t = e.reference_url;
22
- l.has(t) || (l.add(t), c.push({
27
+ u.has(t) || (u.add(t), l.push({
23
28
  url: t,
24
29
  title: e.title ?? t,
25
30
  contentType: e.reference_type ?? e.type ?? "",
26
31
  quote: e.data
27
32
  }));
28
33
  }
29
- for (let e of r(f)) {
34
+ for (let e of a(p)) {
30
35
  let t = e?.body?.source?.attachment, n = t?.url;
31
- !n || l.has(n) || (l.add(n), c.push({
32
- url: n,
36
+ if (!n) continue;
37
+ let r = c(e, n);
38
+ u.has(r) || (u.add(r), l.push({
39
+ url: r,
33
40
  title: t?.title ?? n.split("/").pop() ?? n,
34
41
  contentType: t?.type ?? "",
35
42
  quote: e.body?.quote
@@ -38,10 +45,10 @@ var a = {}, o = (o, s = a) => i(() => {
38
45
  }
39
46
  }
40
47
  return {
41
- uploaded: i,
42
- generated: a,
43
- sources: c
48
+ uploaded: o,
49
+ generated: s,
50
+ sources: l
44
51
  };
45
- }, [o, s]);
52
+ }, [n, i]);
46
53
  //#endregion
47
- export { o as useConversationSources };
54
+ export { l as useConversationSources };
@@ -18,7 +18,7 @@ export declare interface UseConversationSourcesResult {
18
18
  uploaded: DisplayAttachment[];
19
19
  /** Deduplicated attachments the assistant generated across the conversation. */
20
20
  generated: DisplayAttachment[];
21
- /** Quotation sources referenced by assistant messages, deduplicated by URL. */
21
+ /** Quotation sources referenced by assistant messages, deduplicated by URL; PDF sources are qualified with `#page=N`. */
22
22
  sources: QuotationSource[];
23
23
  }
24
24
 
package/index.d.ts CHANGED
@@ -4527,7 +4527,7 @@ export declare interface UseConversationSourcesResult {
4527
4527
  uploaded: DisplayAttachment[];
4528
4528
  /** Deduplicated attachments the assistant generated across the conversation. */
4529
4529
  generated: DisplayAttachment[];
4530
- /** Quotation sources referenced by assistant messages, deduplicated by URL. */
4530
+ /** Quotation sources referenced by assistant messages, deduplicated by URL; PDF sources are qualified with `#page=N`. */
4531
4531
  sources: QuotationSource[];
4532
4532
  }
4533
4533
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.1.0",
4
+ "version": "1.1.2",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -106,7 +106,7 @@
106
106
  }
107
107
  },
108
108
  "dependencies": {
109
- "@epam/ai-dial-chat-api-client": "1.1.0",
109
+ "@epam/ai-dial-chat-api-client": "1.1.2",
110
110
  "dompurify": "3.4.15",
111
111
  "fflate": "^0.8.3",
112
112
  "lru-cache": "^10.4.3",
@@ -115,20 +115,20 @@
115
115
  },
116
116
  "peerDependencies": {
117
117
  "react": "^19.2.8",
118
- "@epam/ai-dial-attachment-canvas": "1.1.0",
119
- "@epam/ai-dial-attachment-input": "1.1.0",
120
- "@epam/ai-dial-builder-form": "1.1.0",
121
- "@epam/ai-dial-catalog": "1.1.0",
122
- "@epam/ai-dial-chat-overlay": "1.1.0",
123
- "@epam/ai-dial-chat-shared": "1.1.0",
124
- "@epam/ai-dial-mcp-apps": "1.1.0",
125
- "@epam/ai-dial-publish-panel": "1.1.0",
126
- "@epam/ai-dial-quotations": "1.1.0",
118
+ "@epam/ai-dial-attachment-canvas": "1.1.2",
119
+ "@epam/ai-dial-attachment-input": "1.1.2",
120
+ "@epam/ai-dial-builder-form": "1.1.2",
121
+ "@epam/ai-dial-catalog": "1.1.2",
122
+ "@epam/ai-dial-chat-overlay": "1.1.2",
123
+ "@epam/ai-dial-chat-shared": "1.1.2",
124
+ "@epam/ai-dial-mcp-apps": "1.1.2",
125
+ "@epam/ai-dial-publish-panel": "1.1.2",
126
+ "@epam/ai-dial-quotations": "1.1.2",
127
127
  "@epam/ai-dial-react-file-manager": "^0.2.0",
128
- "@epam/ai-dial-scheduled-tasks": "1.1.0",
129
- "@epam/ai-dial-share": "1.1.0",
130
- "@epam/ai-dial-skill-editor": "1.1.0",
131
- "@epam/ai-dial-source-panel": "1.1.0",
128
+ "@epam/ai-dial-scheduled-tasks": "1.1.2",
129
+ "@epam/ai-dial-share": "1.1.2",
130
+ "@epam/ai-dial-skill-editor": "1.1.2",
131
+ "@epam/ai-dial-source-panel": "1.1.2",
132
132
  "@epam/ai-dial-ui-kit": "^0.14.2",
133
133
  "@modelcontextprotocol/sdk": "^1.29.0",
134
134
  "@epam/pdf-highlighter-kit": "^0.0.19",