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
24 changes: 24 additions & 0 deletions packages/components/credentials/YouDotComApi.credential.ts
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 packages/components/nodes/tools/YouDotComSearch/YouDotComSearch.ts
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
Comment on lines +147 to +159
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for building the config object can be made more concise and maintainable. Instead of manually handling each input parameter, you can iterate through the this.inputs array. This will automatically handle any future additions or removals of input parameters, reducing the chance of errors.

Suggested change
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
const inputs = nodeData.inputs ?? {}
for (const input of this.inputs) {
if (inputs[input.name]) {
config[input.name] = inputs[input.name]
}
}


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.
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.
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"@types/jsdom": "^21.1.1",
"@upstash/redis": "1.22.1",
"@upstash/vector": "1.1.5",
"@youdotcom-oss/langchain": "1.1.0",
"@zilliz/milvus2-sdk-node": "^2.2.24",
"apify-client": "^2.7.1",
"assemblyai": "^4.2.2",
Expand Down
Loading