@webority/chat-react 0.0.0-stage → 0.21.0
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/LICENSE +5 -0
- package/README.md +232 -2
- package/dist/chat-react.js +1188 -0
- package/dist/types/client.d.ts +208 -0
- package/dist/types/components/ActionCard.d.ts +27 -0
- package/dist/types/components/ChatComposer.d.ts +20 -0
- package/dist/types/components/ChatConversationList.d.ts +20 -0
- package/dist/types/components/ChatLauncher.d.ts +23 -0
- package/dist/types/components/ChatMessage.d.ts +31 -0
- package/dist/types/components/ChatPanel.d.ts +52 -0
- package/dist/types/components/ChatThread.d.ts +30 -0
- package/dist/types/components/ReplyRating.d.ts +16 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/labels.d.ts +69 -0
- package/dist/types/lib/format.d.ts +8 -0
- package/dist/types/lib/sse.d.ts +33 -0
- package/dist/types/markdown.d.ts +97 -0
- package/dist/types/useChat.d.ts +69 -0
- package/package.json +58 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type ChatTurnError = {
|
|
2
|
+
code: string;
|
|
3
|
+
/**
|
|
4
|
+
* Written for the person.
|
|
5
|
+
*/
|
|
6
|
+
message: string;
|
|
7
|
+
resetsAtUtc: string | null;
|
|
8
|
+
};
|
|
9
|
+
export type ChatTurn = {
|
|
10
|
+
/**
|
|
11
|
+
* Local key; for a reopened conversation, the stored message's id.
|
|
12
|
+
*/
|
|
13
|
+
id: string;
|
|
14
|
+
question: string;
|
|
15
|
+
/**
|
|
16
|
+
* What is shown: the streamed text, then the reply of record.
|
|
17
|
+
*/
|
|
18
|
+
answer: string;
|
|
19
|
+
streaming: boolean;
|
|
20
|
+
error: ChatTurnError | null;
|
|
21
|
+
actions: import('./client.js').SupportAction[];
|
|
22
|
+
/**
|
|
23
|
+
* The stored reply's id; rating needs it.
|
|
24
|
+
*/
|
|
25
|
+
messageId: string | null;
|
|
26
|
+
rating: "Up" | "Down" | null;
|
|
27
|
+
ratingNote: string | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The chat's state and actions, with no store of its own: it lives in the component that calls
|
|
31
|
+
* it. Call `reset()` when the signed-in person or account changes so nothing of one person's chat
|
|
32
|
+
* shows to the next. An answer still streaming is cancelled on `reset`, `newConversation`,
|
|
33
|
+
* `openConversation` and unmount.
|
|
34
|
+
*
|
|
35
|
+
* @param {object} options
|
|
36
|
+
* @param {import('./client.js').ChatClient} options.client From `createChatClient`.
|
|
37
|
+
* @param {any} [options.pageContext] Sent with each question; read at the moment of sending.
|
|
38
|
+
* @returns {{
|
|
39
|
+
* turns: ChatTurn[],
|
|
40
|
+
* conversationId: string|null,
|
|
41
|
+
* messagesLeftToday: number|null,
|
|
42
|
+
* streaming: boolean,
|
|
43
|
+
* loading: boolean,
|
|
44
|
+
* loadError: ChatTurnError|null,
|
|
45
|
+
* submit: (message: string) => Promise<void>,
|
|
46
|
+
* openConversation: (id: string) => Promise<void>,
|
|
47
|
+
* newConversation: () => void,
|
|
48
|
+
* rate: (turnId: string, rating: "Up"|"Down", note?: string) => Promise<void>,
|
|
49
|
+
* refreshAllowance: () => Promise<void>,
|
|
50
|
+
* reset: () => void
|
|
51
|
+
* }}
|
|
52
|
+
*/
|
|
53
|
+
export declare function useChat({ client, pageContext }: {
|
|
54
|
+
client: import('./client.js').ChatClient;
|
|
55
|
+
pageContext?: any;
|
|
56
|
+
}): {
|
|
57
|
+
turns: ChatTurn[];
|
|
58
|
+
conversationId: string | null;
|
|
59
|
+
messagesLeftToday: number | null;
|
|
60
|
+
streaming: boolean;
|
|
61
|
+
loading: boolean;
|
|
62
|
+
loadError: ChatTurnError | null;
|
|
63
|
+
submit: (message: string) => Promise<void>;
|
|
64
|
+
openConversation: (id: string) => Promise<void>;
|
|
65
|
+
newConversation: () => void;
|
|
66
|
+
rate: (turnId: string, rating: "Up" | "Down", note?: string) => Promise<void>;
|
|
67
|
+
refreshAllowance: () => Promise<void>;
|
|
68
|
+
reset: () => void;
|
|
69
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/chat-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.21.0",
|
|
4
|
+
"description": "Webority AI assistant for React portals: a streaming chat client, a store-agnostic chat hook, and the launcher, panel, thread, rating and support action card, built on @webority/ui-react.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Webority/webority-ui.git",
|
|
14
|
+
"directory": "packages/chat-react"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/chat-react.js",
|
|
20
|
+
"module": "./dist/chat-react.js",
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"default": "./dist/chat-react.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"bootstrap": "5.3.3",
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"react-bootstrap": "^2.10.0",
|
|
34
|
+
"react-dom": "^19.0.0",
|
|
35
|
+
"@webority/ui-react": "0.21.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@testing-library/dom": "10.4.2",
|
|
39
|
+
"@testing-library/jest-dom": "7.0.1",
|
|
40
|
+
"@testing-library/react": "^16.3.0",
|
|
41
|
+
"@testing-library/user-event": "^14.6.1",
|
|
42
|
+
"@types/react": "^19.2.17",
|
|
43
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
44
|
+
"@vitest/coverage-v8": "5.0.1",
|
|
45
|
+
"bootstrap": "5.3.3",
|
|
46
|
+
"jsdom": "30.1.1",
|
|
47
|
+
"react": "^19.2.6",
|
|
48
|
+
"react-bootstrap": "^2.10.6",
|
|
49
|
+
"react-dom": "^19.2.6",
|
|
50
|
+
"typescript": "^7.0.2",
|
|
51
|
+
"vite": "^8.0.12",
|
|
52
|
+
"vitest": "5.0.1",
|
|
53
|
+
"@webority/ui-react": "0.21.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "vite build && tsc -p tsconfig.json",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
"test:coverage": "vitest run --coverage"
|
|
60
|
+
}
|
|
6
61
|
}
|