To use a method from an npm package like @pipedream/rss in a Node.js component, you can import the method and then use it in your code. However, I couldn’t find a specific “listItems” method in the @pipedream/rss package. If you could provide more information about the method or the package, I’d be happy to help you with an example. In the meantime, here’s a general example of how to import a method from an npm package and use it in a Pipedream component: import { someMethod } from "some-package"; export default { async run() { const result = await someMethod(); console.log(result); }, };
Replace someMethod
with the actual method you want to use, and some-package
with the correct package name.
Can users create custom apps? This is effectively be what I was looking for
e.g. import {gpt} from "@pipedream/henrikskog"
Not today, but soon! If you want us to add a new integrations, we can always do that, but there’s not a concept of private apps today. Leo’s suggestion to create your own npm package to distribute code is the best way to do what you’d like here.
Okay, thanks for the help! Is this documented? I might have missed it, but if not I think it would be of great use as its pretty common to want something like this I think. Loving the product so far though!
It was, trying to find it now though… it may have been errantly removed in one of our prior updates
I put it on the docs backlog
Nice:+1::skin-tone-2:
I’m trying to use the methods exposed in the app file for the openai component, but I’m a bit confused. @pipedream/openai
simply returns the whole object defined in the components/openai/app/openai.app.mjs
file. Was this what you were referring to ?
**import** all **from** "@pipedream/openai"
// To use previous step data, pass the steps object to the run() function
export
**default** defineComponent({
**async** run({ steps, $ }) {
// Return data to use it in future steps
_const models =_ **await a**ll.methods.getChatCompletionModels()
console.log(models)
**return** steps.trigger.event
},
})
apologies, Mario didn’t return an accurate response now that I look at it. I’ll also add these docs so it knows how to work with components. Try this:
import openai from "@pipedream/openai"
// To use previous step data, pass the steps object to the run() function
export default defineComponent({
props: {
openai,
},
async run({ steps, $ }) {
// Return data to use it in future steps
const models = await this.openai.getChatCompletionModels()
console.log(models)
return steps.trigger.event
},
})
The openai
export is an object of type app
, so we can pass it to props
directly as a standard app prop. Then this.openai
should expose the methods directly
Aha I see, thanks!