Skip to content

Commit 20c2220

Browse files
committed
🐛 FIX: comments for filter examples
1 parent b8bc15a commit 20c2220

File tree

7 files changed

+110
-30
lines changed

7 files changed

+110
-30
lines changed

examples/nodejs/examples/memory/memory.retrieve.filters.And.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* Basic example to demonstrate how to retrieve memories with filters.
3+
*
4+
* - And: This filter is used to retrieve memories that match all the filters.
5+
* - Eq: This filter is used to retrieve memories that match the exact value.
6+
*
7+
* In this example, we retrieve memories with the following filters:
8+
* - company: Langbase
9+
* - category: docs
10+
*
11+
* We expect to get all chunks of memory from the Langbase Docs memory that have the company Langbase and the category docs.
12+
*
13+
*/
14+
115
import 'dotenv/config';
216
import {Langbase} from 'langbase';
317

examples/nodejs/examples/memory/memory.retrieve.filters.Eq.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/**
2+
* Basic example to demonstrate how to retrieve memories with filters.
3+
*
4+
* - Eq: This filter is used to retrieve memories that match the exact value.
5+
*
6+
* In this example, we retrieve memories with the following filters:
7+
* - company: Langbase
8+
*
9+
* We expect to get all chunks of memory from the Langbase Docs memory that have the company Langbase.
10+
*
11+
*/
12+
113
import 'dotenv/config';
214
import {Langbase} from 'langbase';
315

examples/nodejs/examples/memory/memory.retrieve.filters.In.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/**
2+
* Basic example to demonstrate how to retrieve memories with filters.
3+
*
4+
* - In: This filter is used to retrieve memories that match any of the value/values in the array.
5+
*
6+
* In this example, we retrieve memories with the following filters:
7+
* - company: Langbase or Google
8+
*
9+
* We expect to get all chunks of memory from the Langbase Docs memory that have the company Langbase or Google.
10+
*
11+
*/
12+
113
import 'dotenv/config';
214
import {Langbase} from 'langbase';
315

examples/nodejs/examples/memory/memory.retrieve.filters.NotEq.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/**
2+
* Basic example to demonstrate how to retrieve memories with filters.
3+
*
4+
* - NotEq: This filter is used to retrieve memories that do not match the exact value.
5+
*
6+
* In this example, we retrieve memories with the following filters:
7+
* - company: Langbase
8+
*
9+
* We expect to get all chunks of memory from the Langbase Docs memory that do not have the company Langbase.
10+
*
11+
*/
12+
113
import 'dotenv/config';
214
import {Langbase} from 'langbase';
315

examples/nodejs/examples/memory/memory.retrieve.filters.NotIn.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/**
2+
* Basic example to demonstrate how to retrieve memories with filters.
3+
*
4+
* - NotIn: This filter is used to retrieve memories that do not match any of the value/values in the array.
5+
*
6+
* In this example, we retrieve memories with the following filters:
7+
* - company: Google
8+
*
9+
* We expect to get all chunks of memory from the Langbase Docs memory that do not have the company Google.
10+
*
11+
*/
12+
113
import 'dotenv/config';
214
import {Langbase} from 'langbase';
315

examples/nodejs/examples/memory/memory.retrieve.filters.Or.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Advanced example to demonstrate how to retrieve memories with filters.
3+
*
4+
* - And: This filter is used to retrieve memories that match all the filters.
5+
* - Or: This filter is used to retrieve memories that match any of the filters.
6+
* - In: This filter is used to retrieve memories that match any of the value/values in the array.
7+
* - Eq: This filter is used to retrieve memories that match the exact value.
8+
*
9+
* In this example, we retrieve memories with the following filters:
10+
* - company: Langbase
11+
* - category: docs or examples
12+
* - primative: Chunk or Threads
13+
*
14+
* We expect to get all chunks of memory from the Langbase Docs memory
15+
* that have the company Langbase, the category docs or examples, and the primative can be Chunk or Threads.
16+
*
17+
*/
18+
19+
import 'dotenv/config';
20+
import {Langbase} from 'langbase';
21+
22+
const langbase = new Langbase({
23+
apiKey: process.env.LANGBASE_API_KEY!,
24+
});
25+
26+
async function main() {
27+
const response = await langbase.memories.retrieve({
28+
memory: [
29+
{
30+
name: "langbase-docs",
31+
filters: ["And", [
32+
["company", "Eq", "Langbase"],
33+
["Or", [
34+
["category", "Eq", "docs"],
35+
["category", "Eq", "examples"]
36+
]],
37+
["primative", "In", ["Chunk", "Threads"]]
38+
]]
39+
}
40+
],
41+
query: "What are primitives in Langbase?",
42+
topK: 5
43+
});
44+
45+
console.log(response);
46+
}
47+
48+
main();

0 commit comments

Comments
 (0)