wecool-chat 0.1.0 → 0.2.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/dist/client.d.ts +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/components/ChatFooter.d.ts +3 -2
- package/dist/components/ChatFooter.d.ts.map +1 -1
- package/dist/components/ChatPanel.d.ts +2 -1
- package/dist/components/ChatPanel.d.ts.map +1 -1
- package/dist/components/ChatWidget.d.ts.map +1 -1
- package/dist/hooks/cancellation-log.d.ts +14 -0
- package/dist/hooks/cancellation-log.d.ts.map +1 -0
- package/dist/hooks/consume-stream.d.ts +20 -0
- package/dist/hooks/consume-stream.d.ts.map +1 -0
- package/dist/hooks/run-conversation.d.ts +23 -0
- package/dist/hooks/run-conversation.d.ts.map +1 -0
- package/dist/hooks/stream-state.d.ts +23 -0
- package/dist/hooks/stream-state.d.ts.map +1 -0
- package/dist/hooks/tool-runner.d.ts +8 -4
- package/dist/hooks/tool-runner.d.ts.map +1 -1
- package/dist/hooks/use-send-message.d.ts +29 -0
- package/dist/hooks/use-send-message.d.ts.map +1 -0
- package/dist/hooks/use-stream-lifecycle.d.ts +42 -0
- package/dist/hooks/use-stream-lifecycle.d.ts.map +1 -0
- package/dist/hooks/use-tool-runner.d.ts +15 -0
- package/dist/hooks/use-tool-runner.d.ts.map +1 -0
- package/dist/hooks/useChatStream.d.ts +41 -8
- package/dist/hooks/useChatStream.d.ts.map +1 -1
- package/dist/index.js +514 -353
- package/dist/types.d.ts +16 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Schema for tool parameters
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ToolParameters = {
|
|
5
5
|
type: "object";
|
|
6
6
|
properties: Record<string, {
|
|
7
7
|
type: "string" | "number" | "boolean" | "array" | "object";
|
|
@@ -12,11 +12,11 @@ export interface ToolParameters {
|
|
|
12
12
|
};
|
|
13
13
|
}>;
|
|
14
14
|
required?: string[];
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
/**
|
|
17
17
|
* Tool definition that can be executed by the LLM
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type Tool = {
|
|
20
20
|
/** Unique identifier for the tool */
|
|
21
21
|
name: string;
|
|
22
22
|
/** Human-readable description for the LLM to understand when to use this tool */
|
|
@@ -25,19 +25,19 @@ export interface Tool {
|
|
|
25
25
|
parameters: ToolParameters;
|
|
26
26
|
/** Function to execute when the LLM calls this tool */
|
|
27
27
|
handler: (args: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
/**
|
|
30
30
|
* Tool definition sent to the API (without handler)
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export type ToolDefinition = {
|
|
33
33
|
name: string;
|
|
34
34
|
description: string;
|
|
35
35
|
parameters: ToolParameters;
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
37
|
/**
|
|
38
38
|
* Configuration for initializing the chat widget
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type ChatConfig = {
|
|
41
41
|
/** API endpoint URL */
|
|
42
42
|
endpoint: string;
|
|
43
43
|
/** API key for authentication */
|
|
@@ -58,11 +58,11 @@ export interface ChatConfig {
|
|
|
58
58
|
className?: string;
|
|
59
59
|
/** Placeholder text for the input field */
|
|
60
60
|
placeholder?: string;
|
|
61
|
-
}
|
|
61
|
+
};
|
|
62
62
|
/**
|
|
63
63
|
* Chat message
|
|
64
64
|
*/
|
|
65
|
-
export
|
|
65
|
+
export type Message = {
|
|
66
66
|
id: string;
|
|
67
67
|
role: "user" | "assistant" | "system" | "tool";
|
|
68
68
|
content: string;
|
|
@@ -72,14 +72,14 @@ export interface Message {
|
|
|
72
72
|
arguments: Record<string, unknown>;
|
|
73
73
|
};
|
|
74
74
|
toolResult?: unknown;
|
|
75
|
-
}
|
|
75
|
+
};
|
|
76
76
|
/**
|
|
77
77
|
* Tool call from the API
|
|
78
78
|
*/
|
|
79
|
-
export
|
|
79
|
+
export type ToolCall = {
|
|
80
80
|
name: string;
|
|
81
81
|
arguments: Record<string, unknown>;
|
|
82
|
-
}
|
|
82
|
+
};
|
|
83
83
|
/**
|
|
84
84
|
* SSE event received from the server
|
|
85
85
|
*/
|
|
@@ -107,16 +107,16 @@ export type ChatEvent = {
|
|
|
107
107
|
/**
|
|
108
108
|
* Tool result sent back to the server
|
|
109
109
|
*/
|
|
110
|
-
export
|
|
110
|
+
export type ToolResult = {
|
|
111
111
|
toolCallId: string;
|
|
112
112
|
toolName: string;
|
|
113
113
|
toolInput: Record<string, unknown>;
|
|
114
114
|
result: unknown;
|
|
115
|
-
}
|
|
115
|
+
};
|
|
116
116
|
/**
|
|
117
117
|
* Props for ChatWidget component
|
|
118
118
|
*/
|
|
119
|
-
export
|
|
119
|
+
export type ChatWidgetProps = {
|
|
120
120
|
config: Omit<ChatConfig, "tools"> & {
|
|
121
121
|
tools?: Tool[];
|
|
122
122
|
};
|
|
@@ -127,5 +127,5 @@ export interface ChatWidgetProps {
|
|
|
127
127
|
defaultOpen?: boolean;
|
|
128
128
|
/** Position for floating mode */
|
|
129
129
|
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
130
|
-
}
|
|
130
|
+
};
|
|
131
131
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAChB,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