Skip to content

Commit 246004f

Browse files
committed
👌 IMPROVE: Pipe run
1 parent 83976c7 commit 246004f

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

examples/nodejs/examples/pipes/pipe.run.stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {getRunner, Pipe} from 'langbase';
33

44
const pipe = new Pipe({
55
apiKey: process.env.LANGBASE_API_KEY!,
6-
name: 'summary',
76
});
87

98
async function main() {
@@ -14,6 +13,7 @@ async function main() {
1413
messages: [{role: 'user', content: userMsg}],
1514
stream: true,
1615
rawResponse: true,
16+
name: 'summary',
1717
});
1818

1919
// Convert the stream to a stream runner.

examples/nodejs/examples/pipes/pipe.run.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {Pipe} from 'langbase';
33

44
const pipe = new Pipe({
55
apiKey: process.env.LANGBASE_API_KEY!,
6-
name: 'summary',
76
});
87

98
async function main() {
@@ -16,6 +15,8 @@ async function main() {
1615
content: userMsg,
1716
},
1817
],
18+
stream: false,
19+
name: 'summary'
1920
});
2021
console.log('response: ', response);
2122
}

packages/langbase/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"test:ui:react:watch": "vitest --config vitest.ui.react.config.js"
3030
},
3131
"dependencies": {
32-
"@baseai/core": "0.9.30",
32+
"@baseai/core": "0.9.33",
3333
"dotenv": "^16.4.5",
3434
"openai": "^4.53.0",
3535
"zod": "^3.23.8",

packages/langbase/src/pipes/pipes.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ import {Request} from '../common/request';
22
import {Stream} from '../common/stream';
33
import {
44
Pipe as PipeBaseAI,
5-
RunOptions,
6-
RunOptionsStream,
5+
RunOptions as RunOptionsT,
6+
RunOptionsStream as RunOptionsStreamT,
77
RunResponse,
88
RunResponseStream,
99
} from '@baseai/core';
1010

1111
export type Role = 'user' | 'assistant' | 'system' | 'tool';
1212

13+
export interface RunOptions extends RunOptionsT {
14+
name: string;
15+
}
16+
17+
export interface RunOptionsStream extends RunOptionsStreamT {
18+
name: string;
19+
}
20+
1321
export interface Function {
1422
name: string;
1523
arguments: string;
@@ -174,11 +182,13 @@ export interface PipeListResponse {
174182
description?: string;
175183
parameters?: Record<string, any>;
176184
};
177-
}[]
185+
}[]
186+
| [];
187+
memory:
188+
| {
189+
name: string;
190+
}[]
178191
| [];
179-
memory: {
180-
name: string;
181-
}[] | [];
182192
}
183193

184194
interface PipeBaseResponse {
@@ -221,11 +231,6 @@ export class Pipe {
221231
public async run(
222232
options: RunOptions | RunOptionsStream,
223233
): Promise<RunResponse | RunResponseStream> {
224-
if (!this.pipeOptions.name) {
225-
throw new Error(
226-
'Pipe name is required with run. Please provide pipe name when creating Pipe instance.',
227-
);
228-
}
229234
return await this.pipe.run({...options, runTools: false});
230235
}
231236

pnpm-lock.yaml

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)