@chatbotkit/react 0.8.0 → 1.1.4
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/cjs/components/AutoScroller.cjs +22 -55
- package/dist/cjs/components/AutoScroller.d.ts +5 -15
- package/dist/cjs/components/AutoTextarea.cjs +8 -19
- package/dist/cjs/components/AutoTextarea.d.ts +3 -10
- package/dist/cjs/hooks/useConversationManager.cjs +91 -269
- package/dist/cjs/hooks/useConversationManager.d.ts +31 -55
- package/dist/cjs/index.cjs +4 -7
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/utils/object.cjs +7 -0
- package/dist/cjs/utils/object.d.ts +1 -0
- package/dist/cjs/utils/string.cjs +0 -16
- package/dist/cjs/utils/string.d.ts +0 -16
- package/dist/esm/components/AutoScroller.d.ts +5 -15
- package/dist/esm/components/AutoScroller.js +16 -27
- package/dist/esm/components/AutoTextarea.d.ts +3 -10
- package/dist/esm/components/AutoTextarea.js +5 -15
- package/dist/esm/hooks/useConversationManager.d.ts +31 -55
- package/dist/esm/hooks/useConversationManager.js +90 -270
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/object.d.ts +1 -0
- package/dist/esm/utils/object.js +3 -0
- package/dist/esm/utils/string.d.ts +0 -16
- package/dist/esm/utils/string.js +0 -16
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +91 -58
- package/.eslintrc +0 -1
- package/CHANGELOG.md +0 -69
|
@@ -1,65 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* text: string,
|
|
6
|
-
* createdAt: number,
|
|
7
|
-
* meta?: Record<string,any>
|
|
8
|
-
* }} Message
|
|
9
|
-
*
|
|
10
|
-
* @typedef {(error: any) => any} onErrorFn
|
|
11
|
-
* @typedef {(conversationId: string, messages: Message[], data: Record<string,any>) => any} onSendFn
|
|
12
|
-
* @typedef {(conversationId: string, messages: Message[], data: Record<string,any>) => any} onReceiveFn
|
|
13
|
-
*
|
|
14
|
-
* @param {{
|
|
15
|
-
* conversationId?: string,
|
|
16
|
-
* token?: string,
|
|
17
|
-
* messages?: Message[],
|
|
18
|
-
* stream?: boolean,
|
|
19
|
-
* verbose?: boolean,
|
|
20
|
-
* onError?: onErrorFn?,
|
|
21
|
-
* onSend?: onSendFn?,
|
|
22
|
-
* onReceive?: onReceiveFn?,
|
|
23
|
-
* }}[options]
|
|
24
|
-
*/
|
|
25
|
-
export default function useConversationManager({ conversationId: _conversationId, token: _token, messages: _messages, stream, verbose, onError, onSend, onReceive, }?: {
|
|
26
|
-
conversationId?: string | undefined;
|
|
1
|
+
export function useConversationManager(options: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
client?: ConversationClient | undefined;
|
|
4
|
+
endpoint?: string | undefined;
|
|
27
5
|
token?: string | undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
conversationId?: string | undefined;
|
|
7
|
+
backstory?: string | undefined;
|
|
8
|
+
model?: string | undefined;
|
|
9
|
+
datasetId?: string | undefined;
|
|
10
|
+
skillsetId?: string | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
token: string | undefined;
|
|
13
|
+
setToken: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
14
|
+
conversationId: string | undefined;
|
|
15
|
+
setConversationId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
16
|
+
backstory: string | undefined;
|
|
17
|
+
setBackstory: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
18
|
+
model: string | undefined;
|
|
19
|
+
setModel: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
20
|
+
datasetId: string | undefined;
|
|
21
|
+
setDatasetId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
22
|
+
skillsetId: string | undefined;
|
|
23
|
+
setSkillsetId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
35
24
|
text: string;
|
|
36
25
|
setText: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
37
|
-
token: string;
|
|
38
|
-
setToken: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
39
|
-
conversationId: string;
|
|
40
|
-
setConversationId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
41
26
|
messages: Message[];
|
|
42
27
|
setMessages: import("react").Dispatch<import("react").SetStateAction<Message[]>>;
|
|
43
|
-
flushUserMessage: () => Promise<void>;
|
|
44
|
-
continueConversation: (options?: {
|
|
45
|
-
token?: string | undefined;
|
|
46
|
-
} | undefined) => Promise<void>;
|
|
47
|
-
interact: (options?: {
|
|
48
|
-
token?: string | undefined;
|
|
49
|
-
conversationId?: string | undefined;
|
|
50
|
-
messages?: Message[] | undefined;
|
|
51
|
-
} | undefined) => void;
|
|
52
|
-
reset: () => void;
|
|
53
|
-
loading: boolean;
|
|
54
28
|
thinking: boolean;
|
|
29
|
+
setThinking: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
30
|
+
writing: boolean;
|
|
31
|
+
setWriting: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
32
|
+
error: any;
|
|
33
|
+
setError: import("react").Dispatch<any>;
|
|
34
|
+
submit: () => Promise<void>;
|
|
55
35
|
};
|
|
36
|
+
export default useConversationManager;
|
|
56
37
|
export type Message = {
|
|
57
|
-
|
|
58
|
-
type: string;
|
|
38
|
+
type: 'bot' | 'user';
|
|
59
39
|
text: string;
|
|
60
|
-
createdAt: number;
|
|
61
|
-
meta?: Record<string, any>;
|
|
62
40
|
};
|
|
63
|
-
|
|
64
|
-
export type onSendFn = (conversationId: string, messages: Message[], data: Record<string, any>) => any;
|
|
65
|
-
export type onReceiveFn = (conversationId: string, messages: Message[], data: Record<string, any>) => any;
|
|
41
|
+
import { ConversationClient } from '@chatbotkit/sdk';
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useConversationManager = exports.AutoTextarea = void 0;
|
|
7
|
-
var AutoTextarea_js_1 = require("./components/AutoTextarea
|
|
8
|
-
Object.defineProperty(exports, "AutoTextarea", { enumerable: true, get: function () { return
|
|
9
|
-
var useConversationManager_js_1 = require("./hooks/useConversationManager
|
|
10
|
-
Object.defineProperty(exports, "useConversationManager", { enumerable: true, get: function () { return
|
|
4
|
+
var AutoTextarea_js_1 = require("./components/AutoTextarea..cjs");
|
|
5
|
+
Object.defineProperty(exports, "AutoTextarea", { enumerable: true, get: function () { return AutoTextarea_js_1.AutoTextarea; } });
|
|
6
|
+
var useConversationManager_js_1 = require("./hooks/useConversationManager..cjs");
|
|
7
|
+
Object.defineProperty(exports, "useConversationManager", { enumerable: true, get: function () { return useConversationManager_js_1.useConversationManager; } });
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { AutoTextarea } from "./components/AutoTextarea.js";
|
|
2
|
+
export { useConversationManager } from "./hooks/useConversationManager.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cloneAndExtend = void 0;
|
|
4
|
+
function cloneAndExtend(object, extension) {
|
|
5
|
+
return Object.assign(Object.assign(Object.create(Object.getPrototypeOf(object)), object), extension);
|
|
6
|
+
}
|
|
7
|
+
exports.cloneAndExtend = cloneAndExtend;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function cloneAndExtend<T>(object: T, extension: object): T;
|
|
@@ -1,30 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replaceWithCoordinates = exports.replaceBetween = exports.getRandomId = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} [prefix]
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
4
|
function getRandomId(prefix) {
|
|
9
5
|
return `${prefix || ''}${Math.random().toString(32).slice(2)}`;
|
|
10
6
|
}
|
|
11
7
|
exports.getRandomId = getRandomId;
|
|
12
|
-
/**
|
|
13
|
-
* @param {string} input
|
|
14
|
-
* @param {number} begin
|
|
15
|
-
* @param {number} end
|
|
16
|
-
* @param {string} replacement
|
|
17
|
-
* @returns {string}
|
|
18
|
-
*/
|
|
19
8
|
function replaceBetween(input, begin, end, replacement) {
|
|
20
9
|
return input.substring(0, begin) + replacement + input.substring(end);
|
|
21
10
|
}
|
|
22
11
|
exports.replaceBetween = replaceBetween;
|
|
23
|
-
/**
|
|
24
|
-
* @param {string} input
|
|
25
|
-
* @param {[string, string][]} replacements
|
|
26
|
-
* @returns {({begin: number, end: number, input: string, output: string}|string)[]}
|
|
27
|
-
*/
|
|
28
12
|
function replaceWithCoordinates(input, replacements) {
|
|
29
13
|
const output = [];
|
|
30
14
|
let currentIndex = 0;
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string} [prefix]
|
|
3
|
-
* @returns {string}
|
|
4
|
-
*/
|
|
5
1
|
export function getRandomId(prefix?: string | undefined): string;
|
|
6
|
-
/**
|
|
7
|
-
* @param {string} input
|
|
8
|
-
* @param {number} begin
|
|
9
|
-
* @param {number} end
|
|
10
|
-
* @param {string} replacement
|
|
11
|
-
* @returns {string}
|
|
12
|
-
*/
|
|
13
2
|
export function replaceBetween(input: string, begin: number, end: number, replacement: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} input
|
|
16
|
-
* @param {[string, string][]} replacements
|
|
17
|
-
* @returns {({begin: number, end: number, input: string, output: string}|string)[]}
|
|
18
|
-
*/
|
|
19
3
|
export function replaceWithCoordinates(input: string, replacements: [string, string][]): (string | {
|
|
20
4
|
begin: number;
|
|
21
5
|
end: number;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
export function AutoScrollAnchor():
|
|
2
|
-
|
|
3
|
-
* @param {{
|
|
4
|
-
* anchor?: 'top'|'bottom',
|
|
5
|
-
* childList?: boolean,
|
|
6
|
-
* subtree?: boolean,
|
|
7
|
-
* block?: 'start'|'end',
|
|
8
|
-
* delay?: number,
|
|
9
|
-
* [name: string]: any
|
|
10
|
-
* }} props
|
|
11
|
-
*/
|
|
12
|
-
export default function AutoScroller({ anchor, childList, subtree, block, delay, disabled, children, ...props }: {
|
|
1
|
+
export function AutoScrollAnchor(): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export function AutoScroller(props?: {
|
|
13
3
|
[name: string]: any;
|
|
14
|
-
anchor?: "
|
|
4
|
+
anchor?: "bottom" | "top" | undefined;
|
|
15
5
|
childList?: boolean | undefined;
|
|
16
6
|
subtree?: boolean | undefined;
|
|
17
7
|
block?: "end" | "start" | undefined;
|
|
18
8
|
delay?: number | undefined;
|
|
19
|
-
}):
|
|
20
|
-
|
|
9
|
+
} | undefined): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default AutoScroller;
|
|
@@ -1,62 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useRef, useEffect } from 'react';
|
|
3
3
|
export function AutoScrollAnchor() {
|
|
4
|
-
return
|
|
4
|
+
return _jsx("div", { className: "auto-scroll-anchor ![height:1px]" });
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* childList?: boolean,
|
|
10
|
-
* subtree?: boolean,
|
|
11
|
-
* block?: 'start'|'end',
|
|
12
|
-
* delay?: number,
|
|
13
|
-
* [name: string]: any
|
|
14
|
-
* }} props
|
|
15
|
-
*/
|
|
16
|
-
export default function AutoScroller({ anchor = 'bottom', childList = true, subtree = false, block = 'end', delay = 3000, disabled, children, ...props }) {
|
|
17
|
-
const rootRef = useRef();
|
|
6
|
+
export function AutoScroller(props) {
|
|
7
|
+
const { anchor = 'bottom', childList = true, subtree = false, block = 'end', delay = 3000, disabled, children, ...rest } = props || {};
|
|
8
|
+
const rootRef = (useRef());
|
|
18
9
|
useEffect(() => {
|
|
19
10
|
if (disabled) {
|
|
20
11
|
return;
|
|
21
12
|
}
|
|
22
13
|
let visible = false;
|
|
23
14
|
let pause = false;
|
|
24
|
-
let timeout
|
|
15
|
+
let timeout;
|
|
25
16
|
const io = new IntersectionObserver((entries) => {
|
|
26
17
|
if (pause) {
|
|
27
18
|
return;
|
|
28
19
|
}
|
|
29
20
|
visible = entries.some((entry) => entry.isIntersecting);
|
|
30
21
|
});
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
const anchor = rootRef.current?.querySelector('.auto-scroll-anchor');
|
|
23
|
+
if (anchor) {
|
|
24
|
+
io.observe(anchor);
|
|
25
|
+
}
|
|
33
26
|
const mo = new MutationObserver(() => {
|
|
34
27
|
if (!visible) {
|
|
35
28
|
return;
|
|
36
29
|
}
|
|
37
30
|
pause = true;
|
|
38
31
|
rootRef.current
|
|
39
|
-
// @ts-ignore
|
|
40
32
|
?.querySelector('.auto-scroll-anchor')
|
|
41
33
|
?.scrollIntoView({ behavior: 'smooth', block });
|
|
42
34
|
clearTimeout(timeout);
|
|
43
|
-
// @ts-ignore
|
|
44
35
|
timeout = setTimeout(() => {
|
|
45
36
|
visible = true;
|
|
46
37
|
pause = false;
|
|
47
38
|
}, delay);
|
|
48
39
|
});
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const root = rootRef.current;
|
|
41
|
+
if (root) {
|
|
42
|
+
mo.observe(root, { childList, subtree });
|
|
43
|
+
}
|
|
51
44
|
return () => {
|
|
52
45
|
io.disconnect();
|
|
53
46
|
mo.disconnect();
|
|
54
47
|
};
|
|
55
48
|
}, [disabled]);
|
|
56
|
-
return (
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
React.createElement("div", { ref: rootRef, ...props },
|
|
59
|
-
anchor === 'top' ? React.createElement(AutoScrollAnchor, { key: "top" }) : null,
|
|
60
|
-
children,
|
|
61
|
-
anchor === 'bottom' ? React.createElement(AutoScrollAnchor, { key: "bottom" }) : null));
|
|
49
|
+
return (_jsxs("div", { ref: rootRef, ...rest, children: [anchor === 'top' ? _jsx(AutoScrollAnchor, {}, "top") : null, children, anchor === 'bottom' ? _jsx(AutoScrollAnchor, {}, "bottom") : null] }));
|
|
62
50
|
}
|
|
51
|
+
export default AutoScroller;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {(event: React.ChangeEvent<HTMLTextAreaElement>) => any} onInputFn
|
|
3
|
-
*
|
|
4
|
-
* @param {{
|
|
5
|
-
* onInput?: onInputFn?,
|
|
6
|
-
* [name: string]: any
|
|
7
|
-
* }} [props]
|
|
8
|
-
*/
|
|
9
|
-
export default function AutoTextarea({ onInput, ...props }?: {
|
|
1
|
+
export function AutoTextarea(props?: {
|
|
10
2
|
[name: string]: any;
|
|
11
3
|
onInput?: onInputFn | null | undefined;
|
|
12
|
-
} | undefined):
|
|
4
|
+
} | undefined): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export default AutoTextarea;
|
|
13
6
|
export type onInputFn = (event: React.ChangeEvent<HTMLTextAreaElement>) => any;
|
|
14
7
|
import React from 'react';
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @param {{
|
|
7
|
-
* onInput?: onInputFn?,
|
|
8
|
-
* [name: string]: any
|
|
9
|
-
* }} [props]
|
|
10
|
-
*/
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
export default function AutoTextarea({ onInput, ...props } = {}) {
|
|
13
|
-
/**
|
|
14
|
-
* @param {React.ChangeEvent<HTMLTextAreaElement>} event
|
|
15
|
-
*/
|
|
3
|
+
export function AutoTextarea(props) {
|
|
4
|
+
const { onInput, ...rest } = props || {};
|
|
16
5
|
function handleOnInput(event) {
|
|
17
6
|
const adjustment = `calc(${[event.target.style.paddingTop, event.target.style.paddingBottom]
|
|
18
7
|
.filter((f) => f)
|
|
@@ -23,5 +12,6 @@ export default function AutoTextarea({ onInput, ...props } = {}) {
|
|
|
23
12
|
onInput(event);
|
|
24
13
|
}
|
|
25
14
|
}
|
|
26
|
-
return
|
|
15
|
+
return _jsx("textarea", { ...rest, rows: 1, onInput: handleOnInput });
|
|
27
16
|
}
|
|
17
|
+
export default AutoTextarea;
|
|
@@ -1,65 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* text: string,
|
|
6
|
-
* createdAt: number,
|
|
7
|
-
* meta?: Record<string,any>
|
|
8
|
-
* }} Message
|
|
9
|
-
*
|
|
10
|
-
* @typedef {(error: any) => any} onErrorFn
|
|
11
|
-
* @typedef {(conversationId: string, messages: Message[], data: Record<string,any>) => any} onSendFn
|
|
12
|
-
* @typedef {(conversationId: string, messages: Message[], data: Record<string,any>) => any} onReceiveFn
|
|
13
|
-
*
|
|
14
|
-
* @param {{
|
|
15
|
-
* conversationId?: string,
|
|
16
|
-
* token?: string,
|
|
17
|
-
* messages?: Message[],
|
|
18
|
-
* stream?: boolean,
|
|
19
|
-
* verbose?: boolean,
|
|
20
|
-
* onError?: onErrorFn?,
|
|
21
|
-
* onSend?: onSendFn?,
|
|
22
|
-
* onReceive?: onReceiveFn?,
|
|
23
|
-
* }}[options]
|
|
24
|
-
*/
|
|
25
|
-
export default function useConversationManager({ conversationId: _conversationId, token: _token, messages: _messages, stream, verbose, onError, onSend, onReceive, }?: {
|
|
26
|
-
conversationId?: string | undefined;
|
|
1
|
+
export function useConversationManager(options: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
client?: ConversationClient | undefined;
|
|
4
|
+
endpoint?: string | undefined;
|
|
27
5
|
token?: string | undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
conversationId?: string | undefined;
|
|
7
|
+
backstory?: string | undefined;
|
|
8
|
+
model?: string | undefined;
|
|
9
|
+
datasetId?: string | undefined;
|
|
10
|
+
skillsetId?: string | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
token: string | undefined;
|
|
13
|
+
setToken: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
14
|
+
conversationId: string | undefined;
|
|
15
|
+
setConversationId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
16
|
+
backstory: string | undefined;
|
|
17
|
+
setBackstory: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
18
|
+
model: string | undefined;
|
|
19
|
+
setModel: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
20
|
+
datasetId: string | undefined;
|
|
21
|
+
setDatasetId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
22
|
+
skillsetId: string | undefined;
|
|
23
|
+
setSkillsetId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
35
24
|
text: string;
|
|
36
25
|
setText: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
37
|
-
token: string;
|
|
38
|
-
setToken: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
39
|
-
conversationId: string;
|
|
40
|
-
setConversationId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
41
26
|
messages: Message[];
|
|
42
27
|
setMessages: import("react").Dispatch<import("react").SetStateAction<Message[]>>;
|
|
43
|
-
flushUserMessage: () => Promise<void>;
|
|
44
|
-
continueConversation: (options?: {
|
|
45
|
-
token?: string | undefined;
|
|
46
|
-
} | undefined) => Promise<void>;
|
|
47
|
-
interact: (options?: {
|
|
48
|
-
token?: string | undefined;
|
|
49
|
-
conversationId?: string | undefined;
|
|
50
|
-
messages?: Message[] | undefined;
|
|
51
|
-
} | undefined) => void;
|
|
52
|
-
reset: () => void;
|
|
53
|
-
loading: boolean;
|
|
54
28
|
thinking: boolean;
|
|
29
|
+
setThinking: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
30
|
+
writing: boolean;
|
|
31
|
+
setWriting: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
32
|
+
error: any;
|
|
33
|
+
setError: import("react").Dispatch<any>;
|
|
34
|
+
submit: () => Promise<void>;
|
|
55
35
|
};
|
|
36
|
+
export default useConversationManager;
|
|
56
37
|
export type Message = {
|
|
57
|
-
|
|
58
|
-
type: string;
|
|
38
|
+
type: 'bot' | 'user';
|
|
59
39
|
text: string;
|
|
60
|
-
createdAt: number;
|
|
61
|
-
meta?: Record<string, any>;
|
|
62
40
|
};
|
|
63
|
-
|
|
64
|
-
export type onSendFn = (conversationId: string, messages: Message[], data: Record<string, any>) => any;
|
|
65
|
-
export type onReceiveFn = (conversationId: string, messages: Message[], data: Record<string, any>) => any;
|
|
41
|
+
import { ConversationClient } from '@chatbotkit/sdk';
|