Skip to content

Commit c658a54

Browse files
committed
[Components] Exa - new components
1 parent 6da388e commit c658a54

File tree

7 files changed

+961
-156
lines changed

7 files changed

+961
-156
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import app from "../../exa.app.mjs";
2+
3+
export default {
4+
key: "exa-answer-question",
5+
name: "Answer Question",
6+
description: "Generates LLM-powered responses to queries, informed by Exa search results with citations. Handles both factual queries requiring direct answers and open-ended questions needing detailed summaries. [See the documentation](https://docs.exa.ai/reference/answer)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
query: {
17+
label: "Question",
18+
description: "The question or query to answer",
19+
propDefinition: [
20+
app,
21+
"query",
22+
],
23+
},
24+
text: {
25+
propDefinition: [
26+
app,
27+
"text",
28+
],
29+
description: "Whether to include full text content from search results in the response",
30+
},
31+
stream: {
32+
type: "boolean",
33+
label: "Stream",
34+
description: "Enable streaming response via server-sent events (not recommended for Pipedream workflows)",
35+
optional: true,
36+
},
37+
},
38+
async run({ $ }) {
39+
const {
40+
app,
41+
query,
42+
text,
43+
stream,
44+
} = this;
45+
46+
const response = await app.answer({
47+
$,
48+
data: {
49+
query,
50+
text,
51+
stream,
52+
},
53+
});
54+
55+
$.export("$summary", "Successfully answered question.");
56+
return response;
57+
},
58+
};
Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import app from "../../exa.app.mjs";
3+
4+
export default {
5+
key: "exa-find-similar-links",
6+
name: "Find Similar Links",
7+
description: "Identifies and retrieves web pages similar to a provided URL with optional content extraction. [See the documentation](https://docs.exa.ai/reference/find-similar-links)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
app,
17+
url: {
18+
propDefinition: [
19+
app,
20+
"url",
21+
],
22+
},
23+
numResults: {
24+
propDefinition: [
25+
app,
26+
"numResults",
27+
],
28+
},
29+
includeDomains: {
30+
propDefinition: [
31+
app,
32+
"includeDomains",
33+
],
34+
},
35+
excludeDomains: {
36+
propDefinition: [
37+
app,
38+
"excludeDomains",
39+
],
40+
},
41+
startCrawlDate: {
42+
propDefinition: [
43+
app,
44+
"startCrawlDate",
45+
],
46+
},
47+
endCrawlDate: {
48+
propDefinition: [
49+
app,
50+
"endCrawlDate",
51+
],
52+
},
53+
startPublishedDate: {
54+
propDefinition: [
55+
app,
56+
"startPublishedDate",
57+
],
58+
},
59+
endPublishedDate: {
60+
propDefinition: [
61+
app,
62+
"endPublishedDate",
63+
],
64+
},
65+
includeText: {
66+
propDefinition: [
67+
app,
68+
"includeText",
69+
],
70+
},
71+
excludeText: {
72+
propDefinition: [
73+
app,
74+
"excludeText",
75+
],
76+
},
77+
context: {
78+
propDefinition: [
79+
app,
80+
"context",
81+
],
82+
},
83+
moderation: {
84+
propDefinition: [
85+
app,
86+
"moderation",
87+
],
88+
},
89+
contentsText: {
90+
label: "Contents - Text",
91+
propDefinition: [
92+
app,
93+
"text",
94+
],
95+
},
96+
contentsHighlightsNumSentences: {
97+
label: "Contents - Highlights - Number of Sentences",
98+
propDefinition: [
99+
app,
100+
"highlightsNumSentences",
101+
],
102+
},
103+
contentsHighlightsPerUrl: {
104+
label: "Contents - Highlights - Number of Snippets per URL",
105+
propDefinition: [
106+
app,
107+
"highlightsPerUrl",
108+
],
109+
},
110+
contentsHighlightsQuery: {
111+
label: "Contents - Highlights - Custom Query",
112+
propDefinition: [
113+
app,
114+
"highlightsQuery",
115+
],
116+
},
117+
contentsSummaryQuery: {
118+
label: "Contents - Summary - Custom Query",
119+
propDefinition: [
120+
app,
121+
"summaryQuery",
122+
],
123+
},
124+
contentsSummarySchema: {
125+
label: "Contents - Summary - JSON Schema",
126+
propDefinition: [
127+
app,
128+
"summarySchema",
129+
],
130+
},
131+
contentsLivecrawl: {
132+
label: "Contents - Live Crawl",
133+
propDefinition: [
134+
app,
135+
"livecrawl",
136+
],
137+
},
138+
contentsLivecrawlTimeout: {
139+
label: "Contents - Live Crawl Timeout",
140+
propDefinition: [
141+
app,
142+
"livecrawlTimeout",
143+
],
144+
},
145+
contentsSubpages: {
146+
label: "Contents - Subpages",
147+
propDefinition: [
148+
app,
149+
"subpages",
150+
],
151+
},
152+
contentsSubpageTarget: {
153+
label: "Contents - Subpage Target",
154+
propDefinition: [
155+
app,
156+
"subpageTarget",
157+
],
158+
},
159+
contentsExtrasLinks: {
160+
label: "Contents - Extras - Number of Links",
161+
propDefinition: [
162+
app,
163+
"extrasLinks",
164+
],
165+
},
166+
contentsExtrasImageLinks: {
167+
label: "Contents - Extras - Number of Image Links",
168+
propDefinition: [
169+
app,
170+
"extrasImageLinks",
171+
],
172+
},
173+
contentsContext: {
174+
label: "Contents - Context",
175+
propDefinition: [
176+
app,
177+
"context",
178+
],
179+
},
180+
},
181+
async run({ $ }) {
182+
const {
183+
app,
184+
url,
185+
numResults,
186+
includeDomains,
187+
excludeDomains,
188+
startCrawlDate,
189+
endCrawlDate,
190+
startPublishedDate,
191+
endPublishedDate,
192+
includeText,
193+
excludeText,
194+
contentsText,
195+
contentsHighlightsNumSentences,
196+
contentsHighlightsPerUrl,
197+
contentsHighlightsQuery,
198+
contentsSummaryQuery,
199+
contentsSummarySchema,
200+
contentsLivecrawl,
201+
contentsLivecrawlTimeout,
202+
contentsSubpages,
203+
contentsSubpageTarget,
204+
contentsExtrasLinks,
205+
contentsExtrasImageLinks,
206+
contentsContext,
207+
} = this;
208+
209+
const highlights = contentsHighlightsNumSentences
210+
|| contentsHighlightsPerUrl
211+
|| contentsHighlightsQuery
212+
? {
213+
numSentences: contentsHighlightsNumSentences,
214+
highlightsPerUrl: contentsHighlightsPerUrl,
215+
query: contentsHighlightsQuery,
216+
}
217+
: undefined;
218+
219+
let parsedSchema;
220+
if (contentsSummarySchema) {
221+
if (typeof contentsSummarySchema === "string") {
222+
try {
223+
parsedSchema = JSON.parse(contentsSummarySchema);
224+
} catch (error) {
225+
throw new ConfigurationError(`Invalid JSON schema format: ${error.message}. Please provide a valid JSON object.`);
226+
}
227+
} else {
228+
parsedSchema = contentsSummarySchema;
229+
}
230+
}
231+
232+
const summary = contentsSummaryQuery
233+
|| contentsSummarySchema
234+
? {
235+
query: contentsSummaryQuery,
236+
schema: parsedSchema,
237+
}
238+
: undefined;
239+
240+
const extras = contentsExtrasLinks
241+
|| contentsExtrasImageLinks
242+
? {
243+
links: contentsExtrasLinks,
244+
imageLinks: contentsExtrasImageLinks,
245+
}
246+
: undefined;
247+
248+
const response = await app.findSimilar({
249+
$,
250+
data: {
251+
url,
252+
numResults,
253+
includeDomains,
254+
excludeDomains,
255+
startCrawlDate,
256+
endCrawlDate,
257+
startPublishedDate,
258+
endPublishedDate,
259+
includeText,
260+
excludeText,
261+
...(contentsText
262+
|| contentsLivecrawl
263+
|| contentsLivecrawlTimeout
264+
|| contentsSubpages
265+
|| contentsSubpageTarget
266+
|| contentsContext
267+
|| highlights
268+
|| summary
269+
|| extras
270+
? {
271+
contents: {
272+
text: contentsText,
273+
context: contentsContext,
274+
highlights,
275+
summary,
276+
livecrawl: contentsLivecrawl,
277+
livecrawlTimeout: contentsLivecrawlTimeout,
278+
subpages: contentsSubpages,
279+
subpageTarget: contentsSubpageTarget,
280+
extras,
281+
},
282+
}
283+
: undefined
284+
),
285+
},
286+
});
287+
288+
$.export("$summary", `Successfully found similar links with ID \`${response.requestId}\`.`);
289+
return response;
290+
},
291+
};

0 commit comments

Comments
 (0)