File tree Expand file tree Collapse file tree 4 files changed +100
-7
lines changed
Expand file tree Collapse file tree 4 files changed +100
-7
lines changed Original file line number Diff line number Diff line change 1+ import aiTextraction from "../../ai_textraction.app.mjs" ;
2+
3+ export default {
4+ key : "ai_textraction-extract-data" ,
5+ name : "Extract Data" ,
6+ description : "Extract custom data from text using AI Textraction. [See the documentation](https://rapidapi.com/textractionai/api/ai-textraction)" ,
7+ version : "0.0.1" ,
8+ type : "action" ,
9+ props : {
10+ aiTextraction,
11+ text : {
12+ type : "string" ,
13+ label : "Text" ,
14+ description : "The text to extract entities from" ,
15+ } ,
16+ entities : {
17+ type : "string[]" ,
18+ label : "Entities" ,
19+ description : "An array of entity names to extract from the text. Example: `first_name`" ,
20+ reloadProps : true ,
21+ } ,
22+ } ,
23+ async additionalProps ( ) {
24+ const props = { } ;
25+ if ( ! this . entities ?. length ) {
26+ return props ;
27+ }
28+ for ( const entity of this . entities ) {
29+ props [ `${ entity } _type` ] = {
30+ type : "string" ,
31+ label : `${ entity } - Type` ,
32+ description : `The type of results to return for ${ entity } ` ,
33+ options : [
34+ "string" ,
35+ "integer" ,
36+ "array[string]" ,
37+ "array[integer]" ,
38+ ] ,
39+ } ;
40+ props [ `${ entity } _description` ] = {
41+ type : "string" ,
42+ label : `${ entity } - Description` ,
43+ description : `Description of the entity ${ entity } . Example: \`First name of the person\`` ,
44+ } ;
45+ }
46+ return props ;
47+ } ,
48+ async run ( { $ } ) {
49+ const entities = this . entities . map ( ( entity ) => ( {
50+ var_name : entity ,
51+ type : this [ `${ entity } _type` ] ,
52+ description : this [ `${ entity } _description` ] ,
53+ } ) ) ;
54+
55+ const response = await this . aiTextraction . extractData ( {
56+ $,
57+ data : {
58+ text : this . text ,
59+ entities,
60+ } ,
61+ } ) ;
62+
63+ $ . export ( "$summary" , "Successfully extracted data from text" ) ;
64+ return response ;
65+ } ,
66+ } ;
Original file line number Diff line number Diff line change 1+ import { axios } from "@pipedream/platform" ;
2+
13export default {
24 type : "app" ,
35 app : "ai_textraction" ,
4- propDefinitions : { } ,
56 methods : {
6- // this.$auth contains connected account data
7- authKeys ( ) {
8- console . log ( Object . keys ( this . $auth ) ) ;
7+ _baseUrl ( ) {
8+ return "https://ai-textraction.p.rapidapi.com" ;
9+ } ,
10+ _makeRequest ( {
11+ $ = this ,
12+ path,
13+ ...opts
14+ } ) {
15+ return axios ( $ , {
16+ url : `${ this . _baseUrl ( ) } ${ path } ` ,
17+ headers : {
18+ "x-rapidapi-host" : "ai-textraction.p.rapidapi.com" ,
19+ "x-rapidapi-key" : `${ this . $auth . rapid_key } ` ,
20+ } ,
21+ ...opts ,
22+ } ) ;
23+ } ,
24+ extractData ( opts = { } ) {
25+ return this . _makeRequest ( {
26+ method : "POST" ,
27+ path : "/textraction" ,
28+ ...opts ,
29+ } ) ;
930 } ,
1031 } ,
1132} ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/ai_textraction" ,
3- "version" : " 0.0.1 " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " Pipedream AI Textraction Components" ,
55 "main" : " ai_textraction.app.mjs" ,
66 "keywords" : [
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+ }
You can’t perform that action at this time.
0 commit comments