From d3f96db3c2acd91788b0626325364ffbc7755a6d Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Thu, 23 Jan 2025 16:54:09 +0100 Subject: [PATCH 1/8] add linkup actions --- components/linkup/actions/answer/answer.mjs | 40 +++++++++++ components/linkup/actions/search/search.mjs | 75 +-------------------- components/linkup/linkup.app.mjs | 4 ++ 3 files changed, 46 insertions(+), 73 deletions(-) create mode 100644 components/linkup/actions/answer/answer.mjs diff --git a/components/linkup/actions/answer/answer.mjs b/components/linkup/actions/answer/answer.mjs new file mode 100644 index 0000000000000..37b2998d00db9 --- /dev/null +++ b/components/linkup/actions/answer/answer.mjs @@ -0,0 +1,40 @@ +import app from "../../linkup.app.mjs"; + +export default { + name: "Linkup Answer", + description: "Get a natural language answer to your natural language question.", + key: "linkup-search", + version: "0.0.1", + type: "action", + props: { + app, + query: { + type: "string", + label: "Query", + description: "The search query for Linkup.", + }, + depth: { + type: "string", + label: "Search Depth", + description: "Defines the precision of the search. `standard` returns results quickly; `deep` takes longer but yields more complete results.", + options: [ + "standard", + "deep", + ], + }, + }, + async run({ $ }) { + try { + const response = await this.app.search({ + query: this.query, + depth: this.depth, + outputType: "sourcedAnswer", + }); + $.export("$summary", "Successfully completed search query"); + return response; + } catch (error) { + console.error("Error calling Linkup API:", error); + throw new Error(`Failed to fetch data from Linkup API: ${error.message}`); + } + }, +}; diff --git a/components/linkup/actions/search/search.mjs b/components/linkup/actions/search/search.mjs index 1c57ef0288954..dd221ce7e87ef 100644 --- a/components/linkup/actions/search/search.mjs +++ b/components/linkup/actions/search/search.mjs @@ -2,7 +2,7 @@ import app from "../../linkup.app.mjs"; export default { name: "Linkup Search", - description: "Search and retrieve insights using the Linkup API. [See the documentation](https://docs.linkup.so/pages/api-reference/endpoint/post-search)", + description: "Retrieve a list of objects relevant to a natural language search query.", key: "linkup-search", version: "0.0.1", type: "action", @@ -22,84 +22,13 @@ export default { "deep", ], }, - outputType: { - type: "string", - label: "Output Type", - description: "The type of output you want to get. Use `structured` for a custom-formatted response defined by `structuredOutputSchema`", - options: [ - { - value: "sourcedAnswer", - label: "Natural language answer and its sources", - }, - { - value: "searchResults", - label: "Raw context", - }, - { - value: "structured", - label: "Json format of the response", - }, - ], - reloadProps: true, - }, - structuredOutputSchema: { - type: "string", - label: "Structured Output Schema", - description: "Schema for structured output (only applicable if Output Type is 'structured'). Provide a JSON schema (as a string) representing the desired response format.", - optional: true, - hidden: true, - }, - includeImages: { - type: "boolean", - label: "Include Images", - description: "Defines whether the API should include images in its results", - optional: true, - }, - }, - additionalProps(props) { - if (this.outputType === "structured") { - props.structuredOutputSchema.optional = false; - props.structuredOutputSchema.hidden = false; - props.structuredOutputSchema.default = `{ - "type": "object", - "properties": { - "results": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "year": { - "type": "number" - } - }, - "required": [ - "name", - "year" - ], - "additionalProperties": false - } - } - }, - "required": [ - "results" - ], - "additionalProperties": false - }`; - } - return {}; }, async run({ $ }) { try { const response = await this.app.search({ query: this.query, depth: this.depth, - outputType: this.outputType, - structuredOutputSchema: - this.structuredOutputSchema && JSON.parse(this.structuredOutputSchema), - includeImages: this.includeImages, + outputType: "searchResults", }); $.export("$summary", "Successfully completed search query"); return response; diff --git a/components/linkup/linkup.app.mjs b/components/linkup/linkup.app.mjs index 5b009adf0f11f..dc99df419e9de 100644 --- a/components/linkup/linkup.app.mjs +++ b/components/linkup/linkup.app.mjs @@ -14,5 +14,9 @@ export default { const client = this._getClient(); return client.search(params); }, + answer(params) { + const client = this._getClient(); + return client.search(params); + }, }, }; From 357f77e408150eabe2936d6c096aa176372993dc Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Thu, 23 Jan 2025 17:01:42 +0100 Subject: [PATCH 2/8] rename key linkup answer --- components/linkup/actions/answer/answer.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/linkup/actions/answer/answer.mjs b/components/linkup/actions/answer/answer.mjs index 37b2998d00db9..dbddae56980a8 100644 --- a/components/linkup/actions/answer/answer.mjs +++ b/components/linkup/actions/answer/answer.mjs @@ -3,7 +3,7 @@ import app from "../../linkup.app.mjs"; export default { name: "Linkup Answer", description: "Get a natural language answer to your natural language question.", - key: "linkup-search", + key: "linkup-answer", version: "0.0.1", type: "action", props: { From 5b69e26a11cf5c07b5122119eefbcc0e2264c380 Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Thu, 23 Jan 2025 17:08:10 +0100 Subject: [PATCH 3/8] delete unused method --- components/linkup/linkup.app.mjs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/linkup/linkup.app.mjs b/components/linkup/linkup.app.mjs index dc99df419e9de..5b009adf0f11f 100644 --- a/components/linkup/linkup.app.mjs +++ b/components/linkup/linkup.app.mjs @@ -14,9 +14,5 @@ export default { const client = this._getClient(); return client.search(params); }, - answer(params) { - const client = this._getClient(); - return client.search(params); - }, }, }; From 71f7579f09a7ba965ea85ae99205ef6ce80215f9 Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Thu, 23 Jan 2025 17:16:21 +0100 Subject: [PATCH 4/8] change version --- components/linkup/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/linkup/package.json b/components/linkup/package.json index 52e05175f933a..b1488359616f0 100644 --- a/components/linkup/package.json +++ b/components/linkup/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/linkup", - "version": "0.1.0", + "version": "0.1.1", "description": "Pipedream Linkup Components", "main": "linkup.app.mjs", "keywords": [ From 9e10a7bbcde125e6a2ce327ad2d79df47085dd4a Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Thu, 23 Jan 2025 17:18:45 +0100 Subject: [PATCH 5/8] change version --- components/linkup/actions/search/search.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/linkup/actions/search/search.mjs b/components/linkup/actions/search/search.mjs index dd221ce7e87ef..8beeb9472467d 100644 --- a/components/linkup/actions/search/search.mjs +++ b/components/linkup/actions/search/search.mjs @@ -4,7 +4,7 @@ export default { name: "Linkup Search", description: "Retrieve a list of objects relevant to a natural language search query.", key: "linkup-search", - version: "0.0.1", + version: "0.1.1", type: "action", props: { app, From 24fc30adc3d9f9fa1d45aea79ac041a7179fc00a Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Mon, 27 Jan 2025 10:15:21 +0100 Subject: [PATCH 6/8] add versions --- components/linkup/actions/sourced/sourced.mjs | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 components/linkup/actions/sourced/sourced.mjs diff --git a/components/linkup/actions/sourced/sourced.mjs b/components/linkup/actions/sourced/sourced.mjs new file mode 100644 index 0000000000000..e860595237412 --- /dev/null +++ b/components/linkup/actions/sourced/sourced.mjs @@ -0,0 +1,78 @@ +import app from "../../linkup.app.mjs"; + +export default { + name: "Linkup Search", + description: "Search and retrieve insights using the Linkup API. [See the documentation](https://docs.linkup.so/pages/api-reference/endpoint/post-search)", + key: "linkup-search", + version: "0.1.1", + type: "action", + props: { + app, + query: { + type: "string", + label: "Query", + description: "The search query for Linkup.", + }, + depth: { + type: "string", + label: "Search Depth", + description: "Defines the precision of the search. `standard` returns results quickly; `deep` takes longer but yields more complete results.", + options: [ + "standard", + "deep", + ], + }, + }, + additionalProps(props) { + if (this.outputType === "structured") { + props.structuredOutputSchema.optional = false; + props.structuredOutputSchema.hidden = false; + props.structuredOutputSchema.default = `{ + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "year": { + "type": "number" + } + }, + "required": [ + "name", + "year" + ], + "additionalProperties": false + } + } + }, + "required": [ + "results" + ], + "additionalProperties": false + }`; + } + return {}; + }, + async run({ $ }) { + try { + const response = await this.app.search({ + query: this.query, + depth: this.depth, + outputType: this.outputType, + structuredOutputSchema: + this.structuredOutputSchema && JSON.parse(this.structuredOutputSchema), + includeImages: this.includeImages, + }); + $.export("$summary", "Successfully completed search query"); + return response; + } catch (error) { + console.error("Error calling Linkup API:", error); + throw new Error(`Failed to fetch data from Linkup API: ${error.message}`); + } + }, +}; From 514639b1871249f4a963b497d30ad68e6264a083 Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Mon, 27 Jan 2025 10:22:24 +0100 Subject: [PATCH 7/8] rename name in file --- components/linkup/actions/sourced/sourced.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/linkup/actions/sourced/sourced.mjs b/components/linkup/actions/sourced/sourced.mjs index e860595237412..022ee3f55f672 100644 --- a/components/linkup/actions/sourced/sourced.mjs +++ b/components/linkup/actions/sourced/sourced.mjs @@ -1,9 +1,9 @@ import app from "../../linkup.app.mjs"; export default { - name: "Linkup Search", - description: "Search and retrieve insights using the Linkup API. [See the documentation](https://docs.linkup.so/pages/api-reference/endpoint/post-search)", - key: "linkup-search", + name: "Linkup Sourced", + description: "Get a natural language answer to your natural language question", + key: "linkup-sourced", version: "0.1.1", type: "action", props: { From 452a0f151b51cb66c8491a2e599875d0398d8bfd Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Mon, 27 Jan 2025 10:24:36 +0100 Subject: [PATCH 8/8] erase structured --- components/linkup/actions/sourced/sourced.mjs | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/components/linkup/actions/sourced/sourced.mjs b/components/linkup/actions/sourced/sourced.mjs index 022ee3f55f672..37811faf2e8f7 100644 --- a/components/linkup/actions/sourced/sourced.mjs +++ b/components/linkup/actions/sourced/sourced.mjs @@ -23,50 +23,12 @@ export default { ], }, }, - additionalProps(props) { - if (this.outputType === "structured") { - props.structuredOutputSchema.optional = false; - props.structuredOutputSchema.hidden = false; - props.structuredOutputSchema.default = `{ - "type": "object", - "properties": { - "results": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "year": { - "type": "number" - } - }, - "required": [ - "name", - "year" - ], - "additionalProperties": false - } - } - }, - "required": [ - "results" - ], - "additionalProperties": false - }`; - } - return {}; - }, async run({ $ }) { try { const response = await this.app.search({ query: this.query, depth: this.depth, - outputType: this.outputType, - structuredOutputSchema: - this.structuredOutputSchema && JSON.parse(this.structuredOutputSchema), - includeImages: this.includeImages, + outputType: "sourcedAnswer", }); $.export("$summary", "Successfully completed search query"); return response;