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
26 changes: 26 additions & 0 deletions packages/components/credentials/SeltzApi.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class SeltzApi implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]

constructor() {
this.label = 'Seltz API'
this.name = 'seltzApi'
this.version = 1.0
this.description =
'You can get your API key from the <a target="_blank" href="https://console.seltz.ai">Seltz Console</a>. Refer to <a target="_blank" href="https://docs.seltz.ai">official docs</a> for more information.'
this.inputs = [
{
label: 'Seltz API Key',
name: 'seltzApiKey',
type: 'password'
}
]
}
}

module.exports = { credClass: SeltzApi }
39 changes: 39 additions & 0 deletions packages/components/nodes/tools/SeltzSearch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Seltz Search Tool

A wrapper around the [Seltz](https://seltz.ai) Web Knowledge API. Returns web search results with source URLs, suitable for use in LLM tool-calling, agents, and RAG pipelines.

## Setup

1. Get your API key from the [Seltz Console](https://console.seltz.ai)
2. In Flowise, add the **Seltz Search** tool node to your flow
3. Create a new **Seltz API** credential with your API key
4. Connect the credential to the tool node

## Configuration

| Parameter | Description | Required |
| -------------------- | ------------------------------------------------------------------ | -------- |
| **API Key** | Your Seltz API key (via credential) | Yes |
| **Tool Description** | Custom description for the LLM to understand when to use this tool | No |
| **Max Documents** | Maximum number of documents to return | No |
| **Context** | Additional context to refine the search | No |
| **Profile** | Search profile to use | No |

## Output Format

The tool returns a JSON array of documents:

```json
[
{
"url": "https://example.com/article",
"content": "The relevant content from the web page..."
}
]
```

## Resources

- [Seltz Documentation](https://docs.seltz.ai)
- [Seltz Console](https://console.seltz.ai)
- [npm Package](https://www.npmjs.com/package/seltz)
151 changes: 151 additions & 0 deletions packages/components/nodes/tools/SeltzSearch/SeltzSearch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { Tool } from '@langchain/core/tools'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'

const defaultDesc =
'A context-engineered web search tool powered by Seltz. Useful for when you need to answer questions using fast, up-to-date web knowledge with sources for real-time AI reasoning. Input should be a search query. Output is a JSON array of documents with url and content fields.'

class SeltzSearch_Tools implements INode {
label: string
name: string
version: number
description: string
type: string
icon: string
category: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]

constructor() {
this.label = 'Seltz Search'
this.name = 'seltzSearch'
this.version = 1.0
this.type = 'SeltzSearch'
this.icon = 'seltz.svg'
this.category = 'Tools'
this.description = 'Wrapper around Seltz Web Knowledge API - context-engineered web content with sources for real-time AI reasoning'
this.inputs = [
{
label: 'Tool Description',
name: 'toolDescription',
type: 'string',
rows: 4,
default: defaultDesc,
optional: true,
additionalParams: true
},
{
label: 'Max Documents',
name: 'maxDocuments',
type: 'number',
description: 'Maximum number of documents to return',
optional: true,
step: 1,
additionalParams: true
},
{
label: 'Context',
name: 'context',
type: 'string',
description: 'Additional context to refine the search',
rows: 2,
optional: true,
additionalParams: true
},
{
label: 'Profile',
name: 'profile',
type: 'string',
description: 'Search profile to use',
optional: true,
additionalParams: true
}
]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['seltzApi']
}
this.baseClasses = [this.type, ...getBaseClasses(SeltzSearchTool)]
}

async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const seltzApiKey = getCredentialParam('seltzApiKey', credentialData, nodeData)
Comment thread
WilliamEspegren marked this conversation as resolved.

if (seltzApiKey == null) {
throw new Error('Seltz API key is missing. Please connect a Seltz API credential.')
}

const toolDescription = nodeData.inputs?.toolDescription as string
const maxDocuments = nodeData.inputs?.maxDocuments as string
const context = nodeData.inputs?.context as string
const profile = nodeData.inputs?.profile as string

const tool = new SeltzSearchTool({
apiKey: seltzApiKey,
maxDocuments: maxDocuments ? parseInt(maxDocuments, 10) : undefined,
context: context || undefined,
profile: profile || undefined
})

if (toolDescription) tool.description = toolDescription

return tool
}
}

class SeltzSearchTool extends Tool {
static lc_name() {
return 'SeltzSearchTool'
}

name = 'seltz-search'
description = defaultDesc

private apiKey: string
private maxDocuments?: number
private context?: string
private profile?: string

constructor({ apiKey, maxDocuments, context, profile }: { apiKey: string; maxDocuments?: number; context?: string; profile?: string }) {
super()
this.apiKey = apiKey
this.maxDocuments = maxDocuments
this.context = context
this.profile = profile
}

async _call(input: string): Promise<string> {
const { Seltz } = await import('seltz')
const client = new Seltz({ apiKey: this.apiKey })

const searchOptions: Record<string, any> = {}
if (this.maxDocuments) {
searchOptions.includes = { maxDocuments: this.maxDocuments }
}
if (this.context) {
searchOptions.context = this.context
}
if (this.profile) {
searchOptions.profile = this.profile
}

const response = await client.search(input, Object.keys(searchOptions).length > 0 ? searchOptions : undefined)

if (!response.documents || response.documents.length === 0) {
return 'No results found.'
}

const results = response.documents.map((doc: any) => ({
url: doc.url || '',
content: doc.content || ''
}))

return JSON.stringify(results)
}
}

module.exports = { nodeClass: SeltzSearch_Tools, SeltzSearchTool }
1 change: 1 addition & 0 deletions packages/components/nodes/tools/SeltzSearch/seltz.svg
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 @@ -160,6 +160,7 @@
"remove-markdown": "^0.6.2",
"replicate": "^0.31.1",
"sanitize-filename": "^1.6.3",
"seltz": "^0.2.0",
"srt-parser-2": "^1.2.3",
"supergateway": "3.0.1",
"typeorm": "^0.3.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Integration test for SeltzSearch tool.
* Requires SELTZ_API_KEY environment variable to be set.
* Run with: SELTZ_API_KEY=your-key npx jest --testPathPattern=SeltzSearch.integration
*/

export {}

// Mock @langchain/core/tools to avoid ESM issues in Jest
jest.mock('@langchain/core/tools', () => {
class MockTool {
name = ''
description = ''
}
return { Tool: MockTool }
})

jest.mock('../../../../src/utils', () => ({
getBaseClasses: jest.fn().mockReturnValue(['Tool']),
getCredentialData: jest.fn(),
getCredentialParam: jest.fn()
}))

const { SeltzSearchTool } = require('../../../../nodes/tools/SeltzSearch/SeltzSearch')

const SELTZ_API_KEY = process.env.SELTZ_API_KEY

const describeIfKey = SELTZ_API_KEY ? describe : describe.skip

describeIfKey('SeltzSearchTool Integration', () => {
it('should return search results for a basic query', async () => {
const tool = new SeltzSearchTool({ apiKey: SELTZ_API_KEY! })
const result = await tool._call('What is Flowise AI?')

const parsed = JSON.parse(result)
expect(Array.isArray(parsed)).toBe(true)
expect(parsed.length).toBeGreaterThan(0)
expect(parsed[0]).toHaveProperty('url')
expect(parsed[0]).toHaveProperty('content')
expect(parsed[0].url).toMatch(/^https?:\/\//)
expect(parsed[0].content.length).toBeGreaterThan(0)
}, 30000)

it('should respect maxDocuments option', async () => {
const tool = new SeltzSearchTool({ apiKey: SELTZ_API_KEY!, maxDocuments: 3 })
const result = await tool._call('TypeScript programming')

const parsed = JSON.parse(result)
expect(parsed.length).toBeLessThanOrEqual(3)
expect(parsed.length).toBeGreaterThan(0)
}, 30000)

it('should work with context option', async () => {
const tool = new SeltzSearchTool({
apiKey: SELTZ_API_KEY!,
context: 'open source AI workflow tools',
maxDocuments: 5
})
const result = await tool._call('low-code AI automation')

const parsed = JSON.parse(result)
expect(Array.isArray(parsed)).toBe(true)
expect(parsed.length).toBeGreaterThan(0)
}, 30000)
})
Loading