@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 +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/useInteractionStreaming.d.ts +8 -0
- package/lib/useInteractionStreaming.d.ts.map +1 -0
- package/lib/useInteractionStreaming.js +24 -0
- package/lib/useInteractionStreaming.js.map +1 -0
- package/package.json +39 -44
package/lib/index.d.ts
ADDED
|
@@ -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
package/lib/index.js.map
ADDED
|
@@ -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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
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
}
|