@vertesia/react 0.77.0 → 0.78.0-dev-9372725
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/package.json +44 -39
- package/src/useInteractionStreaming.ts +2 -2
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/useInteractionStreaming.d.ts +0 -8
- package/lib/useInteractionStreaming.d.ts.map +0 -1
- package/lib/useInteractionStreaming.js +0 -24
- package/lib/useInteractionStreaming.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
2
|
+
"name": "@vertesia/react",
|
|
3
|
+
"version": "0.78.0-dev-9372725",
|
|
4
|
+
"description": "React helpers for Composable AI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"lib",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://docs.vertesiahq.com",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"llm",
|
|
16
|
+
"streaming",
|
|
17
|
+
"composable",
|
|
18
|
+
"prompt",
|
|
19
|
+
"ai",
|
|
20
|
+
"react"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
|
|
24
|
+
"build": "rm -rf ./lib ./tsconfig.tsbuildinfo && tsc --build",
|
|
25
|
+
"clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/json-schema": "^7.0.15",
|
|
29
|
+
"@types/react": "^19.1.0",
|
|
30
|
+
"typescript": "^5.0.2"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": ">=16.8.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@vertesia/client": "workspace:*",
|
|
37
|
+
"@vertesia/common": "workspace:*",
|
|
38
|
+
"json-schema": "^0.4.0"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
43
|
+
"directory": "packages/react"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -2,12 +2,12 @@ import { InteractionBase } from "@vertesia/client";
|
|
|
2
2
|
import { ExecutionRun, InteractionExecutionPayload } from "@vertesia/common";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
|
|
5
|
-
export function useInteractionStreaming<TProps
|
|
5
|
+
export function useInteractionStreaming<TProps>(interaction: InteractionBase<TProps>) {
|
|
6
6
|
|
|
7
7
|
const [isRunning, setRunning] = useState(false);
|
|
8
8
|
const [text, setText] = useState('');
|
|
9
9
|
|
|
10
|
-
const execute = useMemo(() => (payload?: InteractionExecutionPayload): Promise<ExecutionRun<TProps
|
|
10
|
+
const execute = useMemo(() => (payload?: InteractionExecutionPayload): Promise<ExecutionRun<TProps>> => {
|
|
11
11
|
if (isRunning) {
|
|
12
12
|
return Promise.reject(new Error('Trying to run the interaction while it is already running.'));
|
|
13
13
|
}
|
package/lib/index.d.ts
DELETED
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAC"}
|
package/lib/index.js
DELETED
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { InteractionBase } from "@vertesia/client";
|
|
2
|
-
import { ExecutionRun, InteractionExecutionPayload } from "@vertesia/common";
|
|
3
|
-
export declare function useInteractionStreaming<TProps, TReturn>(interaction: InteractionBase<TProps, TReturn>): {
|
|
4
|
-
text: string;
|
|
5
|
-
isRunning: boolean;
|
|
6
|
-
execute: (payload?: InteractionExecutionPayload) => Promise<ExecutionRun<TProps, TReturn>>;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=useInteractionStreaming.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInteractionStreaming.d.ts","sourceRoot":"","sources":["../src/useInteractionStreaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAG7E,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC;;;wBAKzD,2BAA2B,KAAG,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;EAmBhH"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
export function useInteractionStreaming(interaction) {
|
|
3
|
-
const [isRunning, setRunning] = useState(false);
|
|
4
|
-
const [text, setText] = useState('');
|
|
5
|
-
const execute = useMemo(() => (payload) => {
|
|
6
|
-
if (isRunning) {
|
|
7
|
-
return Promise.reject(new Error('Trying to run the interaction while it is already running.'));
|
|
8
|
-
}
|
|
9
|
-
setRunning(true);
|
|
10
|
-
let chunks = [];
|
|
11
|
-
return interaction.execute(payload, (chunk) => {
|
|
12
|
-
chunks.push(chunk);
|
|
13
|
-
setText(chunks.join(''));
|
|
14
|
-
}).then(run => {
|
|
15
|
-
setText('');
|
|
16
|
-
setRunning(false);
|
|
17
|
-
return run;
|
|
18
|
-
}).finally(() => {
|
|
19
|
-
chunks = [];
|
|
20
|
-
});
|
|
21
|
-
}, []);
|
|
22
|
-
return { text, isRunning, execute };
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=useInteractionStreaming.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInteractionStreaming.js","sourceRoot":"","sources":["../src/useInteractionStreaming.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,UAAU,uBAAuB,CAAkB,WAA6C;IAElG,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,OAAqC,EAA0C,EAAE;QAC5G,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC,CAAC;QACnG,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,MAAM,GAAa,EAAE,CAAC;QAC1B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACV,OAAO,CAAC,EAAE,CAAC,CAAC;YACZ,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,OAAO,GAAG,CAAC;QACf,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACZ,MAAM,GAAG,EAAE,CAAA;QACf,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;AACvC,CAAC"}
|