@vertesia/react 0.78.0-dev-28b447d → 0.79.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/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './useInteractionStreaming.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './useInteractionStreaming.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { InteractionBase } from "@vertesia/client";
2
+ import { ExecutionRun, InteractionExecutionPayload } from "@vertesia/common";
3
+ export declare function useInteractionStreaming<TProps>(interaction: InteractionBase<TProps>): {
4
+ text: string;
5
+ isRunning: boolean;
6
+ execute: (payload?: InteractionExecutionPayload) => Promise<ExecutionRun<TProps>>;
7
+ };
8
+ //# sourceMappingURL=useInteractionStreaming.d.ts.map
@@ -0,0 +1 @@
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,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC;;;wBAKvC,2BAA2B,KAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;EAmBvG"}
@@ -0,0 +1,24 @@
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
@@ -0,0 +1 @@
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,CAAS,WAAoC;IAEhF,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,EAAiC,EAAE;QACnG,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"}
package/package.json CHANGED
@@ -1,45 +1,40 @@
1
1
  {
2
- "name": "@vertesia/react",
3
- "version": "0.78.0-dev-28b447d",
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
+ "name": "@vertesia/react",
3
+ "version": "0.79.0",
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
+ "devDependencies": {
23
+ "@types/json-schema": "^7.0.15",
24
+ "@types/react": "^19.1.0",
25
+ "typescript": "^5.0.2"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=16.8.0"
29
+ },
30
+ "dependencies": {
31
+ "json-schema": "^0.4.0",
32
+ "@vertesia/client": "0.79.0",
33
+ "@vertesia/common": "0.79.0"
34
+ },
35
+ "scripts": {
36
+ "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
37
+ "build": "rm -rf ./lib ./tsconfig.tsbuildinfo && tsc --build",
38
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
39
+ }
40
+ }