@genkit-ai/express 1.0.0-rc.13 → 1.0.0-rc.15
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/README.md +10 -13
- package/package.json +2 -2
- package/tests/express_test.ts +1 -1
package/README.md
CHANGED
|
@@ -6,17 +6,14 @@ This plugin provides utilities for conveninetly exposing Genkit flows and action
|
|
|
6
6
|
import { expressHandler } from '@genkit-ai/express';
|
|
7
7
|
import express from 'express';
|
|
8
8
|
|
|
9
|
-
const simpleFlow = ai.defineFlow(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return text;
|
|
18
|
-
}
|
|
19
|
-
);
|
|
9
|
+
const simpleFlow = ai.defineFlow('simpleFlow', async (input, { sendChunk }) => {
|
|
10
|
+
const { text } = await ai.generate({
|
|
11
|
+
model: gemini15Flash,
|
|
12
|
+
prompt: input,
|
|
13
|
+
onChunk: (c) => sendChunk(c.text),
|
|
14
|
+
});
|
|
15
|
+
return text;
|
|
16
|
+
});
|
|
20
17
|
|
|
21
18
|
const app = express();
|
|
22
19
|
app.use(express.json());
|
|
@@ -52,10 +49,10 @@ app.post(
|
|
|
52
49
|
);
|
|
53
50
|
```
|
|
54
51
|
|
|
55
|
-
Flows and actions exposed using the `expressHandler` function can be accessed using `genkit/client` library:
|
|
52
|
+
Flows and actions exposed using the `expressHandler` function can be accessed using `genkit/beta/client` library:
|
|
56
53
|
|
|
57
54
|
```ts
|
|
58
|
-
import { runFlow, streamFlow } from 'genkit/client';
|
|
55
|
+
import { runFlow, streamFlow } from 'genkit/beta/client';
|
|
59
56
|
|
|
60
57
|
const result = await runFlow({
|
|
61
58
|
url: `http://localhost:${port}/simpleFlow`,
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"genai",
|
|
10
10
|
"generative-ai"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-rc.
|
|
12
|
+
"version": "1.0.0-rc.15",
|
|
13
13
|
"type": "commonjs",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"express": "^4.21.1",
|
|
27
|
-
"genkit": "^1.0.0-rc.
|
|
27
|
+
"genkit": "^1.0.0-rc.15"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"get-port": "^5.1.0",
|
package/tests/express_test.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import * as assert from 'assert';
|
|
18
18
|
import express from 'express';
|
|
19
19
|
import { GenerateResponseData, Genkit, genkit, z } from 'genkit';
|
|
20
|
-
import { runFlow, streamFlow } from 'genkit/client';
|
|
20
|
+
import { runFlow, streamFlow } from 'genkit/beta/client';
|
|
21
21
|
import { GenerateResponseChunkData, ModelAction } from 'genkit/model';
|
|
22
22
|
import getPort from 'get-port';
|
|
23
23
|
import * as http from 'http';
|