@stainless-api/docs-ai-chat 0.1.0-beta.47 → 0.1.0-beta.48
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/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/src/hook.ts +7 -7
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainless-api/docs-ai-chat",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.48",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@streamparser/json-whatwg": "^0.0.22",
|
|
15
15
|
"zod": "^4.3.6",
|
|
16
|
-
"@stainless-api/ai-chat": "0.1.0-beta.
|
|
16
|
+
"@stainless-api/ai-chat": "0.1.0-beta.10"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/react": "19.2.14",
|
package/src/hook.ts
CHANGED
|
@@ -121,12 +121,12 @@ export function useChat({
|
|
|
121
121
|
siteTitle: string | undefined;
|
|
122
122
|
}) {
|
|
123
123
|
// Used to clean up stray streaming requests on unmount (prevent setState on unmounted component)
|
|
124
|
-
const
|
|
124
|
+
const abortControllerRef = useRef(new AbortController());
|
|
125
125
|
useEffect(() => {
|
|
126
|
-
|
|
126
|
+
abortControllerRef.current = abortControllerRef.current.signal.aborted
|
|
127
127
|
? new AbortController()
|
|
128
|
-
:
|
|
129
|
-
const ac =
|
|
128
|
+
: abortControllerRef.current;
|
|
129
|
+
const ac = abortControllerRef.current;
|
|
130
130
|
return () => ac.abort('Component unmounted');
|
|
131
131
|
}, []);
|
|
132
132
|
|
|
@@ -153,9 +153,9 @@ export function useChat({
|
|
|
153
153
|
),
|
|
154
154
|
siteTitle,
|
|
155
155
|
},
|
|
156
|
-
|
|
156
|
+
abortControllerRef.current.signal,
|
|
157
157
|
)) {
|
|
158
|
-
if (
|
|
158
|
+
if (abortControllerRef.current.signal.aborted) break;
|
|
159
159
|
|
|
160
160
|
// mark complete when text messages finish streaming
|
|
161
161
|
if (lastChunkType === 'text' && chunk.type !== 'text') {
|
|
@@ -201,7 +201,7 @@ export function useChat({
|
|
|
201
201
|
|
|
202
202
|
lastChunkType = chunk.type;
|
|
203
203
|
}
|
|
204
|
-
if (!chunk) {
|
|
204
|
+
if (!chunk || lastChunkType === 'start_session') {
|
|
205
205
|
dispatch({
|
|
206
206
|
type: 'addError',
|
|
207
207
|
respondingTo: userMessageId,
|