Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions components/exa/actions/answer-question/answer-question.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import app from "../../exa.app.mjs";

export default {
key: "exa-answer-question",
name: "Answer Question",
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)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
app,
query: {
label: "Question",
description: "The question or query to answer",
propDefinition: [
app,
"query",
],
},
text: {
propDefinition: [
app,
"text",
],
description: "Whether to include full text content from search results in the response",
},
stream: {
type: "boolean",
label: "Stream",
description: "Enable streaming response via server-sent events (not recommended for Pipedream workflows)",
optional: true,
},
},
async run({ $ }) {
const {
app,
query,
text,
stream,
} = this;

const response = await app.answer({
$,
data: {
query,
text,
stream,
},
});

$.export("$summary", "Successfully answered question.");
return response;
},
};
291 changes: 291 additions & 0 deletions components/exa/actions/find-similar-links/find-similar-links.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
import { ConfigurationError } from "@pipedream/platform";
import app from "../../exa.app.mjs";

export default {
key: "exa-find-similar-links",
name: "Find Similar Links",
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)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
app,
url: {
propDefinition: [
app,
"url",
],
},
numResults: {
propDefinition: [
app,
"numResults",
],
},
includeDomains: {
propDefinition: [
app,
"includeDomains",
],
},
excludeDomains: {
propDefinition: [
app,
"excludeDomains",
],
},
startCrawlDate: {
propDefinition: [
app,
"startCrawlDate",
],
},
endCrawlDate: {
propDefinition: [
app,
"endCrawlDate",
],
},
startPublishedDate: {
propDefinition: [
app,
"startPublishedDate",
],
},
endPublishedDate: {
propDefinition: [
app,
"endPublishedDate",
],
},
includeText: {
propDefinition: [
app,
"includeText",
],
},
excludeText: {
propDefinition: [
app,
"excludeText",
],
},
context: {
propDefinition: [
app,
"context",
],
},
moderation: {
propDefinition: [
app,
"moderation",
],
},
contentsText: {
label: "Contents - Text",
propDefinition: [
app,
"text",
],
},
contentsHighlightsNumSentences: {
label: "Contents - Highlights - Number of Sentences",
propDefinition: [
app,
"highlightsNumSentences",
],
},
contentsHighlightsPerUrl: {
label: "Contents - Highlights - Number of Snippets per URL",
propDefinition: [
app,
"highlightsPerUrl",
],
},
contentsHighlightsQuery: {
label: "Contents - Highlights - Custom Query",
propDefinition: [
app,
"highlightsQuery",
],
},
contentsSummaryQuery: {
label: "Contents - Summary - Custom Query",
propDefinition: [
app,
"summaryQuery",
],
},
contentsSummarySchema: {
label: "Contents - Summary - JSON Schema",
propDefinition: [
app,
"summarySchema",
],
},
contentsLivecrawl: {
label: "Contents - Live Crawl",
propDefinition: [
app,
"livecrawl",
],
},
contentsLivecrawlTimeout: {
label: "Contents - Live Crawl Timeout",
propDefinition: [
app,
"livecrawlTimeout",
],
},
contentsSubpages: {
label: "Contents - Subpages",
propDefinition: [
app,
"subpages",
],
},
contentsSubpageTarget: {
label: "Contents - Subpage Target",
propDefinition: [
app,
"subpageTarget",
],
},
contentsExtrasLinks: {
label: "Contents - Extras - Number of Links",
propDefinition: [
app,
"extrasLinks",
],
},
contentsExtrasImageLinks: {
label: "Contents - Extras - Number of Image Links",
propDefinition: [
app,
"extrasImageLinks",
],
},
contentsContext: {
label: "Contents - Context",
propDefinition: [
app,
"context",
],
},
},
async run({ $ }) {
const {
app,
url,
numResults,
includeDomains,
excludeDomains,
startCrawlDate,
endCrawlDate,
startPublishedDate,
endPublishedDate,
includeText,
excludeText,
contentsText,
contentsHighlightsNumSentences,
contentsHighlightsPerUrl,
contentsHighlightsQuery,
contentsSummaryQuery,
contentsSummarySchema,
contentsLivecrawl,
contentsLivecrawlTimeout,
contentsSubpages,
contentsSubpageTarget,
contentsExtrasLinks,
contentsExtrasImageLinks,
contentsContext,
} = this;

const highlights = contentsHighlightsNumSentences
|| contentsHighlightsPerUrl
|| contentsHighlightsQuery
? {
numSentences: contentsHighlightsNumSentences,
highlightsPerUrl: contentsHighlightsPerUrl,
query: contentsHighlightsQuery,
}
: undefined;

let parsedSchema;
if (contentsSummarySchema) {
if (typeof contentsSummarySchema === "string") {
try {
parsedSchema = JSON.parse(contentsSummarySchema);
} catch (error) {
throw new ConfigurationError(`Invalid JSON schema format: ${error.message}. Please provide a valid JSON object.`);
}
} else {
parsedSchema = contentsSummarySchema;
}
}

const summary = contentsSummaryQuery
|| contentsSummarySchema
? {
query: contentsSummaryQuery,
schema: parsedSchema,
}
: undefined;

const extras = contentsExtrasLinks
|| contentsExtrasImageLinks
? {
links: contentsExtrasLinks,
imageLinks: contentsExtrasImageLinks,
}
: undefined;

const response = await app.findSimilar({
$,
data: {
url,
numResults,
includeDomains,
excludeDomains,
startCrawlDate,
endCrawlDate,
startPublishedDate,
endPublishedDate,
includeText,
excludeText,
...(contentsText
|| contentsLivecrawl
|| contentsLivecrawlTimeout
|| contentsSubpages
|| contentsSubpageTarget
|| contentsContext
|| highlights
|| summary
|| extras
? {
contents: {
text: contentsText,
context: contentsContext,
highlights,
summary,
livecrawl: contentsLivecrawl,
livecrawlTimeout: contentsLivecrawlTimeout,
subpages: contentsSubpages,
subpageTarget: contentsSubpageTarget,
extras,
},
}
: undefined
),
},
});

$.export("$summary", `Successfully found similar links with ID \`${response.requestId}\`.`);
return response;
},
};
Loading
Loading