Skip to content

Commit d0643ee

Browse files
committed
📦 NEW: SDK
1 parent 4cd5248 commit d0643ee

File tree

4 files changed

+34
-33
lines changed

4 files changed

+34
-33
lines changed

packages/langbase/src/common/errors.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ export class APIError extends Error {
2020
super(APIError.makeMessage(status, error, message));
2121
this.status = status;
2222
this.headers = headers;
23-
this.request_id = headers?.['x-request-id'];
23+
this.request_id = headers?.['lb-request-id'];
2424

2525
const data = error as Record<string, any>;
2626
this.error = data;
2727
this.code = data?.['code'];
28-
this.param = data?.['param'];
29-
this.type = data?.['type'];
28+
this.status = data?.['status'];
29+
// this.param = data?.['param'];
30+
// this.type = data?.['type'];
3031
}
3132

3233
private static makeMessage(

packages/langbase/src/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
import {Pipe, PipeOptions} from './pipes/pipes';
2-
3-
class Langbase {
4-
static pipe(options: PipeOptions): Pipe {
5-
return new Pipe(options);
6-
}
7-
}
8-
9-
export default Langbase;
1+
export {Pipe} from './pipes/pipes';
2+
export type {PipeOptions} from './pipes/pipes';

packages/langbase/src/pipes/gen.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'dotenv/config';
2+
import {Pipe} from './../index';
3+
4+
async function main() {
5+
const pipeLessWordy = new Pipe({
6+
apiKey: process.env.PIPE_LESS_WORDY!,
7+
});
8+
9+
const result = await pipeLessWordy.generateText({
10+
messages: [{role: 'user', content: 'Who is Ahmad Awais?'}],
11+
});
12+
13+
console.log(result.completion);
14+
15+
const pipeLessWordyStream = new Pipe({
16+
apiKey: process.env.PIPE_LESS_WORDY_STREAM!,
17+
});
18+
19+
const stream = await pipeLessWordyStream.streamText({
20+
messages: [{role: 'user', content: 'Who is Ahmad Awais?'}],
21+
});
22+
23+
for await (const chunk of stream) {
24+
process.stdout.write(chunk.choices[0]?.delta?.content || '');
25+
}
26+
}
27+
28+
main();

0 commit comments

Comments
 (0)