@inkeep/cxkit-primitives 0.5.36 → 0.5.38
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/atoms/cmdk/index.cjs +1 -1
- package/dist/atoms/cmdk/index.js +328 -320
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +138 -143
- package/dist/components/embedded-chat.cjs +2 -2
- package/dist/components/embedded-chat.js +306 -306
- package/dist/components/embedded-search/search-provider.cjs +1 -1
- package/dist/components/embedded-search/search-provider.js +19 -12
- package/dist/components/embedded-search/transform-results.cjs +1 -1
- package/dist/components/embedded-search/transform-results.js +56 -72
- package/dist/components/embedded-search/url-query.cjs +1 -0
- package/dist/components/embedded-search/url-query.js +12 -0
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
- package/dist/components/embedded-search/use-inkeep-search.js +27 -149
- package/dist/components/embedded-search/use-search-filter.cjs +1 -0
- package/dist/components/embedded-search/use-search-filter.js +91 -0
- package/dist/components/embedded-search.cjs +1 -1
- package/dist/components/embedded-search.js +372 -365
- package/dist/components/intelligent-form/actions/escalation-schema.cjs +1 -1
- package/dist/components/intelligent-form/actions/escalation-schema.js +1 -2
- package/dist/constants/search.cjs +1 -0
- package/dist/constants/search.js +5 -0
- package/dist/index.d.cts +17 -122
- package/dist/index.d.ts +17 -122
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/providers/config-provider.cjs +1 -1
- package/dist/providers/config-provider.js +15 -15
- package/dist/utils/component-ids.cjs +1 -1
- package/dist/utils/component-ids.js +1 -1
- package/dist/utils/default-settings.cjs +1 -1
- package/dist/utils/default-settings.js +7 -21
- package/dist/utils/tools/{links-schema.cjs → links-tool.cjs} +1 -1
- package/dist/utils/tools/{links-schema.js → links-tool.js} +13 -4
- package/package.json +4 -4
|
@@ -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 _e=require("openai"),t=require("react"),Ae=require("../../providers/config-provider.cjs"),Re=require("../../providers/conversation-provider.cjs"),Le=require("../../providers/chat-events-provider.cjs"),B=require("../../utils/get-message-metadata.cjs"),xe=require("../../utils/misc.cjs"),ae=require("../../utils/reset-query-params.cjs"),Be=require("../../providers/chat-form-provider.cjs"),De=require("../../providers/widget-provider.cjs"),Oe=require("../../hooks/use-media-query.cjs"),Fe=require("./use-captcha.cjs"),Ke=require("../modal/modal-provider.cjs"),u=require("../../utils/generate-uid.cjs"),Te=require("../../utils/tools/links-tool.cjs"),Qe=require("../../atoms/api/analytics/conversation.cjs"),We=()=>{const{chatId:f,setConversation:re,conversation:D,resetConversation:ie}=Re.useInkeepConversation(),{baseSettings:k,aiChatSettings:O}=Ae.useInkeepConfig(),{aiApiBaseUrl:F,shouldBypassCaptcha:K,filters:T}=k,Q=Ke.useModal(),{getSolution:ce,prefetchSolution:b,invalidateSolution:W}=Fe.useCaptcha({fetchUrl:`${F}/v1/challenge`,shouldBypassCaptcha:K,shouldMakeInitialRequest:Q?Q.isOpen:!0}),le=new _e({baseURL:`${F}/v1`,apiKey:k.apiKey,dangerouslyAllowBrowser:!0}),{onInputMessageChange:ue,getTools:ge,prompts:de,model:me,filters:J}=O,[p,N]=t.useState(""),z=t.useRef(null);t.useEffect(()=>{ue?.(p)},[p]);const[g,l]=t.useState([]),[H,h]=t.useState(!1),[fe,v]=t.useState(!1),[pe,j]=t.useState(null),[_,G]=t.useState(null),[y,S]=t.useState([]),he=e=>{S(s=>[...s,e])},[ve,V]=t.useState({}),i=t.useRef([]),C=t.useRef(null),{logEvent:q}=Le.useChatEvents(),X=de?.map((e,s)=>({id:`system-${Date.now().toString()}-${u.generateUid(4)}-${s}`,role:"system",content:e})),[ye,Se]=t.useState(!!f);t.useEffect(()=>{if(f){const{apiKey:e,analyticsApiBaseUrl:s}=k;Qe.getConversation(f,e,s).then(n=>{if(n){q({eventName:"shared_chat_loaded",properties:{conversation:n}}),Se(!1),re({...n,id:""});const a=n.messages.map(c=>({id:Date.now().toString()+u.generateUid(4)+c.id,content:xe.parseIfJson(c.content),role:c.role,links:c.links}));l(a),i.current=a}})}},[f]);const Ce=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${k.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.`}},Y=e=>{j(e),l(s=>{const n=[...s],a=n[n.length-1];return a&&(a.content=Ce(e)),n}),h(!1),v(!1),W(),b()},A=!p.trim()&&!y.length||H,Me=e=>{e.key==="Enter"&&!e.shiftKey&&!A&&!e.nativeEvent.isComposing&&(e.preventDefault(),R())},we=e=>{const s=e.target.value;N(s)},R=async(e=p)=>{if(A&&(!e||e.trim().length===0))return;h(!0);const s=_?g.length===2:g.length===0,n=B.getMessageMetadata(_,y,s);let a;const c=B.serializeAttachments(y);y.length&&c?a=[{type:"text",text:c}]:a=e;const ee={id:`${Date.now().toString()}-${u.generateUid(4)}-1`,role:"user",content:a,metadata:n},P=[...g.length?[]:X,ee];f&&ae.resetQueryParams(),l(M=>[...M,...P]),i.current=[...i.current,...P],S([]),N(""),q({eventName:"user_message_submitted",properties:{}},i.current);const te=[Te.provideLinksTool,...ge?.({conversation:D})||[]];try{const M={model:me,messages:i.current,stream:!0,tools:te,tool_choice:"auto"},se=await ce(),ne=se?btoa(JSON.stringify(se)):null,oe=T||J?JSON.stringify({...T,...J}):void 0,E={};!K&&ne&&(E["X-INKEEP-CHALLENGE-SOLUTION"]=ne),oe&&(E["inkeep-filters"]=oe);const d=le.beta.chat.completions.stream(M,Object.keys(E).length>0?{headers:E}:void 0),o={id:`${Date.now().toString()}-${u.generateUid(4)}-2`,role:"assistant",content:"",links:[],toolCalls:[]};l(U=>[...U,o]),d.on("content",(U,w)=>{v(!0),o.content=w,l($=>{const r=[...$],L=r.findIndex(I=>I.id===o.id);return L===-1?[...r,o]:(r[L]={...o},r)})}),d.on("tool_calls.function.arguments.done",U=>{const{name:w,arguments:$}=U,r=te?.find(m=>m.function.name===w);if(!r)return;const I=("parse"in r.function?r.function.parse:JSON.parse)($),Ee=r.function.function?.(I,d),Ue=r.renderMessageButtons?.({args:I,execution:Ee})??[];w==="provideLinks"?o.links=I.links??[]:V(m=>({...m,[o.id]:[...m[o.id]??[],...Ue]})),o.toolCalls?.push({id:"call_"+u.generateUid(24),type:"function",function:{name:w,arguments:$}}),l(m=>{const x=[...m],$e=x.findIndex(Ne=>Ne.id===o.id);return x[$e]={...o},x})}),d.on("error",Y),d.finalChatCompletion().then(()=>{i.current=[...i.current,o],C.current=null,h(!1),v(!1),b(),q({eventName:"assistant_message_received",properties:{}},i.current)}),C.current=d.controller}catch(M){Y(M),h(!1),v(!1)}},Ie=()=>{C.current&&(C.current.abort(),C.current=null),h(!1),v(!1),b()},Z=()=>{j(null),l([]),i.current=[],ie(),V({}),S([]),ae.resetQueryParams(),G(null),W(),b(),q({eventName:"chat_clear_button_clicked",properties:{conversation:D}})},ke=e=>{G(e);const{initialReplyMessage:s,displayName:n}=e,a={id:g.length.toString()+u.generateUid(4),role:"user",content:n},c={id:(g.length+1).toString()+u.generateUid(4),role:"assistant",content:s,links:[]},P=[{id:`system-${Date.now().toString()}-${u.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
4
|
+
${B.serializeWorkflow(e)}`},...X,a,c];l(P),S([])},{openForm:be}=Be.useChatForm(),qe=De.useWidget();t.useImperativeHandle(O.chatFunctionsRef,()=>({submitMessage:R,updateInputMessage(e){N(e)},clearChat:Z,openForm:e=>{qe?.setView("chat"),be(e)},focusInput:()=>{z.current?.focus()}}));const Pe=Oe.useMediaQuery("(max-width: 768px)");return{messages:g,input:p,isLoading:H,isStreaming:fe,isLoadingConversation:ye,error:pe,isSubmitDisabled:A,handleInputChange:we,handleInputKeyDown:Me,handleSubmit:R,stop:Ie,clear:Z,handleWorkflow:ke,selectedWorkflow:_,messageAttachments:y,setMessageAttachments:S,addAttachment:he,messageButtons:ve,isEmpty:g.length===0,inputRef:z,isMobile:Pe}};exports.useInkeepChat=We;
|
|
@@ -1,69 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { useState as c, useRef as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
import Be from "openai";
|
|
3
|
+
import { useState as c, useRef as P, useEffect as ae, useImperativeHandle as De } from "react";
|
|
4
|
+
import { useInkeepConfig as Oe } from "../../providers/config-provider.js";
|
|
5
|
+
import { useInkeepConversation as Re } from "../../providers/conversation-provider.js";
|
|
6
|
+
import { useChatEvents as Pe } from "../../providers/chat-events-provider.js";
|
|
7
|
+
import { getMessageMetadata as Ue, serializeAttachments as Fe, serializeWorkflow as Ke } from "../../utils/get-message-metadata.js";
|
|
8
|
+
import { parseIfJson as We } from "../../utils/misc.js";
|
|
9
|
+
import { resetQueryParams as re } from "../../utils/reset-query-params.js";
|
|
10
|
+
import { useChatForm as Je } from "../../providers/chat-form-provider.js";
|
|
11
|
+
import { useWidget as Te } from "../../providers/widget-provider.js";
|
|
12
|
+
import { useMediaQuery as ze } from "../../hooks/use-media-query.js";
|
|
13
|
+
import { useCaptcha as He } from "./use-captcha.js";
|
|
14
|
+
import { useModal as Qe } from "../modal/modal-provider.js";
|
|
15
|
+
import { generateUid as u } from "../../utils/generate-uid.js";
|
|
16
|
+
import { provideLinksTool as je } from "../../utils/tools/links-tool.js";
|
|
17
|
+
import { getConversation as qe } from "../../atoms/api/analytics/conversation.js";
|
|
18
|
+
const mt = () => {
|
|
19
|
+
const { chatId: d, setConversation: ie, conversation: U, resetConversation: ce } = Re(), { baseSettings: k, aiChatSettings: F } = Oe(), { aiApiBaseUrl: K, shouldBypassCaptcha: W, filters: J } = k, T = Qe(), { getSolution: le, prefetchSolution: b, invalidateSolution: z } = He({
|
|
20
|
+
fetchUrl: `${K}/v1/challenge`,
|
|
21
|
+
shouldBypassCaptcha: W,
|
|
22
|
+
shouldMakeInitialRequest: T ? T.isOpen : !0
|
|
23
|
+
}), ue = new Be({
|
|
24
|
+
baseURL: `${K}/v1`,
|
|
24
25
|
apiKey: k.apiKey,
|
|
25
26
|
dangerouslyAllowBrowser: !0
|
|
26
|
-
}), {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
prompts: ue,
|
|
30
|
-
model: me,
|
|
31
|
-
onToolCall: ge,
|
|
32
|
-
filters: W
|
|
33
|
-
} = P, [f, _] = c(""), J = R(null);
|
|
34
|
-
te(() => {
|
|
35
|
-
ce?.(f);
|
|
27
|
+
}), { onInputMessageChange: me, getTools: ge, prompts: pe, model: de, filters: H } = F, [f, x] = c(""), Q = P(null);
|
|
28
|
+
ae(() => {
|
|
29
|
+
me?.(f);
|
|
36
30
|
}, [f]);
|
|
37
|
-
const [
|
|
31
|
+
const [m, l] = c([]), [j, h] = c(!1), [fe, y] = c(!1), [he, q] = c(null), [L, G] = c(null), [C, w] = c([]), ye = (e) => {
|
|
38
32
|
w((t) => [...t, e]);
|
|
39
|
-
}, [
|
|
40
|
-
id: `system-${Date.now().toString()}-${
|
|
33
|
+
}, [Ce, V] = c({}), r = P([]), v = P(null), { logEvent: $ } = Pe(), X = pe?.map((e, t) => ({
|
|
34
|
+
id: `system-${Date.now().toString()}-${u(4)}-${t}`,
|
|
41
35
|
role: "system",
|
|
42
36
|
content: e
|
|
43
|
-
})), [
|
|
44
|
-
|
|
45
|
-
if (
|
|
37
|
+
})), [we, ve] = c(!!d);
|
|
38
|
+
ae(() => {
|
|
39
|
+
if (d) {
|
|
46
40
|
const { apiKey: e, analyticsApiBaseUrl: t } = k;
|
|
47
|
-
|
|
41
|
+
qe(d, e, t).then((s) => {
|
|
48
42
|
if (s) {
|
|
49
43
|
$({
|
|
50
44
|
eventName: "shared_chat_loaded",
|
|
51
45
|
properties: {
|
|
52
46
|
conversation: s
|
|
53
47
|
}
|
|
54
|
-
}),
|
|
55
|
-
const
|
|
56
|
-
id: Date.now().toString() +
|
|
57
|
-
content:
|
|
48
|
+
}), ve(!1), ie({ ...s, id: "" });
|
|
49
|
+
const o = s.messages.map((i) => ({
|
|
50
|
+
id: Date.now().toString() + u(4) + i.id,
|
|
51
|
+
content: We(i.content),
|
|
58
52
|
role: i.role,
|
|
59
53
|
links: i.links
|
|
60
54
|
}));
|
|
61
|
-
l(
|
|
55
|
+
l(o), r.current = o;
|
|
62
56
|
}
|
|
63
57
|
});
|
|
64
58
|
}
|
|
65
|
-
}, [
|
|
66
|
-
const
|
|
59
|
+
}, [d]);
|
|
60
|
+
const Ie = (e) => {
|
|
67
61
|
switch (e.code) {
|
|
68
62
|
case 400:
|
|
69
63
|
return e.message;
|
|
@@ -74,159 +68,160 @@ const at = () => {
|
|
|
74
68
|
|
|
75
69
|
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
76
70
|
}
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
const s = [...t],
|
|
80
|
-
return
|
|
81
|
-
}), h(!1), y(!1),
|
|
82
|
-
},
|
|
83
|
-
e.key === "Enter" && !e.shiftKey && !
|
|
84
|
-
},
|
|
71
|
+
}, Y = (e) => {
|
|
72
|
+
q(e), l((t) => {
|
|
73
|
+
const s = [...t], o = s[s.length - 1];
|
|
74
|
+
return o && (o.content = Ie(e)), s;
|
|
75
|
+
}), h(!1), y(!1), z(), b();
|
|
76
|
+
}, B = !f.trim() && !C.length || j, Me = (e) => {
|
|
77
|
+
e.key === "Enter" && !e.shiftKey && !B && !e.nativeEvent.isComposing && (e.preventDefault(), D());
|
|
78
|
+
}, Se = (e) => {
|
|
85
79
|
const t = e.target.value;
|
|
86
|
-
|
|
80
|
+
x(t);
|
|
87
81
|
}, D = async (e = f) => {
|
|
88
|
-
if (
|
|
82
|
+
if (B && (!e || e.trim().length === 0)) return;
|
|
89
83
|
h(!0);
|
|
90
|
-
const t =
|
|
91
|
-
let
|
|
92
|
-
const i =
|
|
93
|
-
C.length && i ?
|
|
94
|
-
const
|
|
95
|
-
id: `${Date.now().toString()}-${
|
|
84
|
+
const t = L ? m.length === 2 : m.length === 0, s = Ue(L, C, t);
|
|
85
|
+
let o;
|
|
86
|
+
const i = Fe(C);
|
|
87
|
+
C.length && i ? o = [{ type: "text", text: i }] : o = e;
|
|
88
|
+
const ee = {
|
|
89
|
+
id: `${Date.now().toString()}-${u(4)}-1`,
|
|
96
90
|
role: "user",
|
|
97
|
-
content:
|
|
91
|
+
content: o,
|
|
98
92
|
metadata: s
|
|
99
|
-
}, E = [...
|
|
100
|
-
|
|
93
|
+
}, E = [...m.length ? [] : X, ee];
|
|
94
|
+
d && re(), l((I) => [...I, ...E]), r.current = [...r.current, ...E], w([]), x(""), $(
|
|
101
95
|
{
|
|
102
96
|
eventName: "user_message_submitted",
|
|
103
97
|
properties: {}
|
|
104
98
|
},
|
|
105
99
|
r.current
|
|
106
100
|
);
|
|
101
|
+
const te = [je, ...ge?.({ conversation: U }) || []];
|
|
107
102
|
try {
|
|
108
|
-
const
|
|
109
|
-
model:
|
|
103
|
+
const I = {
|
|
104
|
+
model: de,
|
|
110
105
|
messages: r.current,
|
|
111
106
|
stream: !0,
|
|
112
|
-
tools:
|
|
107
|
+
tools: te,
|
|
113
108
|
tool_choice: "auto"
|
|
114
|
-
},
|
|
115
|
-
...
|
|
116
|
-
...
|
|
109
|
+
}, se = await le(), ne = se ? btoa(JSON.stringify(se)) : null, oe = J || H ? JSON.stringify({
|
|
110
|
+
...J,
|
|
111
|
+
...H
|
|
117
112
|
}) : void 0, N = {};
|
|
118
|
-
!
|
|
119
|
-
const
|
|
120
|
-
|
|
113
|
+
!W && ne && (N["X-INKEEP-CHALLENGE-SOLUTION"] = ne), oe && (N["inkeep-filters"] = oe);
|
|
114
|
+
const g = ue.beta.chat.completions.stream(
|
|
115
|
+
I,
|
|
121
116
|
Object.keys(N).length > 0 ? { headers: N } : void 0
|
|
122
|
-
),
|
|
123
|
-
id: `${Date.now().toString()}-${
|
|
117
|
+
), n = {
|
|
118
|
+
id: `${Date.now().toString()}-${u(4)}-2`,
|
|
124
119
|
role: "assistant",
|
|
125
120
|
content: "",
|
|
126
|
-
links: []
|
|
121
|
+
links: [],
|
|
122
|
+
toolCalls: []
|
|
127
123
|
};
|
|
128
|
-
l((
|
|
129
|
-
y(!0),
|
|
130
|
-
const a = [...
|
|
131
|
-
return
|
|
124
|
+
l((_) => [..._, n]), g.on("content", (_, M) => {
|
|
125
|
+
y(!0), n.content = M, l((A) => {
|
|
126
|
+
const a = [...A], O = a.findIndex((S) => S.id === n.id);
|
|
127
|
+
return O === -1 ? [...a, n] : (a[O] = { ...n }, a);
|
|
132
128
|
});
|
|
133
|
-
}),
|
|
134
|
-
const { name:
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
129
|
+
}), g.on("tool_calls.function.arguments.done", (_) => {
|
|
130
|
+
const { name: M, arguments: A } = _, a = te?.find((p) => p.function.name === M);
|
|
131
|
+
if (!a) return;
|
|
132
|
+
const S = ("parse" in a.function ? a.function.parse : JSON.parse)(A), _e = a.function.function?.(S, g), Ae = a.renderMessageButtons?.({ args: S, execution: _e }) ?? [];
|
|
133
|
+
M === "provideLinks" ? n.links = S.links ?? [] : V((p) => ({
|
|
134
|
+
...p,
|
|
135
|
+
[n.id]: [...p[n.id] ?? [], ...Ae]
|
|
136
|
+
})), n.toolCalls?.push({
|
|
137
|
+
id: "call_" + u(24),
|
|
138
|
+
type: "function",
|
|
139
|
+
function: {
|
|
140
|
+
name: M,
|
|
141
|
+
arguments: A
|
|
142
|
+
}
|
|
143
|
+
}), l((p) => {
|
|
144
|
+
const R = [...p], xe = R.findIndex((Le) => Le.id === n.id);
|
|
145
|
+
return R[xe] = { ...n }, R;
|
|
146
|
+
});
|
|
147
|
+
}), g.on("error", Y), g.finalChatCompletion().then(() => {
|
|
148
|
+
r.current = [...r.current, n], v.current = null, h(!1), y(!1), b(), $(
|
|
152
149
|
{
|
|
153
150
|
eventName: "assistant_message_received",
|
|
154
151
|
properties: {}
|
|
155
152
|
},
|
|
156
153
|
r.current
|
|
157
154
|
);
|
|
158
|
-
}),
|
|
159
|
-
} catch (
|
|
160
|
-
|
|
155
|
+
}), v.current = g.controller;
|
|
156
|
+
} catch (I) {
|
|
157
|
+
Y(I), h(!1), y(!1);
|
|
161
158
|
}
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
},
|
|
165
|
-
|
|
159
|
+
}, ke = () => {
|
|
160
|
+
v.current && (v.current.abort(), v.current = null), h(!1), y(!1), b();
|
|
161
|
+
}, Z = () => {
|
|
162
|
+
q(null), l([]), r.current = [], ce(), V({}), w([]), re(), G(null), z(), b(), $({
|
|
166
163
|
eventName: "chat_clear_button_clicked",
|
|
167
164
|
properties: {
|
|
168
|
-
conversation:
|
|
165
|
+
conversation: U
|
|
169
166
|
}
|
|
170
167
|
});
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
const { initialReplyMessage: t, displayName: s } = e,
|
|
174
|
-
id:
|
|
168
|
+
}, be = (e) => {
|
|
169
|
+
G(e);
|
|
170
|
+
const { initialReplyMessage: t, displayName: s } = e, o = {
|
|
171
|
+
id: m.length.toString() + u(4),
|
|
175
172
|
role: "user",
|
|
176
173
|
content: s
|
|
177
174
|
}, i = {
|
|
178
|
-
id: (
|
|
175
|
+
id: (m.length + 1).toString() + u(4),
|
|
179
176
|
role: "assistant",
|
|
180
177
|
content: t,
|
|
181
178
|
links: []
|
|
182
179
|
}, E = [{
|
|
183
|
-
id: `system-${Date.now().toString()}-${
|
|
180
|
+
id: `system-${Date.now().toString()}-${u(4)}-${e.id}`,
|
|
184
181
|
role: "system",
|
|
185
182
|
content: `Company has asked user to follow this guided workflow:
|
|
186
|
-
${
|
|
187
|
-
|
|
188
|
-
)}`
|
|
189
|
-
}, ...q, n, i];
|
|
183
|
+
${Ke(e)}`
|
|
184
|
+
}, ...X, o, i];
|
|
190
185
|
l(E), w([]);
|
|
191
|
-
}, { openForm:
|
|
192
|
-
|
|
186
|
+
}, { openForm: $e } = Je(), Ee = Te();
|
|
187
|
+
De(F.chatFunctionsRef, () => ({
|
|
193
188
|
submitMessage: D,
|
|
194
189
|
updateInputMessage(e) {
|
|
195
|
-
|
|
190
|
+
x(e);
|
|
196
191
|
},
|
|
197
|
-
clearChat:
|
|
192
|
+
clearChat: Z,
|
|
198
193
|
openForm: (e) => {
|
|
199
|
-
|
|
194
|
+
Ee?.setView("chat"), $e(e);
|
|
200
195
|
},
|
|
201
196
|
focusInput: () => {
|
|
202
|
-
|
|
197
|
+
Q.current?.focus();
|
|
203
198
|
}
|
|
204
199
|
}));
|
|
205
|
-
const
|
|
200
|
+
const Ne = ze("(max-width: 768px)");
|
|
206
201
|
return {
|
|
207
|
-
messages:
|
|
202
|
+
messages: m,
|
|
208
203
|
input: f,
|
|
209
|
-
isLoading:
|
|
210
|
-
isStreaming:
|
|
211
|
-
isLoadingConversation:
|
|
212
|
-
error:
|
|
213
|
-
isSubmitDisabled:
|
|
214
|
-
handleInputChange:
|
|
215
|
-
handleInputKeyDown:
|
|
204
|
+
isLoading: j,
|
|
205
|
+
isStreaming: fe,
|
|
206
|
+
isLoadingConversation: we,
|
|
207
|
+
error: he,
|
|
208
|
+
isSubmitDisabled: B,
|
|
209
|
+
handleInputChange: Se,
|
|
210
|
+
handleInputKeyDown: Me,
|
|
216
211
|
handleSubmit: D,
|
|
217
|
-
stop:
|
|
218
|
-
clear:
|
|
219
|
-
handleWorkflow:
|
|
220
|
-
selectedWorkflow:
|
|
212
|
+
stop: ke,
|
|
213
|
+
clear: Z,
|
|
214
|
+
handleWorkflow: be,
|
|
215
|
+
selectedWorkflow: L,
|
|
221
216
|
messageAttachments: C,
|
|
222
217
|
setMessageAttachments: w,
|
|
223
|
-
addAttachment:
|
|
224
|
-
|
|
225
|
-
isEmpty:
|
|
226
|
-
inputRef:
|
|
227
|
-
isMobile:
|
|
218
|
+
addAttachment: ye,
|
|
219
|
+
messageButtons: Ce,
|
|
220
|
+
isEmpty: m.length === 0,
|
|
221
|
+
inputRef: Q,
|
|
222
|
+
isMobile: Ne
|
|
228
223
|
};
|
|
229
224
|
};
|
|
230
225
|
export {
|
|
231
|
-
|
|
226
|
+
mt as useInkeepChat
|
|
232
227
|
};
|