Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions components/langbase/actions/create-memory/create-memory.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../langbase.app.mjs";

export default {
key: "langbase-create-memory",
name: "Create Memory",
description: "Create a new organization memory by sending the memory data. [See the documentation](https://langbase.com/docs/api-reference/memory/create)",
version: "0.0.1",
type: "action",
props: {
app,
name: {
propDefinition: [
app,
"name",
],
},
description: {
propDefinition: [
app,
"description",
],
},
},

async run({ $ }) {
const response = await this.app.createMemory({
$,
data: {
name: this.name,
description: this.description,
},
});

$.export("$summary", `Successfully created memory ${this.name}`);

return response;
},
};
29 changes: 29 additions & 0 deletions components/langbase/actions/delete-memory/delete-memory.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import app from "../../langbase.app.mjs";

export default {
key: "langbase-delete-memory",
name: "Delete Memory",
description: "Delete an existing memory on Langbase. [See the documentation](https://langbase.com/docs/api-reference/memory/delete)",
version: "0.0.1",
type: "action",
props: {
app,
memoryName: {
propDefinition: [
app,
"memoryName",
],
},
},

async run({ $ }) {
const response = await this.app.deleteMemory({
$,
memoryName: this.memoryName,
});

$.export("$summary", `Successfully deleted memory named ${this.memoryName}`);

return response;
},
};
22 changes: 22 additions & 0 deletions components/langbase/actions/list-memories/list-memories.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import app from "../../langbase.app.mjs";

export default {
key: "langbase-list-memories",
name: "List Memories",
description: "Get a list of memory sets on Langbase. [See the documentation](https://langbase.com/docs/api-reference/memory/list)",
version: "0.0.1",
type: "action",
props: {
app,
},

async run({ $ }) {
const response = await this.app.listMemories({
$,
});

$.export("$summary", `Successfully retrieved ${response.memorySets.length} memorysets`);

return response;
},
};
74 changes: 70 additions & 4 deletions components/langbase/langbase.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "langbase",
propDefinitions: {},
propDefinitions: {
memoryName: {
type: "string",
label: "Memory Name",
description: "The name of the memory",
async options() {
const response = await this.listMemories();
const memoryNames = response.memorySets;
return memoryNames.map(({
name, description,
}) => ({
label: description,
value: name,
}));
},
},
name: {
type: "string",
label: "Name",
description: "Name of the memory",
},
description: {
type: "string",
label: "Description",
description: "Short description of the memory",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.langbase.com/beta";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"Authorization": `Bearer ${this.$auth.org_api_key}`,
"Accept": "application/json",
},
});
},
async createMemory(args = {}) {
return this._makeRequest({
path: `/org/${this.$auth.org}/memorysets`,
method: "post",
...args,
});
},
async deleteMemory({
memoryName, ...args
}) {
return this._makeRequest({
path: `/memorysets/${this.$auth.org}/${memoryName}`,
method: "delete",
...args,
});
},
async listMemories(args = {}) {
return this._makeRequest({
path: `/org/${this.$auth.org}/memorysets`,
...args,
});
},
},
};
7 changes: 5 additions & 2 deletions components/langbase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/langbase",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Langbase Components",
"main": "langbase.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
17 changes: 10 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading