Skip to content

Commit 8208522

Browse files
committed
📦 NEW: Parser and chunker functions
1 parent cce5254 commit 8208522

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const langbase = new Langbase({
88
});
99

1010
async function main() {
11-
const results = await langbase.chunk({
11+
const results = await langbase.chunker({
1212
content: `Langbase is the most powerful serverless AI platform for building AI agents with memory.
1313
Build, deploy, and scale AI agents with tools and memory (RAG). Simple AI primitives with a world-class developer experience without using any frameworks.
1414

examples/nodejs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"tools.web-search": "npx tsx ./tools/web-search.ts",
3535
"tools.crawl": "npx tsx ./tools/crawl.ts",
3636
"embed": "npx tsx ./embed/index.ts",
37-
"chunk": "npx tsx ./chunk/index.ts",
38-
"parse": "npx tsx ./parse/index.ts",
37+
"chunker": "npx tsx ./chunker/index.ts",
38+
"parser": "npx tsx ./parser/index.ts",
3939
"threads.create": "npx tsx ./threads/threads.create.ts",
4040
"threads.update": "npx tsx ./threads/threads.update.ts",
4141
"threads.delete": "npx tsx ./threads/threads.delete.ts",
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@ const langbase = new Langbase({
1010
});
1111

1212
async function main() {
13-
const documentPath = path.join(
14-
process.cwd(),
15-
'examples',
16-
'parse',
17-
'composable-ai.md',
18-
);
13+
const documentPath = path.join(process.cwd(), 'parser', 'composable-ai.md');
1914

20-
const results = await langbase.parse({
15+
const results = await langbase.parser({
2116
document: fs.readFileSync(documentPath),
2217
documentName: 'composable-ai.md',
2318
contentType: 'application/pdf',

packages/langbase/src/langbase/langbase.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,9 @@ export class Langbase {
591591

592592
public embed: (options: EmbedOptions) => Promise<EmbedResponse>;
593593
public chunk: (options: ChunkOptions) => Promise<ChunkResponse>;
594+
public chunker: (options: ChunkOptions) => Promise<ChunkResponse>;
594595
public parse: (options: ParseOptions) => Promise<ParseResponse>;
596+
public parser: (options: ParseOptions) => Promise<ParseResponse>;
595597

596598
public agent: {
597599
run: {
@@ -667,7 +669,9 @@ export class Langbase {
667669

668670
this.embed = this.generateEmbeddings.bind(this);
669671
this.chunk = this.chunkDocument.bind(this);
672+
this.chunker = this.chunkDocument.bind(this);
670673
this.parse = this.parseDocument.bind(this);
674+
this.parser = this.parseDocument.bind(this);
671675
this.threads = {
672676
create: this.createThread.bind(this),
673677
update: this.updateThread.bind(this),
@@ -974,7 +978,7 @@ export class Langbase {
974978
*/
975979
private async chunkDocument(options: ChunkOptions): Promise<ChunkResponse> {
976980
return this.request.post({
977-
endpoint: '/v1/chunk',
981+
endpoint: '/v1/chunker',
978982
body: options,
979983
});
980984
}
@@ -998,7 +1002,7 @@ export class Langbase {
9981002
contentType: options.contentType,
9991003
});
10001004

1001-
const response = await fetch(`${this.baseUrl}/v1/parse`, {
1005+
const response = await fetch(`${this.baseUrl}/v1/parser`, {
10021006
method: 'POST',
10031007
headers: {
10041008
Authorization: `Bearer ${this.apiKey}`,

0 commit comments

Comments
 (0)