@inkeep/cxkit-primitives 0.5.118 → 0.5.119
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,4 +1,6 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ce=require("openai"),t=require("react"),Oe=require("../../providers/config-provider.cjs"),De=require("../../providers/conversation-provider.cjs"),Fe=require("../../providers/chat-events-provider.cjs"),K=require("../../utils/get-message-metadata.cjs"),le=require("../../utils/reset-query-params.cjs"),Te=require("../../providers/chat-form-provider.cjs"),Ke=require("../../providers/widget-provider.cjs"),Qe=require("../../hooks/use-media-query.cjs"),We=require("./use-captcha.cjs"),Je=require("../modal/modal-provider.cjs"),d=require("../../utils/generate-uid.cjs"),ze=require("../../utils/tools/links-tool.cjs"),He=require("../../atoms/api/analytics/conversation.cjs"),je=require("../../utils/misc.cjs"),Ge=()=>{const{chatId:S,isSharedChat:ue,setConversation:ge,conversation:de,resetConversation:me}=De.useInkeepConversation(),{baseSettings:
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ce=require("openai"),t=require("react"),Oe=require("../../providers/config-provider.cjs"),De=require("../../providers/conversation-provider.cjs"),Fe=require("../../providers/chat-events-provider.cjs"),K=require("../../utils/get-message-metadata.cjs"),le=require("../../utils/reset-query-params.cjs"),Te=require("../../providers/chat-form-provider.cjs"),Ke=require("../../providers/widget-provider.cjs"),Qe=require("../../hooks/use-media-query.cjs"),We=require("./use-captcha.cjs"),Je=require("../modal/modal-provider.cjs"),d=require("../../utils/generate-uid.cjs"),ze=require("../../utils/tools/links-tool.cjs"),He=require("../../atoms/api/analytics/conversation.cjs"),je=require("../../utils/misc.cjs"),Ge=()=>{const{chatId:S,isSharedChat:ue,setConversation:ge,conversation:de,resetConversation:me}=De.useInkeepConversation(),{baseSettings:q,aiChatSettings:Q}=Oe.useInkeepConfig(),{aiApiBaseUrl:W,shouldBypassCaptcha:J,filters:z}=q,H=Je.useModal(),{getSolution:pe,prefetchSolution:E,invalidateSolution:j}=We.useCaptcha({fetchUrl:`${W}/v1/challenge`,shouldBypassCaptcha:J,shouldMakeInitialRequest:H?H.isOpen:!0}),fe=new ce({baseURL:`${W}/v1`,apiKey:q.apiKey??"",dangerouslyAllowBrowser:!0}),{onInputMessageChange:he,getTools:ve,prompts:ye,model:Se,filters:G,onToolCall:we}=Q,[w,x]=t.useState(""),V=t.useRef(null);t.useEffect(()=>{he?.(w)},[w]);const[m,l]=t.useState([]),[X,C]=t.useState(!1),[Ce,M]=t.useState(!1),[Me,Y]=t.useState(null),[B,Z]=t.useState(null),[I,b]=t.useState([]),Ie=e=>{b(s=>[...s,e])},[be,ee]=t.useState({}),o=t.useRef([]),k=t.useRef(null),{logEvent:_,getLatestConversation:te}=Fe.useChatEvents(),se=ye?.map((e,s)=>({id:`system-${Date.now().toString()}-${d.generateUid(4)}-${s}`,role:"system",content:e})),[ke,_e]=t.useState(!!S);t.useEffect(()=>{if(S){const{apiKey:e,analyticsApiBaseUrl:s}=q;He.getConversation(S,e,s).then(a=>{if(a){_({eventName:"shared_chat_loaded",properties:{conversation:a}}),_e(!1),ge({...a});const r=a.messages.map(p=>({...p,content:je.parseIfJson(p.content)}));l(r),o.current=r}})}},[S]);const $e=e=>e.status===403||e.status===401?`There seems to be a configuration error. Please contact ${q.organizationDisplayName??"Administrator"}.`:e.error?.message?`${e.error.message}
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Please clear the chat and try again.`:`Hmm..
|
|
4
|
+
|
|
5
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`,ne=e=>{Y(e),l(s=>{const a=[...s],r=a[a.length-1];return r&&(r.content=$e(e)),a}),C(!1),M(!1),j(),E()},R=!w.trim()&&!I.length||X,Pe=e=>{e.key==="Enter"&&!e.shiftKey&&!R&&!e.nativeEvent.isComposing&&(e.preventDefault(),O())},qe=e=>{const s=e.target.value;x(s)},O=async(e=w)=>{if(R&&(!e||e.trim().length===0))return;C(!0);const s=B?m.length===2:m.length===0,a=K.getMessageMetadata(B,I,s);let r;const p=K.serializeAttachments(I);I.length&&p?r=[{type:"text",text:p}]:r=e;const ae={id:`${Date.now().toString()}-${d.generateUid(4)}-1`,role:"user",content:r,metadata:a},f=[...m.length?[]:se,ae];if(ue&&S){le.resetQueryParams();const u=o.current.map((i,U)=>({id:`${i.id}-${d.generateUid(6)}-${U}`,role:i.role,...i.role==="assistant"?{links:i.links??[]}:{},content:i.content,metadata:i.metadata,tool_calls:i.tool_calls}));l([...u,...f]),o.current=[...u,...f]}else l(u=>[...u,...f]),o.current=[...o.current,...f];b([]),x(""),_({eventName:"user_message_submitted",properties:{}},o.current);const xe=te(),re=[ze.provideLinksTool,...ve?.({conversation:xe})||[]];try{const u={model:Se,messages:o.current,stream:!0,tools:re,tool_choice:"auto"},i=await pe(),U=i?btoa(JSON.stringify(i)):null,ie=z||G?JSON.stringify({...z,...G}):void 0,N={};!J&&U&&(N["X-INKEEP-CHALLENGE-SOLUTION"]=U),ie&&(N["inkeep-filters"]=ie);const h=fe.beta.chat.completions.stream(u,Object.keys(N).length>0?{headers:N}:void 0),n={id:`${Date.now().toString()}-${d.generateUid(4)}-2`,role:"assistant",content:"",links:[],tool_calls:[]};l(g=>[...g,n]),h.on("content",(g,$)=>{M(!0),n.content=$,l(A=>{const c=[...A],D=c.findIndex(P=>P.id===n.id);return D===-1?[...c,n]:(c[D]={...n},c)})}),h.on("tool_calls.function.arguments.done",async g=>{const{name:$,arguments:A}=g,c=re?.find(v=>v.function.name===$);if(!c)return;const P=("parse"in c.function?c.function.parse:JSON.parse)(A),Be=c.function.function?.(P,h);if($==="provideLinks")n.links=P.links??[];else{const v=c.renderMessageButtons?.({args:P,execution:Be})??[];v.length>0&&ee(y=>{const L=y[n.id]??[],F=new Set(L.map(T=>T.label)),Re=v.filter(T=>!F.has(T.label));return{...y,[n.id]:[...L,...Re]}})}n.tool_calls?.push({id:"call_"+d.generateUid(24),type:"function",function:{name:$,arguments:A}}),l(v=>{const y=[...v],L=y.findIndex(F=>F.id===n.id);return y[L]={...n},y}),we?.(g,{conversation:{...te(),messages:[...o.current,n]}})}),h.on("error",ne),h.finalChatCompletion().then(async()=>{o.current=[...o.current,n],k.current=null,C(!1),M(!1),E(),await _({eventName:"assistant_message_received",properties:{}},o.current),_({eventName:"assistant_answer_displayed",properties:{}})}).catch(g=>{g instanceof ce.APIUserAbortError||console.warn(g)}),k.current=h.controller}catch(u){ne(u),C(!1),M(!1)}},Ee=()=>{k.current&&(k.current.abort(),k.current=null),C(!1),M(!1),E()},oe=()=>{Y(null),l([]),o.current=[],me(),ee({}),b([]),le.resetQueryParams(),Z(null),j(),E(),_({eventName:"chat_clear_button_clicked",properties:{conversation:de}})},Ue=e=>{Z(e);const{initialReplyMessage:s,displayName:a}=e,r={id:m.length.toString()+d.generateUid(4),role:"user",content:a},p={id:(m.length+1).toString()+d.generateUid(4),role:"assistant",content:s,links:[]},f=[{id:`system-${Date.now().toString()}-${d.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
6
|
+
${K.serializeWorkflow(e)}`},...se,r,p];l(f),b([])},{openForm:Ne}=Te.useChatForm(),Ae=Ke.useWidget();t.useImperativeHandle(Q.chatFunctionsRef,()=>({submitMessage:O,updateInputMessage(e){x(e)},clearChat:oe,openForm:e=>{Ae?.setView("chat"),Ne(e)},focusInput:()=>{V.current?.focus()}}));const Le=Qe.useMediaQuery("(max-width: 768px)");return{messages:m,input:w,isLoading:X,isStreaming:Ce,isLoadingConversation:ke,error:Me,isSubmitDisabled:R,handleInputChange:qe,handleInputKeyDown:Pe,handleSubmit:O,stop:Ee,clear:oe,handleWorkflow:Ue,selectedWorkflow:B,messageAttachments:I,setMessageAttachments:b,addAttachment:Ie,messageButtons:be,isEmpty:m.length===0,inputRef:V,isMobile:Le}};exports.useInkeepChat=Ge;
|
|
@@ -1,94 +1,96 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { useState as l, useRef as W, useEffect as
|
|
4
|
-
import { useInkeepConfig as
|
|
5
|
-
import { useInkeepConversation as
|
|
6
|
-
import { useChatEvents as
|
|
7
|
-
import { getMessageMetadata as
|
|
8
|
-
import { resetQueryParams as
|
|
9
|
-
import { useChatForm as
|
|
10
|
-
import { useWidget as
|
|
11
|
-
import { useMediaQuery as
|
|
12
|
-
import { useCaptcha as
|
|
13
|
-
import { useModal as
|
|
2
|
+
import Ue, { APIUserAbortError as Fe } from "openai";
|
|
3
|
+
import { useState as l, useRef as W, useEffect as ce, useImperativeHandle as Ke } from "react";
|
|
4
|
+
import { useInkeepConfig as Te } from "../../providers/config-provider.js";
|
|
5
|
+
import { useInkeepConversation as We } from "../../providers/conversation-provider.js";
|
|
6
|
+
import { useChatEvents as Je } from "../../providers/chat-events-provider.js";
|
|
7
|
+
import { getMessageMetadata as ze, serializeAttachments as He, serializeWorkflow as Qe } from "../../utils/get-message-metadata.js";
|
|
8
|
+
import { resetQueryParams as le } from "../../utils/reset-query-params.js";
|
|
9
|
+
import { useChatForm as je } from "../../providers/chat-form-provider.js";
|
|
10
|
+
import { useWidget as qe } from "../../providers/widget-provider.js";
|
|
11
|
+
import { useMediaQuery as Ge } from "../../hooks/use-media-query.js";
|
|
12
|
+
import { useCaptcha as Ve } from "./use-captcha.js";
|
|
13
|
+
import { useModal as Xe } from "../modal/modal-provider.js";
|
|
14
14
|
import { generateUid as g } from "../../utils/generate-uid.js";
|
|
15
|
-
import { provideLinksTool as
|
|
16
|
-
import { getConversation as
|
|
17
|
-
import { parseIfJson as
|
|
18
|
-
const
|
|
19
|
-
const { chatId: w, isSharedChat:
|
|
15
|
+
import { provideLinksTool as Ye } from "../../utils/tools/links-tool.js";
|
|
16
|
+
import { getConversation as Ze } from "../../atoms/api/analytics/conversation.js";
|
|
17
|
+
import { parseIfJson as et } from "../../utils/misc.js";
|
|
18
|
+
const yt = () => {
|
|
19
|
+
const { chatId: w, isSharedChat: ue, setConversation: me, conversation: ge, resetConversation: pe } = We(), { baseSettings: N, aiChatSettings: J } = Te(), { aiApiBaseUrl: z, shouldBypassCaptcha: H, filters: Q } = N, j = Xe(), { getSolution: de, prefetchSolution: A, invalidateSolution: q } = Ve({
|
|
20
20
|
fetchUrl: `${z}/v1/challenge`,
|
|
21
21
|
shouldBypassCaptcha: H,
|
|
22
22
|
shouldMakeInitialRequest: j ? j.isOpen : !0
|
|
23
|
-
}),
|
|
23
|
+
}), fe = new Ue({
|
|
24
24
|
baseURL: `${z}/v1`,
|
|
25
25
|
apiKey: N.apiKey ?? "",
|
|
26
26
|
dangerouslyAllowBrowser: !0
|
|
27
27
|
}), {
|
|
28
|
-
onInputMessageChange:
|
|
29
|
-
getTools:
|
|
30
|
-
prompts:
|
|
31
|
-
model:
|
|
28
|
+
onInputMessageChange: he,
|
|
29
|
+
getTools: ye,
|
|
30
|
+
prompts: ve,
|
|
31
|
+
model: we,
|
|
32
32
|
filters: G,
|
|
33
|
-
onToolCall:
|
|
34
|
-
} = J, [C,
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
onToolCall: Ce
|
|
34
|
+
} = J, [C, D] = l(""), V = W(null);
|
|
35
|
+
ce(() => {
|
|
36
|
+
he?.(C);
|
|
37
37
|
}, [C]);
|
|
38
|
-
const [p, c] = l([]), [X, I] = l(!1), [
|
|
39
|
-
b((
|
|
40
|
-
}, [
|
|
41
|
-
id: `system-${Date.now().toString()}-${g(4)}-${
|
|
38
|
+
const [p, c] = l([]), [X, I] = l(!1), [Ie, M] = l(!1), [Me, Y] = l(null), [O, Z] = l(null), [S, b] = l([]), Se = (e) => {
|
|
39
|
+
b((t) => [...t, e]);
|
|
40
|
+
}, [be, ee] = l({}), n = W([]), k = W(null), { logEvent: _, getLatestConversation: te } = Je(), se = ve?.map((e, t) => ({
|
|
41
|
+
id: `system-${Date.now().toString()}-${g(4)}-${t}`,
|
|
42
42
|
role: "system",
|
|
43
|
-
content:
|
|
44
|
-
})), [
|
|
45
|
-
|
|
43
|
+
content: e
|
|
44
|
+
})), [ke, _e] = l(!!w);
|
|
45
|
+
ce(() => {
|
|
46
46
|
if (w) {
|
|
47
|
-
const { apiKey:
|
|
48
|
-
|
|
47
|
+
const { apiKey: e, analyticsApiBaseUrl: t } = N;
|
|
48
|
+
Ze(w, e, t).then((o) => {
|
|
49
49
|
if (o) {
|
|
50
50
|
_({
|
|
51
51
|
eventName: "shared_chat_loaded",
|
|
52
52
|
properties: {
|
|
53
53
|
conversation: o
|
|
54
54
|
}
|
|
55
|
-
}),
|
|
55
|
+
}), _e(!1), me({ ...o });
|
|
56
56
|
const a = o.messages.map((d) => ({
|
|
57
57
|
...d,
|
|
58
|
-
content:
|
|
58
|
+
content: et(d.content)
|
|
59
59
|
}));
|
|
60
60
|
c(a), n.current = a;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
}, [w]);
|
|
65
|
-
const $
|
|
65
|
+
const $e = (e) => e.status === 403 || e.status === 401 ? `There seems to be a configuration error. Please contact ${N.organizationDisplayName ?? "Administrator"}.` : e.error?.message ? `${e.error.message}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
Please clear the chat and try again.` : `Hmm..
|
|
68
|
+
|
|
69
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`, ne = (e) => {
|
|
70
|
+
Y(e), c((t) => {
|
|
71
|
+
const o = [...t], a = o[o.length - 1];
|
|
72
|
+
return a && (a.content = $e(e)), o;
|
|
71
73
|
}), I(!1), M(!1), q(), A();
|
|
72
|
-
}, R = !C.trim() && !S.length || X,
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}, U = async (
|
|
78
|
-
if (R && (!
|
|
74
|
+
}, R = !C.trim() && !S.length || X, Ee = (e) => {
|
|
75
|
+
e.key === "Enter" && !e.shiftKey && !R && !e.nativeEvent.isComposing && (e.preventDefault(), U());
|
|
76
|
+
}, Ne = (e) => {
|
|
77
|
+
const t = e.target.value;
|
|
78
|
+
D(t);
|
|
79
|
+
}, U = async (e = C) => {
|
|
80
|
+
if (R && (!e || e.trim().length === 0)) return;
|
|
79
81
|
I(!0);
|
|
80
|
-
const
|
|
82
|
+
const t = O ? p.length === 2 : p.length === 0, o = ze(O, S, t);
|
|
81
83
|
let a;
|
|
82
|
-
const d =
|
|
83
|
-
S.length && d ? a = [{ type: "text", text: d }] : a =
|
|
84
|
-
const
|
|
84
|
+
const d = He(S);
|
|
85
|
+
S.length && d ? a = [{ type: "text", text: d }] : a = e;
|
|
86
|
+
const ae = {
|
|
85
87
|
id: `${Date.now().toString()}-${g(4)}-1`,
|
|
86
88
|
role: "user",
|
|
87
89
|
content: a,
|
|
88
90
|
metadata: o
|
|
89
|
-
}, f = [...p.length ? [] :
|
|
90
|
-
if (
|
|
91
|
-
|
|
91
|
+
}, f = [...p.length ? [] : se, ae];
|
|
92
|
+
if (ue && w) {
|
|
93
|
+
le();
|
|
92
94
|
const u = n.current.map((r, x) => ({
|
|
93
95
|
id: `${r.id}-${g(6)}-${x}`,
|
|
94
96
|
role: r.role,
|
|
@@ -100,27 +102,27 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
100
102
|
c([...u, ...f]), n.current = [...u, ...f];
|
|
101
103
|
} else
|
|
102
104
|
c((u) => [...u, ...f]), n.current = [...n.current, ...f];
|
|
103
|
-
b([]),
|
|
105
|
+
b([]), D(""), _(
|
|
104
106
|
{
|
|
105
107
|
eventName: "user_message_submitted",
|
|
106
108
|
properties: {}
|
|
107
109
|
},
|
|
108
110
|
n.current
|
|
109
111
|
);
|
|
110
|
-
const
|
|
112
|
+
const De = te(), re = [Ye, ...ye?.({ conversation: De }) || []];
|
|
111
113
|
try {
|
|
112
114
|
const u = {
|
|
113
|
-
model:
|
|
115
|
+
model: we,
|
|
114
116
|
messages: n.current,
|
|
115
117
|
stream: !0,
|
|
116
|
-
tools:
|
|
118
|
+
tools: re,
|
|
117
119
|
tool_choice: "auto"
|
|
118
|
-
}, r = await
|
|
120
|
+
}, r = await de(), x = r ? btoa(JSON.stringify(r)) : null, ie = Q || G ? JSON.stringify({
|
|
119
121
|
...Q,
|
|
120
122
|
...G
|
|
121
123
|
}) : void 0, L = {};
|
|
122
|
-
!H && x && (L["X-INKEEP-CHALLENGE-SOLUTION"] = x),
|
|
123
|
-
const h =
|
|
124
|
+
!H && x && (L["X-INKEEP-CHALLENGE-SOLUTION"] = x), ie && (L["inkeep-filters"] = ie);
|
|
125
|
+
const h = fe.beta.chat.completions.stream(
|
|
124
126
|
u,
|
|
125
127
|
Object.keys(L).length > 0 ? { headers: L } : void 0
|
|
126
128
|
), s = {
|
|
@@ -136,18 +138,18 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
136
138
|
return F === -1 ? [...i, s] : (i[F] = { ...s }, i);
|
|
137
139
|
});
|
|
138
140
|
}), h.on("tool_calls.function.arguments.done", async (m) => {
|
|
139
|
-
const { name: $, arguments: B } = m, i =
|
|
141
|
+
const { name: $, arguments: B } = m, i = re?.find((y) => y.function.name === $);
|
|
140
142
|
if (!i) return;
|
|
141
|
-
const E = ("parse" in i.function ? i.function.parse : JSON.parse)(B),
|
|
143
|
+
const E = ("parse" in i.function ? i.function.parse : JSON.parse)(B), Oe = i.function.function?.(E, h);
|
|
142
144
|
if ($ === "provideLinks")
|
|
143
145
|
s.links = E.links ?? [];
|
|
144
146
|
else {
|
|
145
|
-
const y = i.renderMessageButtons?.({ args: E, execution:
|
|
146
|
-
y.length > 0 &&
|
|
147
|
-
const
|
|
147
|
+
const y = i.renderMessageButtons?.({ args: E, execution: Oe }) ?? [];
|
|
148
|
+
y.length > 0 && ee((v) => {
|
|
149
|
+
const P = v[s.id] ?? [], K = new Set(P.map((T) => T.label)), Re = y.filter((T) => !K.has(T.label));
|
|
148
150
|
return {
|
|
149
151
|
...v,
|
|
150
|
-
[s.id]: [...
|
|
152
|
+
[s.id]: [...P, ...Re]
|
|
151
153
|
};
|
|
152
154
|
});
|
|
153
155
|
}
|
|
@@ -159,15 +161,15 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
159
161
|
arguments: B
|
|
160
162
|
}
|
|
161
163
|
}), c((y) => {
|
|
162
|
-
const v = [...y],
|
|
163
|
-
return v[
|
|
164
|
-
}),
|
|
164
|
+
const v = [...y], P = v.findIndex((K) => K.id === s.id);
|
|
165
|
+
return v[P] = { ...s }, v;
|
|
166
|
+
}), Ce?.(m, {
|
|
165
167
|
conversation: {
|
|
166
|
-
...
|
|
168
|
+
...te(),
|
|
167
169
|
messages: [...n.current, s]
|
|
168
170
|
}
|
|
169
171
|
});
|
|
170
|
-
}), h.on("error",
|
|
172
|
+
}), h.on("error", ne), h.finalChatCompletion().then(async () => {
|
|
171
173
|
n.current = [...n.current, s], k.current = null, I(!1), M(!1), A(), await _(
|
|
172
174
|
{
|
|
173
175
|
eventName: "assistant_message_received",
|
|
@@ -179,77 +181,77 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
179
181
|
properties: {}
|
|
180
182
|
});
|
|
181
183
|
}).catch((m) => {
|
|
182
|
-
m instanceof
|
|
184
|
+
m instanceof Fe || console.warn(m);
|
|
183
185
|
}), k.current = h.controller;
|
|
184
186
|
} catch (u) {
|
|
185
|
-
|
|
187
|
+
ne(u), I(!1), M(!1);
|
|
186
188
|
}
|
|
187
|
-
},
|
|
189
|
+
}, Ae = () => {
|
|
188
190
|
k.current && (k.current.abort(), k.current = null), I(!1), M(!1), A();
|
|
189
|
-
},
|
|
190
|
-
Y(null), c([]), n.current = [],
|
|
191
|
+
}, oe = () => {
|
|
192
|
+
Y(null), c([]), n.current = [], pe(), ee({}), b([]), le(), Z(null), q(), A(), _({
|
|
191
193
|
eventName: "chat_clear_button_clicked",
|
|
192
194
|
properties: {
|
|
193
|
-
conversation:
|
|
195
|
+
conversation: ge
|
|
194
196
|
}
|
|
195
197
|
});
|
|
196
|
-
},
|
|
197
|
-
Z(
|
|
198
|
-
const { initialReplyMessage:
|
|
198
|
+
}, xe = (e) => {
|
|
199
|
+
Z(e);
|
|
200
|
+
const { initialReplyMessage: t, displayName: o } = e, a = {
|
|
199
201
|
id: p.length.toString() + g(4),
|
|
200
202
|
role: "user",
|
|
201
203
|
content: o
|
|
202
204
|
}, d = {
|
|
203
205
|
id: (p.length + 1).toString() + g(4),
|
|
204
206
|
role: "assistant",
|
|
205
|
-
content:
|
|
207
|
+
content: t,
|
|
206
208
|
links: []
|
|
207
209
|
}, f = [{
|
|
208
|
-
id: `system-${Date.now().toString()}-${g(4)}-${
|
|
210
|
+
id: `system-${Date.now().toString()}-${g(4)}-${e.id}`,
|
|
209
211
|
role: "system",
|
|
210
212
|
content: `Company has asked user to follow this guided workflow:
|
|
211
|
-
${
|
|
212
|
-
}, ...
|
|
213
|
+
${Qe(e)}`
|
|
214
|
+
}, ...se, a, d];
|
|
213
215
|
c(f), b([]);
|
|
214
|
-
}, { openForm:
|
|
215
|
-
|
|
216
|
+
}, { openForm: Le } = je(), Be = qe();
|
|
217
|
+
Ke(J.chatFunctionsRef, () => ({
|
|
216
218
|
submitMessage: U,
|
|
217
|
-
updateInputMessage(
|
|
218
|
-
|
|
219
|
+
updateInputMessage(e) {
|
|
220
|
+
D(e);
|
|
219
221
|
},
|
|
220
|
-
clearChat:
|
|
221
|
-
openForm: (
|
|
222
|
-
|
|
222
|
+
clearChat: oe,
|
|
223
|
+
openForm: (e) => {
|
|
224
|
+
Be?.setView("chat"), Le(e);
|
|
223
225
|
},
|
|
224
226
|
focusInput: () => {
|
|
225
227
|
V.current?.focus();
|
|
226
228
|
}
|
|
227
229
|
}));
|
|
228
|
-
const
|
|
230
|
+
const Pe = Ge("(max-width: 768px)");
|
|
229
231
|
return {
|
|
230
232
|
messages: p,
|
|
231
233
|
input: C,
|
|
232
234
|
isLoading: X,
|
|
233
|
-
isStreaming:
|
|
234
|
-
isLoadingConversation:
|
|
235
|
-
error:
|
|
235
|
+
isStreaming: Ie,
|
|
236
|
+
isLoadingConversation: ke,
|
|
237
|
+
error: Me,
|
|
236
238
|
isSubmitDisabled: R,
|
|
237
|
-
handleInputChange:
|
|
238
|
-
handleInputKeyDown:
|
|
239
|
+
handleInputChange: Ne,
|
|
240
|
+
handleInputKeyDown: Ee,
|
|
239
241
|
handleSubmit: U,
|
|
240
|
-
stop:
|
|
241
|
-
clear:
|
|
242
|
-
handleWorkflow:
|
|
243
|
-
selectedWorkflow:
|
|
242
|
+
stop: Ae,
|
|
243
|
+
clear: oe,
|
|
244
|
+
handleWorkflow: xe,
|
|
245
|
+
selectedWorkflow: O,
|
|
244
246
|
messageAttachments: S,
|
|
245
247
|
setMessageAttachments: b,
|
|
246
|
-
addAttachment:
|
|
247
|
-
messageButtons:
|
|
248
|
+
addAttachment: Se,
|
|
249
|
+
messageButtons: be,
|
|
248
250
|
isEmpty: p.length === 0,
|
|
249
251
|
inputRef: V,
|
|
250
|
-
isMobile:
|
|
252
|
+
isMobile: Pe
|
|
251
253
|
};
|
|
252
254
|
};
|
|
253
255
|
export {
|
|
254
|
-
|
|
256
|
+
yt as useInkeepChat
|
|
255
257
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.119",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
|
|
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
|
|
|
7
7
|
const u = B(void 0), $ = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.119",
|
|
11
11
|
componentType: s,
|
|
12
12
|
tags: a
|
|
13
13
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.119",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"remark-gfm": "^4.0.1",
|
|
69
69
|
"unist-util-visit": "^5.0.0",
|
|
70
70
|
"use-sync-external-store": "^1.4.0",
|
|
71
|
-
"@inkeep/cxkit-color-mode": "^0.5.
|
|
72
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
73
|
-
"@inkeep/cxkit-types": "0.5.
|
|
71
|
+
"@inkeep/cxkit-color-mode": "^0.5.119",
|
|
72
|
+
"@inkeep/cxkit-theme": "0.5.119",
|
|
73
|
+
"@inkeep/cxkit-types": "0.5.119"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@biomejs/biome": "1.9.4",
|