Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/nodejs/examples/pipes/pipe.list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dotenv/config';
import {Pipe} from 'langbase';

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

async function main() {
const response = await pipe.list();
console.log(response);
}

main();
8 changes: 8 additions & 0 deletions packages/langbase/src/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export class Request {
await this.handleErrorResponse({response});
}

if(!options.body) {
return this.handleGenerateResponse({
response,
isChat: false,
threadId: null,
})
}

const threadId = response.headers.get('lb-thread-id');

if (options.body.stream) {
Expand Down
9 changes: 9 additions & 0 deletions packages/langbase/src/pipes/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ interface BaseResponse {
status: 'public' | 'private';
owner_login: string;
url: string;
type: 'chat' | 'generate' | 'run';
api_key: string;
}

export interface CreateOptions extends BaseOptions {}
Expand All @@ -167,6 +169,7 @@ export class Pipe {
const baseUrl = 'https://api.langbase.com';
this.request = new Request({apiKey: options.apiKey, baseUrl});
this.pipeOptions = options;

this.pipe = new PipeBaseAI({
apiKey: options.apiKey, // Langbase API key
name: options.name?.trim() || '', // Pipe name
Expand Down Expand Up @@ -217,6 +220,12 @@ export class Pipe {
body: options,
});
}

async list() {
return this.request.get({
endpoint: '/v1/pipes',
});
}
}

/**
Expand Down
Loading