Skip to content

Commit 1006518

Browse files
authored
New Components - langbase (#14980)
* langbase components * pnpm-lock.yaml
1 parent 8b500b6 commit 1006518

File tree

6 files changed

+173
-11
lines changed

6 files changed

+173
-11
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import app from "../../langbase.app.mjs";
2+
3+
export default {
4+
key: "langbase-create-memory",
5+
name: "Create Memory",
6+
description: "Create a new organization memory by sending the memory data. [See the documentation](https://langbase.com/docs/api-reference/memory/create)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
propDefinition: [
13+
app,
14+
"name",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
},
24+
25+
async run({ $ }) {
26+
const response = await this.app.createMemory({
27+
$,
28+
data: {
29+
name: this.name,
30+
description: this.description,
31+
},
32+
});
33+
34+
$.export("$summary", `Successfully created memory ${this.name}`);
35+
36+
return response;
37+
},
38+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../langbase.app.mjs";
2+
3+
export default {
4+
key: "langbase-delete-memory",
5+
name: "Delete Memory",
6+
description: "Delete an existing memory on Langbase. [See the documentation](https://langbase.com/docs/api-reference/memory/delete)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
memoryName: {
12+
propDefinition: [
13+
app,
14+
"memoryName",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.deleteMemory({
21+
$,
22+
memoryName: this.memoryName,
23+
});
24+
25+
$.export("$summary", `Successfully deleted memory named ${this.memoryName}`);
26+
27+
return response;
28+
},
29+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../langbase.app.mjs";
2+
3+
export default {
4+
key: "langbase-list-memories",
5+
name: "List Memories",
6+
description: "Get a list of memory sets on Langbase. [See the documentation](https://langbase.com/docs/api-reference/memory/list)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
13+
async run({ $ }) {
14+
const response = await this.app.listMemories({
15+
$,
16+
});
17+
18+
$.export("$summary", `Successfully retrieved ${response.memorySets.length} memorysets`);
19+
20+
return response;
21+
},
22+
};
Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "langbase",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
memoryName: {
8+
type: "string",
9+
label: "Memory Name",
10+
description: "The name of the memory",
11+
async options() {
12+
const response = await this.listMemories();
13+
const memoryNames = response.memorySets;
14+
return memoryNames.map(({
15+
name, description,
16+
}) => ({
17+
label: description,
18+
value: name,
19+
}));
20+
},
21+
},
22+
name: {
23+
type: "string",
24+
label: "Name",
25+
description: "Name of the memory",
26+
},
27+
description: {
28+
type: "string",
29+
label: "Description",
30+
description: "Short description of the memory",
31+
},
32+
},
533
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
34+
_baseUrl() {
35+
return "https://api.langbase.com/beta";
36+
},
37+
async _makeRequest(opts = {}) {
38+
const {
39+
$ = this,
40+
path,
41+
headers,
42+
...otherOpts
43+
} = opts;
44+
return axios($, {
45+
...otherOpts,
46+
url: this._baseUrl() + path,
47+
headers: {
48+
...headers,
49+
"Authorization": `Bearer ${this.$auth.org_api_key}`,
50+
"Accept": "application/json",
51+
},
52+
});
53+
},
54+
async createMemory(args = {}) {
55+
return this._makeRequest({
56+
path: `/org/${this.$auth.org}/memorysets`,
57+
method: "post",
58+
...args,
59+
});
60+
},
61+
async deleteMemory({
62+
memoryName, ...args
63+
}) {
64+
return this._makeRequest({
65+
path: `/memorysets/${this.$auth.org}/${memoryName}`,
66+
method: "delete",
67+
...args,
68+
});
69+
},
70+
async listMemories(args = {}) {
71+
return this._makeRequest({
72+
path: `/org/${this.$auth.org}/memorysets`,
73+
...args,
74+
});
975
},
1076
},
1177
};

components/langbase/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/langbase",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Langbase Components",
55
"main": "langbase.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)