mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
Consolidated separate tavily blocks into one
This commit is contained in:
@@ -1,104 +1,70 @@
|
||||
import { TavilyIcon } from '@/components/icons'
|
||||
import { ExtractResponse } from '@/tools/tavily/extract'
|
||||
import { SearchResponse } from '@/tools/tavily/search'
|
||||
import { TavilyExtractResponse, TavilySearchResponse } from '@/tools/tavily/types'
|
||||
import { BlockConfig } from '../types'
|
||||
|
||||
export const TavilySearchBlock: BlockConfig<SearchResponse> = {
|
||||
type: 'tavily_search',
|
||||
toolbar: {
|
||||
title: 'Tavily Search',
|
||||
description: 'Search the web using Tavily AI',
|
||||
bgColor: '#0066FF',
|
||||
icon: TavilyIcon,
|
||||
category: 'tools',
|
||||
},
|
||||
tools: {
|
||||
access: ['tavily_search'],
|
||||
},
|
||||
workflow: {
|
||||
inputs: {
|
||||
query: { type: 'string', required: true },
|
||||
apiKey: { type: 'string', required: true },
|
||||
max_results: { type: 'number', required: false },
|
||||
},
|
||||
outputs: {
|
||||
response: {
|
||||
type: {
|
||||
query: 'string',
|
||||
results: 'json',
|
||||
response_time: 'number',
|
||||
},
|
||||
},
|
||||
},
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'query',
|
||||
title: 'Search Query',
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter your search query...',
|
||||
},
|
||||
{
|
||||
id: 'max_results',
|
||||
title: 'Max Results',
|
||||
type: 'dropdown',
|
||||
layout: 'half',
|
||||
options: ['5', '10', '15', '20'],
|
||||
},
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter your Tavily API key',
|
||||
password: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
type TavilyResponse = TavilySearchResponse | TavilyExtractResponse
|
||||
|
||||
export const TavilyExtractBlock: BlockConfig<ExtractResponse> = {
|
||||
type: 'tavily_extract',
|
||||
export const TavilyBlock: BlockConfig<TavilyResponse> = {
|
||||
type: 'tavily_block',
|
||||
toolbar: {
|
||||
title: 'Tavily Extract',
|
||||
description: 'Scrape website content',
|
||||
title: 'Tavily',
|
||||
description: 'Search and extract information using Tavily AI',
|
||||
bgColor: '#0066FF',
|
||||
icon: TavilyIcon,
|
||||
category: 'tools',
|
||||
},
|
||||
tools: {
|
||||
access: ['tavily_extract'],
|
||||
access: ['tavily_search', 'tavily_extract'],
|
||||
config: {
|
||||
tool: (params) => {
|
||||
switch (params.operation) {
|
||||
case 'tavily_search':
|
||||
return 'tavily_search'
|
||||
case 'tavily_extract':
|
||||
return 'tavily_extract'
|
||||
default:
|
||||
return 'tavily_search'
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
workflow: {
|
||||
inputs: {
|
||||
urls: { type: 'string', required: true },
|
||||
operation: { type: 'string', required: true },
|
||||
apiKey: { type: 'string', required: true },
|
||||
// Search operation
|
||||
query: { type: 'string', required: false },
|
||||
maxResults: { type: 'number', required: false },
|
||||
// Extract operation
|
||||
urls: { type: 'string', required: false },
|
||||
extract_depth: { type: 'string', required: false },
|
||||
},
|
||||
outputs: {
|
||||
response: {
|
||||
type: {
|
||||
results: 'json',
|
||||
failed_results: 'any',
|
||||
response_time: 'number',
|
||||
answer: 'any',
|
||||
query: 'string',
|
||||
content: 'string',
|
||||
title: 'string',
|
||||
url: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
subBlocks: [
|
||||
// Operation selector
|
||||
{
|
||||
id: 'urls',
|
||||
title: 'URL',
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter URL to extract content from...',
|
||||
},
|
||||
{
|
||||
id: 'extract_depth',
|
||||
title: 'Extract Depth',
|
||||
id: 'operation',
|
||||
title: 'Operation',
|
||||
type: 'dropdown',
|
||||
layout: 'half',
|
||||
options: ['basic', 'advanced'],
|
||||
layout: 'full',
|
||||
options: [
|
||||
{ label: 'Search', id: 'tavily_search' },
|
||||
{ label: 'Extract Content', id: 'tavily_extract' },
|
||||
],
|
||||
value: () => 'tavily_search',
|
||||
},
|
||||
// API Key (common)
|
||||
{
|
||||
id: 'apiKey',
|
||||
title: 'API Key',
|
||||
@@ -107,6 +73,41 @@ export const TavilyExtractBlock: BlockConfig<ExtractResponse> = {
|
||||
placeholder: 'Enter your Tavily API key',
|
||||
password: true,
|
||||
},
|
||||
// Search operation inputs
|
||||
{
|
||||
id: 'query',
|
||||
title: 'Search Query',
|
||||
type: 'long-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter your search query...',
|
||||
condition: { field: 'operation', value: 'tavily_search' },
|
||||
},
|
||||
{
|
||||
id: 'maxResults',
|
||||
title: 'Max Results',
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: '5',
|
||||
condition: { field: 'operation', value: 'tavily_search' },
|
||||
},
|
||||
// Extract operation inputs
|
||||
{
|
||||
id: 'urls',
|
||||
title: 'URL',
|
||||
type: 'long-input',
|
||||
layout: 'full',
|
||||
placeholder: 'Enter URL to extract content from...',
|
||||
condition: { field: 'operation', value: 'tavily_extract' },
|
||||
},
|
||||
{
|
||||
id: 'extract_depth',
|
||||
title: 'Extract Depth',
|
||||
type: 'dropdown',
|
||||
layout: 'full',
|
||||
options: ['basic', 'advanced'],
|
||||
value: () => 'basic',
|
||||
condition: { field: 'operation', value: 'tavily_extract' },
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { NotionBlock } from './blocks/notion'
|
||||
import { RouterBlock } from './blocks/router'
|
||||
import { SerperBlock } from './blocks/serper'
|
||||
import { SlackMessageBlock } from './blocks/slack'
|
||||
import { TavilyExtractBlock, TavilySearchBlock } from './blocks/tavily'
|
||||
import { TavilyBlock } from './blocks/tavily'
|
||||
import { TranslateBlock } from './blocks/translate'
|
||||
import { XBlock } from './blocks/x'
|
||||
import { YouTubeSearchBlock } from './blocks/youtube'
|
||||
@@ -31,8 +31,7 @@ export {
|
||||
GitHubBlock,
|
||||
ConditionBlock,
|
||||
SerperBlock,
|
||||
TavilySearchBlock,
|
||||
TavilyExtractBlock,
|
||||
TavilyBlock,
|
||||
RouterBlock,
|
||||
YouTubeSearchBlock,
|
||||
NotionBlock,
|
||||
@@ -54,8 +53,7 @@ const blocks: Record<string, BlockConfig> = {
|
||||
slack_message: SlackMessageBlock,
|
||||
github_repo_info: GitHubBlock,
|
||||
serper_search: SerperBlock,
|
||||
tavily_search: TavilySearchBlock,
|
||||
tavily_extract: TavilyExtractBlock,
|
||||
tavily_block: TavilyBlock,
|
||||
youtube_search: YouTubeSearchBlock,
|
||||
notion_reader: NotionBlock,
|
||||
gmail_block: GmailBlock,
|
||||
|
||||
29
tools/tavily/types.ts
Normal file
29
tools/tavily/types.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { ToolResponse } from '../types'
|
||||
|
||||
export interface TavilySearchResult {
|
||||
title: string
|
||||
url: string
|
||||
content: string
|
||||
score: number
|
||||
images?: string[]
|
||||
raw_content?: string
|
||||
}
|
||||
|
||||
export interface TavilySearchResponse extends ToolResponse {
|
||||
output: {
|
||||
results: TavilySearchResult[]
|
||||
answer?: string
|
||||
query: string
|
||||
images?: string[]
|
||||
rawContent?: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface TavilyExtractResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
title: string
|
||||
url: string
|
||||
rawContent?: string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user