Skip to content

Commit 7f97ba7

Browse files
committed
updates
1 parent 5975528 commit 7f97ba7

File tree

3 files changed

+90
-34
lines changed

3 files changed

+90
-34
lines changed

components/linkup/actions/search/search.mjs

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import { LinkupClient } from "linkup-sdk";
21
import app from "../../linkup.app.mjs";
32

43
export default {
54
name: "Linkup Search",
6-
description: "Search and retrieve insights using the Linkup API.",
7-
key: "linkup_search",
5+
description: "Search and retrieve insights using the Linkup API. [See the documentation](https://docs.linkup.so/pages/api-reference/endpoint/post-search)",
6+
key: "linkup-search",
87
version: "0.0.1",
98
type: "action",
109
props: {
11-
apiKey: {
12-
type: "string",
13-
label: "API Key",
14-
description: "Your API Key for the Linkup API.",
15-
secret: true,
16-
},
10+
app,
1711
query: {
1812
type: "string",
1913
label: "Query",
@@ -22,40 +16,92 @@ export default {
2216
depth: {
2317
type: "string",
2418
label: "Search Depth",
25-
description: "Specify the depth of the search.",
19+
description: "Defines the precision of the search. `standard` returns results quickly; `deep` takes longer but yields more complete results.",
20+
options: [
21+
"standard",
22+
"deep",
23+
],
2624
},
2725
outputType: {
2826
type: "string",
2927
label: "Output Type",
30-
description: "The format of the search results.",
28+
description: "The type of output you want to get. Use `structured` for a custom-formatted response defined by `structuredOutputSchema`",
29+
options: [
30+
{
31+
value: "sourcedAnswer",
32+
label: "Natural language answer and its sources",
33+
},
34+
{
35+
value: "searchResults",
36+
label: "Raw context",
37+
},
38+
{
39+
value: "structured",
40+
label: "Json format of the response",
41+
},
42+
],
43+
reloadProps: true,
3144
},
3245
structuredOutputSchema: {
3346
type: "string",
3447
label: "Structured Output Schema",
35-
description: "Schema for structured output (only applicable if Output Type is 'structured').",
48+
description: "Schema for structured output (only applicable if Output Type is 'structured'). Provide a JSON schema (as a string) representing the desired response format.",
49+
optional: true,
50+
hidden: true,
51+
},
52+
includeImages: {
53+
type: "boolean",
54+
label: "Include Images",
55+
description: "Defines whether the API should include images in its results",
3656
optional: true,
3757
},
3858
},
39-
async run({
40-
query, depth, outputType, structuredOutputSchema,
41-
}) {
42-
const apiKey = app.getApiKey();
43-
44-
const client = new LinkupClient({
45-
apiKey,
46-
});
47-
const params = {
48-
query: query,
49-
depth: depth,
50-
outputType: outputType,
51-
};
52-
53-
if (outputType === "structured" && structuredOutputSchema) {
54-
params.structuredOutputSchema = structuredOutputSchema;
59+
additionalProps(props) {
60+
if (this.outputType === "structured") {
61+
props.structuredOutputSchema.optional = false;
62+
props.structuredOutputSchema.hidden = false;
63+
props.structuredOutputSchema.default = `{
64+
"type": "object",
65+
"properties": {
66+
"results": {
67+
"type": "array",
68+
"items": {
69+
"type": "object",
70+
"properties": {
71+
"name": {
72+
"type": "string"
73+
},
74+
"year": {
75+
"type": "number"
76+
}
77+
},
78+
"required": [
79+
"name",
80+
"year"
81+
],
82+
"additionalProperties": false
83+
}
84+
}
85+
},
86+
"required": [
87+
"results"
88+
],
89+
"additionalProperties": false
90+
}`;
5591
}
92+
return {};
93+
},
94+
async run({ $ }) {
5695
try {
57-
const response = await client.search(params);
58-
96+
const response = await this.app.search({
97+
query: this.query,
98+
depth: this.depth,
99+
outputType: this.outputType,
100+
structuredOutputSchema:
101+
this.structuredOutputSchema && JSON.parse(this.structuredOutputSchema),
102+
includeImages: this.includeImages,
103+
});
104+
$.export("$summary", "Successfully completed search query");
59105
return response;
60106
} catch (error) {
61107
console.error("Error calling Linkup API:", error);

components/linkup/linkup.app.mjs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import { LinkupClient } from "linkup-sdk";
2+
13
export default {
24
type: "app",
35
app: "linkup",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_getClient() {
9+
return new LinkupClient({
10+
apiKey: this.$auth.api_key,
11+
});
12+
},
13+
search(params) {
14+
const client = this._getClient();
15+
return client.search(params);
916
},
1017
},
1118
};

components/linkup/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/linkup",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Linkup Components",
55
"main": "linkup.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"linkup-sdk": "^1.0.3"
1417
}
1518
}

0 commit comments

Comments
 (0)