Skip to content

Commit a6002e3

Browse files
committed
👌 IMPROVE: memory example with filters
1 parent 442f1cf commit a6002e3

File tree

6 files changed

+148
-0
lines changed

6 files changed

+148
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'dotenv/config';
2+
import {Langbase} from 'langbase';
3+
4+
const langbase = new Langbase({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await langbase.memories.retrieve({
10+
memory: [
11+
{
12+
name: "langbase-docs",
13+
filters:["And", [
14+
["company", "Eq", "Langbase"],
15+
["category", "Eq", "docs"]
16+
]]
17+
},
18+
],
19+
query: "What are pipes in Langbase Docs?",
20+
topK: 5
21+
});
22+
23+
console.log(response);
24+
}
25+
26+
main();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dotenv/config';
2+
import {Langbase} from 'langbase';
3+
4+
const langbase = new Langbase({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await langbase.memories.retrieve({
10+
memory: [
11+
{
12+
name: "langbase-docs",
13+
filters: ["company", "Eq", "Langbase"],
14+
},
15+
],
16+
query: "What is Langbase?",
17+
topK: 5
18+
});
19+
20+
console.log(response);
21+
}
22+
23+
main();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dotenv/config';
2+
import {Langbase} from 'langbase';
3+
4+
const langbase = new Langbase({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await langbase.memories.retrieve({
10+
memory: [
11+
{
12+
name: "langbase-docs",
13+
filters: ["company", "In", ["Langbase","Google"]],
14+
},
15+
],
16+
query: "What are pipes in Langbase?",
17+
topK: 5
18+
});
19+
20+
console.log(response);
21+
}
22+
23+
main();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dotenv/config';
2+
import {Langbase} from 'langbase';
3+
4+
const langbase = new Langbase({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await langbase.memories.retrieve({
10+
memory: [
11+
{
12+
name: "langbase-docs",
13+
filters: ["company", "NotEq", "Google"],
14+
},
15+
],
16+
query: "What is Langbase?",
17+
topK: 5
18+
});
19+
20+
console.log(response);
21+
}
22+
23+
main();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dotenv/config';
2+
import {Langbase} from 'langbase';
3+
4+
const langbase = new Langbase({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await langbase.memories.retrieve({
10+
memory: [
11+
{
12+
name: "langbase-docs",
13+
filters: ["company", "NotIn", "Google"],
14+
},
15+
],
16+
query: "What are pipes in Langbase?",
17+
topK: 5
18+
});
19+
20+
console.log(response);
21+
}
22+
23+
main();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'dotenv/config';
2+
import {Langbase} from 'langbase';
3+
4+
const langbase = new Langbase({
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
});
7+
8+
async function main() {
9+
const response = await langbase.memories.retrieve({
10+
memory: [
11+
{
12+
name: "langbase-docs",
13+
filters: ["And", [
14+
["company", "Eq", "Langbase"],
15+
["Or", [
16+
["category", "Eq", "docs"],
17+
["category", "Eq", "examples"]
18+
]],
19+
["primative", "In", ["Chunk", "Threads"]]
20+
]]
21+
}
22+
],
23+
query: "What are primitives in Langbase?",
24+
topK: 5
25+
});
26+
27+
console.log(response);
28+
}
29+
30+
main();

0 commit comments

Comments
 (0)