File tree Expand file tree Collapse file tree 7 files changed +14
-9
lines changed
packages/components/nodes/tools Expand file tree Collapse file tree 7 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import $RefParser from '@apidevtools/json-schema-ref-parser'
5
5
import { z , ZodSchema , ZodTypeAny } from 'zod'
6
6
import { defaultCode , DynamicStructuredTool , howToUseCode } from './core'
7
7
import { DataSource } from 'typeorm'
8
+ import { getBaseClasses , getVars , stripHTMLFromToolInput } from '../../../src/utils'
8
9
9
10
class OpenAPIToolkit_Tools implements INode {
10
11
label : string
@@ -80,7 +81,7 @@ class OpenAPIToolkit_Tools implements INode {
80
81
const _headers = nodeData . inputs ?. headers as string
81
82
const removeNulls = nodeData . inputs ?. removeNulls as boolean
82
83
83
- const headers = typeof _headers === 'object' ? _headers : _headers ? JSON . parse ( _headers ) : { }
84
+ const headers = typeof _headers === 'object' ? _headers : _headers ? JSON . parse ( stripHTMLFromToolInput ( _headers ) ) : { }
84
85
85
86
let data
86
87
if ( yamlFileBase64 . startsWith ( 'FILE-STORAGE::' ) ) {
Original file line number Diff line number Diff line change 1
1
import { z } from 'zod'
2
2
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
3
3
import { secureFetch } from '../../../src/httpSecurity'
4
+ import { stripHTMLFromToolInput } from '../../../src/utils'
4
5
5
6
export const desc = `Use this when you need to execute a DELETE request to remove data from a website.`
6
7
@@ -22,7 +23,7 @@ const createRequestsDeleteSchema = (queryParamsSchema?: string) => {
22
23
// If queryParamsSchema is provided, parse it and add dynamic query params
23
24
if ( queryParamsSchema ) {
24
25
try {
25
- const parsedSchema = JSON . parse ( queryParamsSchema )
26
+ const parsedSchema = JSON . parse ( stripHTMLFromToolInput ( queryParamsSchema ) )
26
27
const queryParamsObject : Record < string , z . ZodTypeAny > = { }
27
28
28
29
Object . entries ( parsedSchema ) . forEach ( ( [ key , config ] : [ string , any ] ) => {
@@ -108,7 +109,7 @@ export class RequestsDeleteTool extends DynamicStructuredTool {
108
109
109
110
if ( this . queryParamsSchema && params . queryParams && Object . keys ( params . queryParams ) . length > 0 ) {
110
111
try {
111
- const parsedSchema = JSON . parse ( this . queryParamsSchema )
112
+ const parsedSchema = JSON . parse ( stripHTMLFromToolInput ( this . queryParamsSchema ) )
112
113
const pathParams : Array < { key : string ; value : string } > = [ ]
113
114
114
115
Object . entries ( params . queryParams ) . forEach ( ( [ key , value ] ) => {
Original file line number Diff line number Diff line change 1
1
import { z } from 'zod'
2
2
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
3
3
import { secureFetch } from '../../../src/httpSecurity'
4
+ import { stripHTMLFromToolInput } from '../../../src/utils'
4
5
5
6
export const desc = `Use this when you need to execute a GET request to get data from a website.`
6
7
@@ -22,7 +23,7 @@ const createRequestsGetSchema = (queryParamsSchema?: string) => {
22
23
// If queryParamsSchema is provided, parse it and add dynamic query params
23
24
if ( queryParamsSchema ) {
24
25
try {
25
- const parsedSchema = JSON . parse ( queryParamsSchema )
26
+ const parsedSchema = JSON . parse ( stripHTMLFromToolInput ( queryParamsSchema ) )
26
27
const queryParamsObject : Record < string , z . ZodTypeAny > = { }
27
28
28
29
Object . entries ( parsedSchema ) . forEach ( ( [ key , config ] : [ string , any ] ) => {
@@ -108,7 +109,7 @@ export class RequestsGetTool extends DynamicStructuredTool {
108
109
109
110
if ( this . queryParamsSchema && params . queryParams && Object . keys ( params . queryParams ) . length > 0 ) {
110
111
try {
111
- const parsedSchema = JSON . parse ( this . queryParamsSchema )
112
+ const parsedSchema = JSON . parse ( stripHTMLFromToolInput ( this . queryParamsSchema ) )
112
113
const pathParams : Array < { key : string ; value : string } > = [ ]
113
114
114
115
Object . entries ( params . queryParams ) . forEach ( ( [ key , value ] ) => {
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ class RequestsPost_Tools implements INode {
144
144
obj . headers = parsedHeaders
145
145
}
146
146
if ( body ) {
147
- const parsedBody = typeof body === 'object' ? body : JSON . parse ( body )
147
+ const parsedBody = typeof body === 'object' ? body : JSON . parse ( stripHTMLFromToolInput ( body ) )
148
148
obj . body = parsedBody
149
149
}
150
150
Original file line number Diff line number Diff line change 1
1
import { z } from 'zod'
2
2
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
3
3
import { secureFetch } from '../../../src/httpSecurity'
4
+ import { stripHTMLFromToolInput } from '../../../src/utils'
4
5
5
6
export const desc = `Use this when you want to execute a POST request to create or update a resource.`
6
7
@@ -27,7 +28,7 @@ const createRequestsPostSchema = (bodySchema?: string) => {
27
28
// If bodySchema is provided, parse it and add dynamic body params
28
29
if ( bodySchema ) {
29
30
try {
30
- const parsedSchema = JSON . parse ( bodySchema )
31
+ const parsedSchema = JSON . parse ( stripHTMLFromToolInput ( bodySchema ) )
31
32
const bodyParamsObject : Record < string , z . ZodTypeAny > = { }
32
33
33
34
Object . entries ( parsedSchema ) . forEach ( ( [ key , config ] : [ string , any ] ) => {
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ class RequestsPut_Tools implements INode {
144
144
obj . headers = parsedHeaders
145
145
}
146
146
if ( body ) {
147
- const parsedBody = typeof body === 'object' ? body : JSON . parse ( body )
147
+ const parsedBody = typeof body === 'object' ? body : JSON . parse ( stripHTMLFromToolInput ( body ) )
148
148
obj . body = parsedBody
149
149
}
150
150
Original file line number Diff line number Diff line change 1
1
import { z } from 'zod'
2
2
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
3
3
import { secureFetch } from '../../../src/httpSecurity'
4
+ import { stripHTMLFromToolInput } from '../../../src/utils'
4
5
5
6
export const desc = `Use this when you want to execute a PUT request to update or replace a resource.`
6
7
@@ -27,7 +28,7 @@ const createRequestsPutSchema = (bodySchema?: string) => {
27
28
// If bodySchema is provided, parse it and add dynamic body params
28
29
if ( bodySchema ) {
29
30
try {
30
- const parsedSchema = JSON . parse ( bodySchema )
31
+ const parsedSchema = JSON . parse ( stripHTMLFromToolInput ( bodySchema ) )
31
32
const bodyParamsObject : Record < string , z . ZodTypeAny > = { }
32
33
33
34
Object . entries ( parsedSchema ) . forEach ( ( [ key , config ] : [ string , any ] ) => {
You can’t perform that action at this time.
0 commit comments