diff --git a/components/langbase/actions/create-memory/create-memory.mjs b/components/langbase/actions/create-memory/create-memory.mjs new file mode 100644 index 0000000000000..5cf0ca5365b64 --- /dev/null +++ b/components/langbase/actions/create-memory/create-memory.mjs @@ -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; + }, +}; diff --git a/components/langbase/actions/delete-memory/delete-memory.mjs b/components/langbase/actions/delete-memory/delete-memory.mjs new file mode 100644 index 0000000000000..cba327837a7db --- /dev/null +++ b/components/langbase/actions/delete-memory/delete-memory.mjs @@ -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; + }, +}; diff --git a/components/langbase/actions/list-memories/list-memories.mjs b/components/langbase/actions/list-memories/list-memories.mjs new file mode 100644 index 0000000000000..fc47e02888c14 --- /dev/null +++ b/components/langbase/actions/list-memories/list-memories.mjs @@ -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; + }, +}; diff --git a/components/langbase/langbase.app.mjs b/components/langbase/langbase.app.mjs index 4a66c23d22182..24547f9faf43e 100644 --- a/components/langbase/langbase.app.mjs +++ b/components/langbase/langbase.app.mjs @@ -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, + }); }, }, }; diff --git a/components/langbase/package.json b/components/langbase/package.json index 879d82fe8225e..91c547399b30e 100644 --- a/components/langbase/package.json +++ b/components/langbase/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/langbase", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Langbase Components", "main": "langbase.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d4595a5cce24..b0d4136947893 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1239,8 +1239,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/boldsign: - specifiers: {} + components/boldsign: {} components/boloforms: dependencies: @@ -5575,7 +5574,11 @@ importers: components/lambdatest: {} - components/langbase: {} + components/langbase: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/laposta: dependencies: @@ -24510,22 +24513,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==}