-
-
Notifications
You must be signed in to change notification settings - Fork 23.9k
Added support for You.com's Web search & Web contents #5921
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
Open
kevmalek
wants to merge
1
commit into
FlowiseAI:main
Choose a base branch
from
kevmalek:feature/add-youdotcom-tools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+466
−171
Open
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions
24
packages/components/credentials/YouDotComApi.credential.ts
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,24 @@ | ||
| import { INodeParams, INodeCredential } from '../src/Interface' | ||
|
|
||
| class YouDotComApi implements INodeCredential { | ||
| label: string | ||
| name: string | ||
| version: number | ||
| inputs: INodeParams[] | ||
|
|
||
| constructor() { | ||
| this.label = 'You.com API' | ||
| this.name = 'youDotComApi' | ||
| this.version = 1.0 | ||
| this.inputs = [ | ||
| { | ||
| label: 'YDC API Key', | ||
| name: 'ydcApiKey', | ||
| type: 'password', | ||
| description: 'API key from you.com/platform/api-keys' | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| module.exports = { credClass: YouDotComApi } |
165 changes: 165 additions & 0 deletions
165
packages/components/nodes/tools/YouDotComSearch/YouDotComSearch.ts
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,165 @@ | ||
| import { DynamicStructuredTool } from '@langchain/core/tools' | ||
| import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' | ||
| import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' | ||
| import { youSearch } from '@youdotcom-oss/langchain' | ||
|
|
||
| class YouDotComSearch_Tools implements INode { | ||
| label: string | ||
| name: string | ||
| version: number | ||
| description: string | ||
| type: string | ||
| icon: string | ||
| category: string | ||
| author: string | ||
| baseClasses: string[] | ||
| credential: INodeParams | ||
| inputs: INodeParams[] | ||
|
|
||
| constructor() { | ||
| this.label = 'You.com Search' | ||
| this.name = 'youDotComSearch' | ||
| this.version = 1.0 | ||
| this.type = 'YouDotComSearch' | ||
| this.icon = 'Youcom_logo.jpg' | ||
| this.category = 'Tools' | ||
| this.author = 'You.com' | ||
| this.description = 'Real-time web search powered by You.com — returns titles, URLs, and snippets' | ||
| this.credential = { | ||
| label: 'Connect Credential', | ||
| name: 'credential', | ||
| type: 'credential', | ||
| credentialNames: ['youDotComApi'] | ||
| } | ||
| this.inputs = [ | ||
| { | ||
| label: 'Count', | ||
| name: 'count', | ||
| type: 'number', | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Number of search results to return' | ||
| }, | ||
| { | ||
| label: 'Freshness', | ||
| name: 'freshness', | ||
| type: 'string', | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Filter by recency — accepts relative dates like "Day", "Week", "Month", or ISO date ranges' | ||
| }, | ||
| { | ||
| label: 'Country', | ||
| name: 'country', | ||
| type: 'options', | ||
| options: [ | ||
| { label: 'Argentina', name: 'AR' }, | ||
| { label: 'Australia', name: 'AU' }, | ||
| { label: 'Austria', name: 'AT' }, | ||
| { label: 'Belgium', name: 'BE' }, | ||
| { label: 'Brazil', name: 'BR' }, | ||
| { label: 'Brazil (PT-BR)', name: 'PT-BR' }, | ||
| { label: 'Canada', name: 'CA' }, | ||
| { label: 'Chile', name: 'CL' }, | ||
| { label: 'China', name: 'CN' }, | ||
| { label: 'Denmark', name: 'DK' }, | ||
| { label: 'Finland', name: 'FI' }, | ||
| { label: 'France', name: 'FR' }, | ||
| { label: 'Germany', name: 'DE' }, | ||
| { label: 'Hong Kong', name: 'HK' }, | ||
| { label: 'India', name: 'IN' }, | ||
| { label: 'Indonesia', name: 'ID' }, | ||
| { label: 'Italy', name: 'IT' }, | ||
| { label: 'Japan', name: 'JP' }, | ||
| { label: 'Malaysia', name: 'MY' }, | ||
| { label: 'Mexico', name: 'MX' }, | ||
| { label: 'Netherlands', name: 'NL' }, | ||
| { label: 'New Zealand', name: 'NZ' }, | ||
| { label: 'Norway', name: 'NO' }, | ||
| { label: 'Philippines', name: 'PH' }, | ||
| { label: 'Poland', name: 'PL' }, | ||
| { label: 'Portugal', name: 'PT' }, | ||
| { label: 'Russia', name: 'RU' }, | ||
| { label: 'Saudi Arabia', name: 'SA' }, | ||
| { label: 'South Africa', name: 'ZA' }, | ||
| { label: 'South Korea', name: 'KR' }, | ||
| { label: 'Spain', name: 'ES' }, | ||
| { label: 'Sweden', name: 'SE' }, | ||
| { label: 'Switzerland', name: 'CH' }, | ||
| { label: 'Taiwan', name: 'TW' }, | ||
| { label: 'Turkey', name: 'TR' }, | ||
| { label: 'United Kingdom', name: 'GB' }, | ||
| { label: 'United States', name: 'US' } | ||
| ], | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Filter search results by country' | ||
| }, | ||
| { | ||
| label: 'Safe Search', | ||
| name: 'safesearch', | ||
| type: 'options', | ||
| options: [ | ||
| { label: 'Off', name: 'off' }, | ||
| { label: 'Moderate', name: 'moderate' }, | ||
| { label: 'Strict', name: 'strict' } | ||
| ], | ||
| default: 'moderate', | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Safe search filtering level' | ||
| }, | ||
| { | ||
| label: 'Live Crawl', | ||
| name: 'livecrawl', | ||
| type: 'options', | ||
| options: [ | ||
| { label: 'Web', name: 'web' }, | ||
| { label: 'News', name: 'news' }, | ||
| { label: 'All', name: 'all' } | ||
| ], | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Enable live crawling for the freshest results' | ||
| }, | ||
| { | ||
| label: 'Live Crawl Format', | ||
| name: 'livecrawl_formats', | ||
| type: 'options', | ||
| options: [ | ||
| { label: 'Markdown', name: 'markdown' }, | ||
| { label: 'HTML', name: 'html' } | ||
| ], | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Format for live crawled page content' | ||
| } | ||
| ] | ||
| this.baseClasses = [this.type, 'Tool', ...getBaseClasses(DynamicStructuredTool)] | ||
| } | ||
|
|
||
| async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> { | ||
| const credentialData = await getCredentialData(nodeData.credential ?? '', options) | ||
| const apiKey = getCredentialParam('ydcApiKey', credentialData, nodeData) | ||
|
|
||
| const config: Record<string, any> = { apiKey } | ||
|
|
||
| const count = nodeData.inputs?.count as number | ||
| const freshness = nodeData.inputs?.freshness as string | ||
| const country = nodeData.inputs?.country as string | ||
| const safesearch = nodeData.inputs?.safesearch as string | ||
| const livecrawl = nodeData.inputs?.livecrawl as string | ||
| const livecrawl_formats = nodeData.inputs?.livecrawl_formats as string | ||
|
|
||
| if (count) config.count = count | ||
| if (freshness) config.freshness = freshness | ||
| if (country) config.country = country | ||
| if (safesearch) config.safesearch = safesearch | ||
| if (livecrawl) config.livecrawl = livecrawl | ||
| if (livecrawl_formats) config.livecrawl_formats = livecrawl_formats | ||
|
|
||
| return youSearch(config) | ||
| } | ||
| } | ||
|
|
||
| module.exports = { nodeClass: YouDotComSearch_Tools } | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions
77
packages/components/nodes/tools/YouDotComWebContents/YouDotComWebContents.ts
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,77 @@ | ||
| import { DynamicStructuredTool } from '@langchain/core/tools' | ||
| import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' | ||
| import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' | ||
| import { youContents } from '@youdotcom-oss/langchain' | ||
|
|
||
| class YouDotComWebContents_Tools implements INode { | ||
| label: string | ||
| name: string | ||
| version: number | ||
| description: string | ||
| type: string | ||
| icon: string | ||
| category: string | ||
| author: string | ||
| baseClasses: string[] | ||
| credential: INodeParams | ||
| inputs: INodeParams[] | ||
|
|
||
| constructor() { | ||
| this.label = 'You.com Web Contents' | ||
| this.name = 'youDotComWebContents' | ||
| this.version = 1.0 | ||
| this.type = 'YouDotComWebContents' | ||
| this.icon = 'Youcom_logo.jpg' | ||
| this.category = 'Tools' | ||
| this.author = 'You.com' | ||
| this.description = 'Extract full page content from URLs in markdown, HTML, or metadata format using You.com' | ||
| this.credential = { | ||
| label: 'Connect Credential', | ||
| name: 'credential', | ||
| type: 'credential', | ||
| credentialNames: ['youDotComApi'] | ||
| } | ||
| this.inputs = [ | ||
| { | ||
| label: 'Formats', | ||
| name: 'formats', | ||
| type: 'multiOptions', | ||
| options: [ | ||
| { label: 'Markdown', name: 'markdown' }, | ||
| { label: 'HTML', name: 'html' }, | ||
| { label: 'Metadata', name: 'metadata' } | ||
| ], | ||
| default: ['markdown'], | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Output format(s) for extracted page content' | ||
| }, | ||
| { | ||
| label: 'Crawl Timeout', | ||
| name: 'crawl_timeout', | ||
| type: 'number', | ||
| optional: true, | ||
| additionalParams: true, | ||
| description: 'Timeout in seconds for page crawling (1–60)' | ||
| } | ||
| ] | ||
| this.baseClasses = [this.type, 'Tool', ...getBaseClasses(DynamicStructuredTool)] | ||
| } | ||
|
|
||
| async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> { | ||
| const credentialData = await getCredentialData(nodeData.credential ?? '', options) | ||
| const apiKey = getCredentialParam('ydcApiKey', credentialData, nodeData) | ||
|
|
||
| const config: Record<string, any> = { apiKey } | ||
|
|
||
| const formats = nodeData.inputs?.formats as string[] | ||
| const crawl_timeout = nodeData.inputs?.crawl_timeout as number | ||
|
|
||
| if (formats && formats.length > 0) config.formats = formats | ||
| if (crawl_timeout) config.crawl_timeout = crawl_timeout | ||
|
|
||
| return youContents(config) | ||
| } | ||
| } | ||
|
|
||
| module.exports = { nodeClass: YouDotComWebContents_Tools } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for building the
configobject can be made more concise and maintainable. Instead of manually handling each input parameter, you can iterate through thethis.inputsarray. This will automatically handle any future additions or removals of input parameters, reducing the chance of errors.