@fencyai/react 0.1.49 → 0.1.51
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/lib/hooks/useFencyEventSource/index.d.ts +1 -0
- package/lib/hooks/useFencyEventSource/index.js +1 -1
- package/lib/hooks/useFiles/index.js +1 -0
- package/lib/hooks/useStream/toStreamData.js +15 -15
- package/lib/hooks/useStreamingChatCompletions/index.js +6 -5
- package/lib/hooks/useWebsites/index.js +3 -1
- package/lib/types/CreateFileParams.d.ts +1 -0
- package/lib/types/CreateWebsiteParams.d.ts +2 -0
- package/package.json +4 -4
|
@@ -40,8 +40,8 @@ const toStreamDataRaw = (data) => {
|
|
|
40
40
|
const toNewChatCompletionStreamChunk = (data) => {
|
|
41
41
|
return {
|
|
42
42
|
type: 'NewChatCompletionStreamChunk',
|
|
43
|
-
streamId: data.streamId
|
|
44
|
-
chatCompletionId: data.chatCompletionId
|
|
43
|
+
streamId: data.streamId,
|
|
44
|
+
chatCompletionId: data.chatCompletionId,
|
|
45
45
|
timestamp: data.timestamp,
|
|
46
46
|
content: data.content,
|
|
47
47
|
};
|
|
@@ -49,39 +49,39 @@ const toNewChatCompletionStreamChunk = (data) => {
|
|
|
49
49
|
const toChatCompletionStreamCompleted = (data) => {
|
|
50
50
|
return {
|
|
51
51
|
type: 'ChatCompletionStreamCompleted',
|
|
52
|
-
streamId: data.streamId
|
|
53
|
-
chatCompletionId: data.chatCompletionId
|
|
52
|
+
streamId: data.streamId,
|
|
53
|
+
chatCompletionId: data.chatCompletionId,
|
|
54
54
|
timestamp: data.timestamp,
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
const toStreamTimeout = (data) => {
|
|
58
58
|
return {
|
|
59
59
|
type: 'StreamTimeout',
|
|
60
|
-
streamId: data.streamId
|
|
60
|
+
streamId: data.streamId,
|
|
61
61
|
timestamp: data.timestamp,
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
const toStreamNotFound = (data) => {
|
|
65
65
|
return {
|
|
66
66
|
type: 'StreamNotFound',
|
|
67
|
-
streamId: data.streamId
|
|
67
|
+
streamId: data.streamId,
|
|
68
68
|
timestamp: data.timestamp,
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
71
|
const toFileUploadCompleted = (data) => {
|
|
72
72
|
return {
|
|
73
73
|
type: 'FileUploadCompleted',
|
|
74
|
-
streamId: data.streamId
|
|
75
|
-
uploadId: data.fileId
|
|
76
|
-
fileId: data.fileId
|
|
74
|
+
streamId: data.streamId,
|
|
75
|
+
uploadId: data.fileId,
|
|
76
|
+
fileId: data.fileId,
|
|
77
77
|
timestamp: data.timestamp,
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
const toFileTextContentReady = (data) => {
|
|
81
81
|
return {
|
|
82
82
|
type: 'FileTextContentReady',
|
|
83
|
-
streamId: data.streamId
|
|
84
|
-
fileId: data.fileId
|
|
83
|
+
streamId: data.streamId,
|
|
84
|
+
fileId: data.fileId,
|
|
85
85
|
textContent: data.textContent,
|
|
86
86
|
timestamp: data.timestamp,
|
|
87
87
|
};
|
|
@@ -89,8 +89,8 @@ const toFileTextContentReady = (data) => {
|
|
|
89
89
|
const toWebsiteHtmlContentReady = (data) => {
|
|
90
90
|
return {
|
|
91
91
|
type: 'WebsiteHtmlContentReady',
|
|
92
|
-
streamId: data.streamId
|
|
93
|
-
websiteId: data.websiteId
|
|
92
|
+
streamId: data.streamId,
|
|
93
|
+
websiteId: data.websiteId,
|
|
94
94
|
htmlContent: data.htmlContent,
|
|
95
95
|
timestamp: data.timestamp,
|
|
96
96
|
};
|
|
@@ -98,8 +98,8 @@ const toWebsiteHtmlContentReady = (data) => {
|
|
|
98
98
|
const toWebsiteTextContentReady = (data) => {
|
|
99
99
|
return {
|
|
100
100
|
type: 'WebsiteTextContentReady',
|
|
101
|
-
streamId: data.streamId
|
|
102
|
-
websiteId: data.websiteId
|
|
101
|
+
streamId: data.streamId,
|
|
102
|
+
websiteId: data.websiteId,
|
|
103
103
|
textContent: data.textContent,
|
|
104
104
|
timestamp: data.timestamp,
|
|
105
105
|
};
|
|
@@ -9,9 +9,7 @@ export const useStreamingChatCompletions = () => {
|
|
|
9
9
|
const [chunks, setChunks] = useState([]);
|
|
10
10
|
const { stream, createStream } = useStream({
|
|
11
11
|
onNewChatCompletionStreamChunk: (streamData) => {
|
|
12
|
-
|
|
13
|
-
setChunks((prev) => [...prev, streamData]);
|
|
14
|
-
}
|
|
12
|
+
setChunks((prev) => [...prev, streamData]);
|
|
15
13
|
},
|
|
16
14
|
onChatCompletionStreamCompleted: (stream) => {
|
|
17
15
|
setCompletedStreamIds((prev) => [...prev, stream.streamId]);
|
|
@@ -50,7 +48,9 @@ export const useStreamingChatCompletions = () => {
|
|
|
50
48
|
const newChatCompletions = [];
|
|
51
49
|
for (const chatCompletion of chatCompletions) {
|
|
52
50
|
const relevantChunks = chunks
|
|
53
|
-
.filter((chunk) =>
|
|
51
|
+
.filter((chunk) => {
|
|
52
|
+
return chunk.streamId === chatCompletion.streamId;
|
|
53
|
+
})
|
|
54
54
|
.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
55
55
|
const fullMessage = relevantChunks
|
|
56
56
|
.map((chunk) => chunk.content)
|
|
@@ -195,7 +195,8 @@ export const useStreamingChatCompletions = () => {
|
|
|
195
195
|
}, [context]);
|
|
196
196
|
const latest = useMemo(() => {
|
|
197
197
|
return chatCompletions.sort((a, b) => {
|
|
198
|
-
return new Date(b.triggeredAt).getTime() -
|
|
198
|
+
return (new Date(b.triggeredAt).getTime() -
|
|
199
|
+
new Date(a.triggeredAt).getTime());
|
|
199
200
|
})[0];
|
|
200
201
|
}, [chatCompletions]);
|
|
201
202
|
return {
|
|
@@ -10,7 +10,7 @@ export function useWebsites(props) {
|
|
|
10
10
|
props?.onHtmlContentReady?.(streamData);
|
|
11
11
|
setWebsites((prev) => prev.map((website) => {
|
|
12
12
|
return website.id === streamData.websiteId
|
|
13
|
-
? { ...website,
|
|
13
|
+
? { ...website, htmlContent: streamData.htmlContent }
|
|
14
14
|
: website;
|
|
15
15
|
}));
|
|
16
16
|
},
|
|
@@ -31,6 +31,8 @@ export function useWebsites(props) {
|
|
|
31
31
|
request: {
|
|
32
32
|
url: params.url,
|
|
33
33
|
streamId: stream.stream.id,
|
|
34
|
+
extractHtmlContent: params.extractHtmlContent || true,
|
|
35
|
+
extractTextContent: params.extractTextContent || true,
|
|
34
36
|
},
|
|
35
37
|
baseUrl: context.fency.baseUrl,
|
|
36
38
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "staklau <steinaageklaussen@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"zod": "^4.0.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@fencyai/js": "^0.1.
|
|
39
|
+
"@fencyai/js": "^0.1.51",
|
|
40
40
|
"@types/jest": "^29.5.11",
|
|
41
41
|
"@types/node": "^20.10.5",
|
|
42
42
|
"@types/react": "^18.2.45",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "^5.3.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@fencyai/js": "^0.1.
|
|
48
|
+
"@fencyai/js": "^0.1.51",
|
|
49
49
|
"react": ">=16.8.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "78ae5a655bece0599efe1e207ebda23e2e6b0260"
|
|
52
52
|
}
|