Skip to content

Commit

Permalink
👌 IMPROVE: Pipe run
Browse files Browse the repository at this point in the history
  • Loading branch information
msaaddev committed Nov 21, 2024
1 parent 83976c7 commit 246004f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/nodejs/examples/pipes/pipe.run.stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {getRunner, Pipe} from 'langbase';

const pipe = new Pipe({
apiKey: process.env.LANGBASE_API_KEY!,
name: 'summary',
});

async function main() {
Expand All @@ -14,6 +13,7 @@ async function main() {
messages: [{role: 'user', content: userMsg}],
stream: true,
rawResponse: true,
name: 'summary',
});

// Convert the stream to a stream runner.
Expand Down
3 changes: 2 additions & 1 deletion examples/nodejs/examples/pipes/pipe.run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {Pipe} from 'langbase';

const pipe = new Pipe({
apiKey: process.env.LANGBASE_API_KEY!,
name: 'summary',
});

async function main() {
Expand All @@ -16,6 +15,8 @@ async function main() {
content: userMsg,
},
],
stream: false,
name: 'summary'
});
console.log('response: ', response);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/langbase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test:ui:react:watch": "vitest --config vitest.ui.react.config.js"
},
"dependencies": {
"@baseai/core": "0.9.30",
"@baseai/core": "0.9.33",
"dotenv": "^16.4.5",
"openai": "^4.53.0",
"zod": "^3.23.8",
Expand Down
27 changes: 16 additions & 11 deletions packages/langbase/src/pipes/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import {Request} from '../common/request';
import {Stream} from '../common/stream';
import {
Pipe as PipeBaseAI,
RunOptions,
RunOptionsStream,
RunOptions as RunOptionsT,
RunOptionsStream as RunOptionsStreamT,
RunResponse,
RunResponseStream,
} from '@baseai/core';

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

export interface RunOptions extends RunOptionsT {
name: string;
}

export interface RunOptionsStream extends RunOptionsStreamT {
name: string;
}

export interface Function {
name: string;
arguments: string;
Expand Down Expand Up @@ -174,11 +182,13 @@ export interface PipeListResponse {
description?: string;
parameters?: Record<string, any>;
};
}[]
}[]
| [];
memory:
| {
name: string;
}[]
| [];
memory: {
name: string;
}[] | [];
}

interface PipeBaseResponse {
Expand Down Expand Up @@ -221,11 +231,6 @@ export class Pipe {
public async run(
options: RunOptions | RunOptionsStream,
): Promise<RunResponse | RunResponseStream> {
if (!this.pipeOptions.name) {
throw new Error(
'Pipe name is required with run. Please provide pipe name when creating Pipe instance.',
);
}
return await this.pipe.run({...options, runTools: false});
}

Expand Down
25 changes: 23 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 246004f

Please sign in to comment.