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
66 changes: 66 additions & 0 deletions components/ai_textraction/actions/extract-data/extract-data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import aiTextraction from "../../ai_textraction.app.mjs";

export default {
key: "ai_textraction-extract-data",
name: "Extract Data",
description: "Extract custom data from text using AI Textraction. [See the documentation](https://rapidapi.com/textractionai/api/ai-textraction)",
version: "0.0.1",
type: "action",
props: {
aiTextraction,
text: {
type: "string",
label: "Text",
description: "The text to extract entities from",
},
entities: {
type: "string[]",
label: "Entities",
description: "An array of entity names to extract from the text. Example: `first_name`",
reloadProps: true,
},
},
async additionalProps() {
const props = {};
if (!this.entities?.length) {
return props;
}
for (const entity of this.entities) {
props[`${entity}_type`] = {
type: "string",
label: `${entity} - Type`,
description: `The type of results to return for ${entity}`,
options: [
"string",
"integer",
"array[string]",
"array[integer]",
],
};
props[`${entity}_description`] = {
type: "string",
label: `${entity} - Description`,
description: `Description of the entity ${entity}. Example: \`First name of the person\``,
};
}
return props;
},
async run({ $ }) {
const entities = this.entities.map((entity) => ({
var_name: entity,
type: this[`${entity}_type`],
description: this[`${entity}_description`],
}));

const response = await this.aiTextraction.extractData({
$,
data: {
text: this.text,
entities,
},
});

$.export("$summary", "Successfully extracted data from text");
return response;
},
};
31 changes: 26 additions & 5 deletions components/ai_textraction/ai_textraction.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "ai_textraction",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://ai-textraction.p.rapidapi.com";
},
_makeRequest({
$ = this,
path,
...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
"x-rapidapi-host": "ai-textraction.p.rapidapi.com",
"x-rapidapi-key": `${this.$auth.rapid_key}`,
},
...opts,
});
},
extractData(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/textraction",
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/ai_textraction/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ai_textraction",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream AI Textraction Components",
"main": "ai_textraction.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"
}
}
}
107 changes: 55 additions & 52 deletions pnpm-lock.yaml

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

Loading