Skip to content

Commit 8e5292d

Browse files
committed
add linkup actions
1 parent 2c1ae19 commit 8e5292d

File tree

3 files changed

+46
-73
lines changed

3 files changed

+46
-73
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import app from "../../linkup.app.mjs";
2+
3+
export default {
4+
name: "Linkup Answer",
5+
description: "Get a natural language answer to your natural language question.",
6+
key: "linkup-search",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
query: {
12+
type: "string",
13+
label: "Query",
14+
description: "The search query for Linkup.",
15+
},
16+
depth: {
17+
type: "string",
18+
label: "Search Depth",
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+
],
24+
},
25+
},
26+
async run({ $ }) {
27+
try {
28+
const response = await this.app.search({
29+
query: this.query,
30+
depth: this.depth,
31+
outputType: "sourcedAnswer",
32+
});
33+
$.export("$summary", "Successfully completed search query");
34+
return response;
35+
} catch (error) {
36+
console.error("Error calling Linkup API:", error);
37+
throw new Error(`Failed to fetch data from Linkup API: ${error.message}`);
38+
}
39+
},
40+
};

components/linkup/actions/search/search.mjs

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import app from "../../linkup.app.mjs";
22

33
export default {
44
name: "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)",
5+
description: "Retrieve a list of objects relevant to a natural language search query.",
66
key: "linkup-search",
77
version: "0.0.1",
88
type: "action",
@@ -22,84 +22,13 @@ export default {
2222
"deep",
2323
],
2424
},
25-
outputType: {
26-
type: "string",
27-
label: "Output Type",
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,
44-
},
45-
structuredOutputSchema: {
46-
type: "string",
47-
label: "Structured Output Schema",
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",
56-
optional: true,
57-
},
58-
},
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-
}`;
91-
}
92-
return {};
9325
},
9426
async run({ $ }) {
9527
try {
9628
const response = await this.app.search({
9729
query: this.query,
9830
depth: this.depth,
99-
outputType: this.outputType,
100-
structuredOutputSchema:
101-
this.structuredOutputSchema && JSON.parse(this.structuredOutputSchema),
102-
includeImages: this.includeImages,
31+
outputType: "searchResults",
10332
});
10433
$.export("$summary", "Successfully completed search query");
10534
return response;

components/linkup/linkup.app.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ export default {
1414
const client = this._getClient();
1515
return client.search(params);
1616
},
17+
answer(params) {
18+
const client = this._getClient();
19+
return client.search(params);
20+
},
1721
},
1822
};

0 commit comments

Comments
 (0)