@inkeep/cxkit-primitives 0.5.109 → 0.5.111
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,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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:P,aiChatSettings:Q}=Oe.useInkeepConfig(),{aiApiBaseUrl:W,shouldBypassCaptcha:J,filters:z}=P,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:P.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}=P;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=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${P.organizationDisplayName??"Administrator"}`;default:return`Hmm..
|
|
2
2
|
|
|
3
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`}},
|
|
4
|
-
${
|
|
3
|
+
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,qe=e=>{e.key==="Enter"&&!e.shiftKey&&!R&&!e.nativeEvent.isComposing&&(e.preventDefault(),O())},Pe=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(q=>q.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 q=("parse"in c.function?c.function.parse:JSON.parse)(A),Be=c.function.function?.(q,h);if($==="provideLinks")n.links=q.links??[];else{const v=c.renderMessageButtons?.({args:q,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:
|
|
4
|
+
${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:Pe,handleInputKeyDown:qe,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,105 +1,105 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { useState as l, useRef 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:
|
|
20
|
-
fetchUrl: `${
|
|
21
|
-
shouldBypassCaptcha:
|
|
22
|
-
shouldMakeInitialRequest:
|
|
23
|
-
}),
|
|
24
|
-
baseURL: `${
|
|
25
|
-
apiKey:
|
|
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
|
+
fetchUrl: `${z}/v1/challenge`,
|
|
21
|
+
shouldBypassCaptcha: H,
|
|
22
|
+
shouldMakeInitialRequest: j ? j.isOpen : !0
|
|
23
|
+
}), fe = new Ue({
|
|
24
|
+
baseURL: `${z}/v1`,
|
|
25
|
+
apiKey: N.apiKey ?? "",
|
|
26
26
|
dangerouslyAllowBrowser: !0
|
|
27
27
|
}), {
|
|
28
|
-
onInputMessageChange:
|
|
29
|
-
getTools:
|
|
30
|
-
prompts:
|
|
31
|
-
model:
|
|
32
|
-
filters:
|
|
33
|
-
onToolCall:
|
|
34
|
-
} =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
const [p, c] = l([]), [
|
|
39
|
-
|
|
40
|
-
}, [
|
|
28
|
+
onInputMessageChange: he,
|
|
29
|
+
getTools: ye,
|
|
30
|
+
prompts: ve,
|
|
31
|
+
model: we,
|
|
32
|
+
filters: G,
|
|
33
|
+
onToolCall: Ce
|
|
34
|
+
} = J, [C, O] = l(""), V = W(null);
|
|
35
|
+
ce(() => {
|
|
36
|
+
he?.(C);
|
|
37
|
+
}, [C]);
|
|
38
|
+
const [p, c] = l([]), [X, I] = l(!1), [Ie, M] = l(!1), [Me, Y] = l(null), [P, 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
41
|
id: `system-${Date.now().toString()}-${g(4)}-${t}`,
|
|
42
42
|
role: "system",
|
|
43
43
|
content: e
|
|
44
|
-
})), [
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
const { apiKey: e, analyticsApiBaseUrl: t } =
|
|
48
|
-
|
|
44
|
+
})), [ke, _e] = l(!!w);
|
|
45
|
+
ce(() => {
|
|
46
|
+
if (w) {
|
|
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
|
-
}, [
|
|
65
|
-
const
|
|
64
|
+
}, [w]);
|
|
65
|
+
const $e = (e) => {
|
|
66
66
|
switch (e.code) {
|
|
67
67
|
case 400:
|
|
68
68
|
return e.message;
|
|
69
69
|
case 403:
|
|
70
|
-
return `There seems to be a configuration error. Please contact ${
|
|
70
|
+
return `There seems to be a configuration error. Please contact ${N.organizationDisplayName ?? "Administrator"}`;
|
|
71
71
|
default:
|
|
72
72
|
return `Hmm..
|
|
73
73
|
|
|
74
74
|
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
75
75
|
}
|
|
76
|
-
},
|
|
77
|
-
|
|
76
|
+
}, ne = (e) => {
|
|
77
|
+
Y(e), c((t) => {
|
|
78
78
|
const o = [...t], a = o[o.length - 1];
|
|
79
|
-
return a && (a.content =
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
e.key === "Enter" && !e.shiftKey && !
|
|
83
|
-
},
|
|
79
|
+
return a && (a.content = $e(e)), o;
|
|
80
|
+
}), I(!1), M(!1), q(), A();
|
|
81
|
+
}, R = !C.trim() && !S.length || X, Ee = (e) => {
|
|
82
|
+
e.key === "Enter" && !e.shiftKey && !R && !e.nativeEvent.isComposing && (e.preventDefault(), U());
|
|
83
|
+
}, Ne = (e) => {
|
|
84
84
|
const t = e.target.value;
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
const t =
|
|
85
|
+
O(t);
|
|
86
|
+
}, U = async (e = C) => {
|
|
87
|
+
if (R && (!e || e.trim().length === 0)) return;
|
|
88
|
+
I(!0);
|
|
89
|
+
const t = P ? p.length === 2 : p.length === 0, o = ze(P, S, t);
|
|
90
90
|
let a;
|
|
91
|
-
const d =
|
|
92
|
-
|
|
93
|
-
const
|
|
91
|
+
const d = He(S);
|
|
92
|
+
S.length && d ? a = [{ type: "text", text: d }] : a = e;
|
|
93
|
+
const ae = {
|
|
94
94
|
id: `${Date.now().toString()}-${g(4)}-1`,
|
|
95
95
|
role: "user",
|
|
96
96
|
content: a,
|
|
97
97
|
metadata: o
|
|
98
|
-
}, f = [...p.length ? [] :
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
const u = n.current.map((r,
|
|
102
|
-
id: `${r.id}-${g(6)}-${
|
|
98
|
+
}, f = [...p.length ? [] : se, ae];
|
|
99
|
+
if (ue && w) {
|
|
100
|
+
le();
|
|
101
|
+
const u = n.current.map((r, x) => ({
|
|
102
|
+
id: `${r.id}-${g(6)}-${x}`,
|
|
103
103
|
role: r.role,
|
|
104
104
|
...r.role === "assistant" ? { links: r.links ?? [] } : {},
|
|
105
105
|
content: r.content,
|
|
@@ -109,27 +109,27 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
109
109
|
c([...u, ...f]), n.current = [...u, ...f];
|
|
110
110
|
} else
|
|
111
111
|
c((u) => [...u, ...f]), n.current = [...n.current, ...f];
|
|
112
|
-
|
|
112
|
+
b([]), O(""), _(
|
|
113
113
|
{
|
|
114
114
|
eventName: "user_message_submitted",
|
|
115
115
|
properties: {}
|
|
116
116
|
},
|
|
117
117
|
n.current
|
|
118
118
|
);
|
|
119
|
-
const
|
|
119
|
+
const Oe = te(), re = [Ye, ...ye?.({ conversation: Oe }) || []];
|
|
120
120
|
try {
|
|
121
121
|
const u = {
|
|
122
|
-
model:
|
|
122
|
+
model: we,
|
|
123
123
|
messages: n.current,
|
|
124
124
|
stream: !0,
|
|
125
|
-
tools:
|
|
125
|
+
tools: re,
|
|
126
126
|
tool_choice: "auto"
|
|
127
|
-
}, r = await
|
|
128
|
-
...
|
|
129
|
-
...
|
|
127
|
+
}, r = await de(), x = r ? btoa(JSON.stringify(r)) : null, ie = Q || G ? JSON.stringify({
|
|
128
|
+
...Q,
|
|
129
|
+
...G
|
|
130
130
|
}) : void 0, L = {};
|
|
131
|
-
!
|
|
132
|
-
const h =
|
|
131
|
+
!H && x && (L["X-INKEEP-CHALLENGE-SOLUTION"] = x), ie && (L["inkeep-filters"] = ie);
|
|
132
|
+
const h = fe.beta.chat.completions.stream(
|
|
133
133
|
u,
|
|
134
134
|
Object.keys(L).length > 0 ? { headers: L } : void 0
|
|
135
135
|
), s = {
|
|
@@ -139,36 +139,45 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
139
139
|
links: [],
|
|
140
140
|
tool_calls: []
|
|
141
141
|
};
|
|
142
|
-
c((m) => [...m, s]), h.on("content", (m,
|
|
143
|
-
|
|
144
|
-
const i = [...
|
|
145
|
-
return
|
|
142
|
+
c((m) => [...m, s]), h.on("content", (m, $) => {
|
|
143
|
+
M(!0), s.content = $, c((B) => {
|
|
144
|
+
const i = [...B], F = i.findIndex((E) => E.id === s.id);
|
|
145
|
+
return F === -1 ? [...i, s] : (i[F] = { ...s }, i);
|
|
146
146
|
});
|
|
147
147
|
}), h.on("tool_calls.function.arguments.done", async (m) => {
|
|
148
|
-
const { name:
|
|
148
|
+
const { name: $, arguments: B } = m, i = re?.find((y) => y.function.name === $);
|
|
149
149
|
if (!i) return;
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
const E = ("parse" in i.function ? i.function.parse : JSON.parse)(B), Pe = i.function.function?.(E, h);
|
|
151
|
+
if ($ === "provideLinks")
|
|
152
|
+
s.links = E.links ?? [];
|
|
153
|
+
else {
|
|
154
|
+
const y = i.renderMessageButtons?.({ args: E, execution: Pe }) ?? [];
|
|
155
|
+
y.length > 0 && ee((v) => {
|
|
156
|
+
const D = v[s.id] ?? [], K = new Set(D.map((T) => T.label)), Re = y.filter((T) => !K.has(T.label));
|
|
157
|
+
return {
|
|
158
|
+
...v,
|
|
159
|
+
[s.id]: [...D, ...Re]
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
s.tool_calls?.push({
|
|
155
164
|
id: "call_" + g(24),
|
|
156
165
|
type: "function",
|
|
157
166
|
function: {
|
|
158
|
-
name:
|
|
159
|
-
arguments:
|
|
167
|
+
name: $,
|
|
168
|
+
arguments: B
|
|
160
169
|
}
|
|
161
170
|
}), c((y) => {
|
|
162
|
-
const
|
|
163
|
-
return
|
|
164
|
-
}),
|
|
171
|
+
const v = [...y], D = v.findIndex((K) => K.id === s.id);
|
|
172
|
+
return v[D] = { ...s }, v;
|
|
173
|
+
}), Ce?.(m, {
|
|
165
174
|
conversation: {
|
|
166
|
-
...
|
|
175
|
+
...te(),
|
|
167
176
|
messages: [...n.current, s]
|
|
168
177
|
}
|
|
169
178
|
});
|
|
170
|
-
}), h.on("error",
|
|
171
|
-
n.current = [...n.current, s], k.current = null,
|
|
179
|
+
}), h.on("error", ne), h.finalChatCompletion().then(async () => {
|
|
180
|
+
n.current = [...n.current, s], k.current = null, I(!1), M(!1), A(), await _(
|
|
172
181
|
{
|
|
173
182
|
eventName: "assistant_message_received",
|
|
174
183
|
properties: {}
|
|
@@ -179,22 +188,22 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
179
188
|
properties: {}
|
|
180
189
|
});
|
|
181
190
|
}).catch((m) => {
|
|
182
|
-
m instanceof
|
|
191
|
+
m instanceof Fe || console.warn(m);
|
|
183
192
|
}), k.current = h.controller;
|
|
184
193
|
} catch (u) {
|
|
185
|
-
|
|
194
|
+
ne(u), I(!1), M(!1);
|
|
186
195
|
}
|
|
187
|
-
},
|
|
188
|
-
k.current && (k.current.abort(), k.current = null),
|
|
189
|
-
},
|
|
190
|
-
|
|
196
|
+
}, Ae = () => {
|
|
197
|
+
k.current && (k.current.abort(), k.current = null), I(!1), M(!1), A();
|
|
198
|
+
}, oe = () => {
|
|
199
|
+
Y(null), c([]), n.current = [], pe(), ee({}), b([]), le(), Z(null), q(), A(), _({
|
|
191
200
|
eventName: "chat_clear_button_clicked",
|
|
192
201
|
properties: {
|
|
193
|
-
conversation:
|
|
202
|
+
conversation: ge
|
|
194
203
|
}
|
|
195
204
|
});
|
|
196
|
-
},
|
|
197
|
-
|
|
205
|
+
}, xe = (e) => {
|
|
206
|
+
Z(e);
|
|
198
207
|
const { initialReplyMessage: t, displayName: o } = e, a = {
|
|
199
208
|
id: p.length.toString() + g(4),
|
|
200
209
|
role: "user",
|
|
@@ -208,48 +217,48 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
208
217
|
id: `system-${Date.now().toString()}-${g(4)}-${e.id}`,
|
|
209
218
|
role: "system",
|
|
210
219
|
content: `Company has asked user to follow this guided workflow:
|
|
211
|
-
${
|
|
212
|
-
}, ...
|
|
213
|
-
c(f),
|
|
214
|
-
}, { openForm:
|
|
215
|
-
|
|
216
|
-
submitMessage:
|
|
220
|
+
${Qe(e)}`
|
|
221
|
+
}, ...se, a, d];
|
|
222
|
+
c(f), b([]);
|
|
223
|
+
}, { openForm: Le } = je(), Be = qe();
|
|
224
|
+
Ke(J.chatFunctionsRef, () => ({
|
|
225
|
+
submitMessage: U,
|
|
217
226
|
updateInputMessage(e) {
|
|
218
|
-
|
|
227
|
+
O(e);
|
|
219
228
|
},
|
|
220
|
-
clearChat:
|
|
229
|
+
clearChat: oe,
|
|
221
230
|
openForm: (e) => {
|
|
222
|
-
|
|
231
|
+
Be?.setView("chat"), Le(e);
|
|
223
232
|
},
|
|
224
233
|
focusInput: () => {
|
|
225
|
-
|
|
234
|
+
V.current?.focus();
|
|
226
235
|
}
|
|
227
236
|
}));
|
|
228
|
-
const
|
|
237
|
+
const De = Ge("(max-width: 768px)");
|
|
229
238
|
return {
|
|
230
239
|
messages: p,
|
|
231
|
-
input:
|
|
232
|
-
isLoading:
|
|
233
|
-
isStreaming:
|
|
234
|
-
isLoadingConversation:
|
|
235
|
-
error:
|
|
236
|
-
isSubmitDisabled:
|
|
237
|
-
handleInputChange:
|
|
238
|
-
handleInputKeyDown:
|
|
239
|
-
handleSubmit:
|
|
240
|
-
stop:
|
|
241
|
-
clear:
|
|
242
|
-
handleWorkflow:
|
|
243
|
-
selectedWorkflow:
|
|
244
|
-
messageAttachments:
|
|
245
|
-
setMessageAttachments:
|
|
246
|
-
addAttachment:
|
|
247
|
-
messageButtons:
|
|
240
|
+
input: C,
|
|
241
|
+
isLoading: X,
|
|
242
|
+
isStreaming: Ie,
|
|
243
|
+
isLoadingConversation: ke,
|
|
244
|
+
error: Me,
|
|
245
|
+
isSubmitDisabled: R,
|
|
246
|
+
handleInputChange: Ne,
|
|
247
|
+
handleInputKeyDown: Ee,
|
|
248
|
+
handleSubmit: U,
|
|
249
|
+
stop: Ae,
|
|
250
|
+
clear: oe,
|
|
251
|
+
handleWorkflow: xe,
|
|
252
|
+
selectedWorkflow: P,
|
|
253
|
+
messageAttachments: S,
|
|
254
|
+
setMessageAttachments: b,
|
|
255
|
+
addAttachment: Se,
|
|
256
|
+
messageButtons: be,
|
|
248
257
|
isEmpty: p.length === 0,
|
|
249
|
-
inputRef:
|
|
250
|
-
isMobile:
|
|
258
|
+
inputRef: V,
|
|
259
|
+
isMobile: De
|
|
251
260
|
};
|
|
252
261
|
};
|
|
253
262
|
export {
|
|
254
|
-
|
|
263
|
+
yt as useInkeepChat
|
|
255
264
|
};
|
|
@@ -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.111",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.111",
|
|
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.111",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"remark-gfm": "^4.0.1",
|
|
68
68
|
"unist-util-visit": "^5.0.0",
|
|
69
69
|
"use-sync-external-store": "^1.4.0",
|
|
70
|
-
"@inkeep/cxkit-color-mode": "^0.5.
|
|
71
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
72
|
-
"@inkeep/cxkit-types": "0.5.
|
|
70
|
+
"@inkeep/cxkit-color-mode": "^0.5.111",
|
|
71
|
+
"@inkeep/cxkit-theme": "0.5.111",
|
|
72
|
+
"@inkeep/cxkit-types": "0.5.111"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@biomejs/biome": "1.9.4",
|