-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - harpa_ai #17690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - harpa_ai #17690
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
components/harpa_ai/actions/run-ai-command/run-ai-command.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import harpaAi from "../../harpa_ai.app.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "harpa_ai-run-ai-command", | ||
| name: "Run AI Command", | ||
| description: "Run an AI command. [See the documentation](https://harpa.ai/grid/grid-rest-api-reference#run-ai-command)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| harpaAi, | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "the page to run the AI command over", | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "A command name to execute such as Summary", | ||
| optional: true, | ||
| }, | ||
| inputs: { | ||
| type: "string[]", | ||
| label: "Inputs", | ||
| description: "An array of Strings, each one passed down into command in place of the user input. Inputs are used to bypass waiting for the user input in multi-step commands. For example [ \"REPORT\", \"DONE\" ] for the Summary command.", | ||
| optional: true, | ||
| }, | ||
| resultParam: { | ||
| type: "string", | ||
| label: "Result Param", | ||
| description: "A HARPA {{parameter}} to interpret as the command result. By default is set to \"message\" to take the last chat message. Supports dot notation, e.g. \"g.data.email\". Refer to [AI Commands Guide](https://harpa.ai/chatml/overview) for more details.", | ||
| optional: true, | ||
| }, | ||
| node: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "node", | ||
| ], | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "timeout", | ||
| ], | ||
| }, | ||
| resultsWebhook: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "resultsWebhook", | ||
| ], | ||
| }, | ||
| connection: { | ||
| type: "string", | ||
| label: "Connection", | ||
| description: "The title or ID of AI connection to use for AI actions. If not specified or connection not found, default connection is used.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.harpaAi.sendAction({ | ||
| $, | ||
| data: { | ||
| action: "command", | ||
| url: this.url, | ||
| name: this.name, | ||
| inputs: parseObject(this.inputs), | ||
| resultParam: this.resultParam, | ||
| node: this.node, | ||
| timeout: this.timeout, | ||
| resultsWebhook: this.resultsWebhook, | ||
| connection: this.connection, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Ran AI command on ${this.url}`); | ||
| return response; | ||
| }, | ||
| }; |
57 changes: 57 additions & 0 deletions
57
components/harpa_ai/actions/scrape-web-page/scrape-web-page.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import harpaAi from "../../harpa_ai.app.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "harpa_ai-scrape-web-page", | ||
| name: "Scrape Web Page", | ||
| description: "Scrape a web page. [See the documentation](https://harpa.ai/grid/grid-rest-api-reference#web-page-scraping)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| harpaAi, | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "The URL of the web page to scrape", | ||
| }, | ||
| grab: { | ||
| type: "string[]", | ||
| label: "Grab", | ||
| description: "An array of HTML Element selectors to scrape from the page. Refer to the [Scraping Web Page Elements and Data](https://harpa.ai/grid/grid-rest-api-reference#scraping-web-page-elements-and-data) section for more details.", | ||
| optional: true, | ||
| }, | ||
| node: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "node", | ||
| ], | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "timeout", | ||
| ], | ||
| }, | ||
| resultsWebhook: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "resultsWebhook", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.harpaAi.sendAction({ | ||
| $, | ||
| data: { | ||
| action: "scrape", | ||
| url: this.url, | ||
| grab: parseObject(this.grab), | ||
| node: this.node, | ||
| timeout: this.timeout, | ||
| resultsWebhook: this.resultsWebhook, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Scraped ${this.url}`); | ||
| return response; | ||
| }, | ||
| }; |
49 changes: 49 additions & 0 deletions
49
components/harpa_ai/actions/search-the-web/search-the-web.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import harpaAi from "../../harpa_ai.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "harpa_ai-search-the-web", | ||
| name: "Search the Web", | ||
| description: "Search the web. [See the documentation](https://harpa.ai/grid/grid-rest-api-reference#search-the-web)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| harpaAi, | ||
| query: { | ||
| type: "string", | ||
| label: "Query", | ||
| description: "The search term or a query string to search for. Supports search parameters like **site:example.com** or **intitle:keyword**.", | ||
| }, | ||
| node: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "node", | ||
| ], | ||
| }, | ||
| timeout: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "timeout", | ||
| ], | ||
| }, | ||
| resultsWebhook: { | ||
| propDefinition: [ | ||
| harpaAi, | ||
| "resultsWebhook", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.harpaAi.sendAction({ | ||
| $, | ||
| data: { | ||
| action: "serp", | ||
| query: this.query, | ||
| node: this.node, | ||
| timeout: this.timeout, | ||
| resultsWebhook: this.resultsWebhook, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Searched the web for ${this.query}`); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) { | ||
| return undefined; | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| if (Array.isArray(obj)) { | ||
| return obj.map(parseObject); | ||
| } | ||
| if (typeof obj === "object") { | ||
| return Object.fromEntries(Object.entries(obj).map(([ | ||
| key, | ||
| value, | ||
| ]) => [ | ||
| key, | ||
| parseObject(value), | ||
| ])); | ||
| } | ||
| return obj; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,50 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "harpa_ai", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| node: { | ||
| type: "string", | ||
| label: "Node", | ||
| description: "A target Node ID which should run the command. If omitted, the first available Node will be used.", | ||
| optional: true, | ||
| }, | ||
| timeout: { | ||
| type: "string", | ||
| label: "Timeout", | ||
| description: "Synchronous action execution timeout", | ||
| optional: true, | ||
| }, | ||
| resultsWebhook: { | ||
| type: "string", | ||
| label: "Results Webhook", | ||
| description: "An asynchronous webhook URL to send the results to upon completion", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.harpa.ai/api/v1"; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| "Authorization": `Bearer ${this.$auth.api_key}`, | ||
| "Content-type": "application/json", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| sendAction(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/grid", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.