Skip to content

Commit 7f301db

Browse files
authored
📦 NEW: Pipe list support (#74)
1 parent 207f708 commit 7f301db

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'dotenv/config';
2+
import {Pipe} from 'langbase';
3+
4+
const pipe = new Pipe({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await pipe.list();
10+
console.log(response);
11+
}
12+
13+
main();

packages/langbase/src/common/request.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ export class Request {
5757
await this.handleErrorResponse({response});
5858
}
5959

60+
if(!options.body) {
61+
return this.handleGenerateResponse({
62+
response,
63+
isChat: false,
64+
threadId: null,
65+
})
66+
}
67+
6068
const threadId = response.headers.get('lb-thread-id');
6169

6270
if (options.body.stream) {

packages/langbase/src/pipes/pipes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ interface BaseResponse {
151151
status: 'public' | 'private';
152152
owner_login: string;
153153
url: string;
154+
type: 'chat' | 'generate' | 'run';
155+
api_key: string;
154156
}
155157

156158
export interface CreateOptions extends BaseOptions {}
@@ -167,6 +169,7 @@ export class Pipe {
167169
const baseUrl = 'https://api.langbase.com';
168170
this.request = new Request({apiKey: options.apiKey, baseUrl});
169171
this.pipeOptions = options;
172+
170173
this.pipe = new PipeBaseAI({
171174
apiKey: options.apiKey, // Langbase API key
172175
name: options.name?.trim() || '', // Pipe name
@@ -217,6 +220,12 @@ export class Pipe {
217220
body: options,
218221
});
219222
}
223+
224+
async list() {
225+
return this.request.get({
226+
endpoint: '/v1/pipes',
227+
});
228+
}
220229
}
221230

222231
/**

0 commit comments

Comments
 (0)