From 83f53ca4d90a21adc2c07126d41a9c4dcb5c1f7d Mon Sep 17 00:00:00 2001 From: Jintao Wei <2797154930@qq.com> Date: Thu, 5 Feb 2026 14:00:13 +0800 Subject: [PATCH] add bocha web search tool --- apps/docs/content/docs/de/tools/bocha.mdx | 48 ++++++++++ apps/docs/content/docs/en/tools/bocha.mdx | 48 ++++++++++ apps/docs/content/docs/es/tools/bocha.mdx | 48 ++++++++++ apps/docs/content/docs/fr/tools/bocha.mdx | 48 ++++++++++ apps/docs/content/docs/ja/tools/bocha.mdx | 48 ++++++++++ apps/docs/content/docs/zh/tools/bocha.mdx | 58 ++++++++++++ apps/sim/blocks/blocks/bocha.ts | 86 +++++++++++++++++ apps/sim/blocks/registry.ts | 2 + apps/sim/components/icons.tsx | 35 +++++++ apps/sim/tools/bocha/index.ts | 5 + apps/sim/tools/bocha/search.ts | 109 ++++++++++++++++++++++ apps/sim/tools/bocha/types.ts | 38 ++++++++ apps/sim/tools/registry.ts | 2 + 13 files changed, 575 insertions(+) create mode 100644 apps/docs/content/docs/de/tools/bocha.mdx create mode 100644 apps/docs/content/docs/en/tools/bocha.mdx create mode 100644 apps/docs/content/docs/es/tools/bocha.mdx create mode 100644 apps/docs/content/docs/fr/tools/bocha.mdx create mode 100644 apps/docs/content/docs/ja/tools/bocha.mdx create mode 100644 apps/docs/content/docs/zh/tools/bocha.mdx create mode 100644 apps/sim/blocks/blocks/bocha.ts create mode 100644 apps/sim/tools/bocha/index.ts create mode 100644 apps/sim/tools/bocha/search.ts create mode 100644 apps/sim/tools/bocha/types.ts diff --git a/apps/docs/content/docs/de/tools/bocha.mdx b/apps/docs/content/docs/de/tools/bocha.mdx new file mode 100644 index 0000000000..0b167f9f53 --- /dev/null +++ b/apps/docs/content/docs/de/tools/bocha.mdx @@ -0,0 +1,48 @@ +--- +title: BoCha +description: Websuche mit BoCha +--- + +[BoCha](https://bocha.cn/) ist eine KI-gestützte Such-API, die speziell für LLM-Anwendungen entwickelt wurde. Sie bietet zuverlässige Echtzeit-Informationsabfragen und ist für KI-Anwendungsfälle optimiert. + +Mit BoCha in Sim können Sie: + +- **Webseiten durchsuchen**: Sofort Antworten, Fakten und Übersichten zu Suchanfragen finden +- **Direkte Antworten erhalten**: Konkrete Ergebnisse für Berechnungen, Umrechnungen oder Faktenabfragen abrufen +- **Zusammenfassungen erhalten**: Kurze Zusammenfassungen oder Beschreibungen zu Suchthemen bekommen +- **Verwandte Themen entdecken**: Links und Referenzen zu verwandten Suchthemen finden + +Diese Funktionen ermöglichen es Sim-Agenten, automatisch auf aktuelles Webwissen zuzugreifen – von der Darstellung von Fakten in Workflows bis hin zur Anreicherung von Dokumenten und Analysen mit neuesten Informationen. + +## Verwendung + +Verwenden Sie die BoCha Instant Answer API, um das Web zu durchsuchen. Sie gibt direkte Antworten, Zusammenfassungen und verwandte Themen zurück. + +## Tool + +### `bocha_search` + +Durchsucht das Web mit der BoCha Instant Answer API und gibt direkte Antworten, Zusammenfassungen und verwandte Themen zurück. + +#### Eingaben + +| Parameter | Typ | Erforderlich | Beschreibung | +| --------- | ---- | ---- | ----------- | +| `query` | string | Ja | Die auszuführende Suchanfrage (z. B. „latest AI research papers 2024“) | +| `freshness` | string | Nein | Zeitbereich der Suchergebnisse (noLimit / oneDay / oneWeek / oneMonth / oneYear / YYYY-MM-DD / YYYY-MM-DD..YYYY-MM-DD) | +| `summary` | boolean | Nein | Ob eine Textzusammenfassung zurückgegeben werden soll | +| `count` | number | Nein | Maximale Anzahl der Ergebnisse (1–50, z. B. 5) | +| `include` | string | Nein | Eingeschränkte Domains für die Suche, getrennt durch `|` oder `,` (max. 100) | +| `exclude` | string | Nein | Ausgeschlossene Domains, getrennt durch `|` oder `,` (max. 100) | + +#### Ausgaben + +| Parameter | Typ | Beschreibung | +| --------- | ---- | ----------- | +| `query` | string | Die ausgeführte Suchanfrage | +| `results` | array | Suchergebnisse des Tools | + +## Hinweise + +- Kategorie: `tools` +- Typ: `bocha` diff --git a/apps/docs/content/docs/en/tools/bocha.mdx b/apps/docs/content/docs/en/tools/bocha.mdx new file mode 100644 index 0000000000..5dfd6776c2 --- /dev/null +++ b/apps/docs/content/docs/en/tools/bocha.mdx @@ -0,0 +1,48 @@ +--- +title: BoCha +description: Search the web using BoCha +--- + +[BoCha](https://bocha.cn/) is an AI-powered search API designed specifically for LLM applications. It provides reliable real-time information retrieval and is optimized for AI-driven use cases. + +With BoCha in Sim, you can: + +- **Search the web**: Instantly find answers, facts, and overviews for search queries +- **Get direct answers**: Retrieve precise responses for calculations, conversions, or factual queries +- **Access summaries**: Receive concise summaries or descriptions of search topics +- **Discover related topics**: Explore links and references related to your search + +These capabilities allow Sim agents to automatically access up-to-date web knowledge—from presenting facts in workflows to enriching documents and analyses with the latest information. + +## Usage + +Use the BoCha Instant Answer API to search the web. It returns direct answers, summaries, and related topics. + +## Tool + +### `bocha_search` + +Searches the web using the BoCha Instant Answer API and returns direct answers, summaries, and related topics. + +#### Inputs + +| Parameter | Type | Required | Description | +| --------- | ---- | ---- | ----------- | +| `query` | string | Yes | The search query to execute (e.g., "latest AI research papers 2024") | +| `freshness` | string | No | Time range for search results (noLimit / oneDay / oneWeek / oneMonth / oneYear / YYYY-MM-DD / YYYY-MM-DD..YYYY-MM-DD) | +| `summary` | boolean | No | Whether to return a text summary | +| `count` | number | No | Maximum number of results (1–50, e.g., 5) | +| `include` | string | No | Domains to include in the search, separated by `|` or `,` (max 100) | +| `exclude` | string | No | Domains to exclude from the search, separated by `|` or `,` (max 100) | + +#### Outputs + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `query` | string | The executed search query | +| `results` | array | Results returned by the tool | + +## Notes + +- Category: `tools` +- Type: `bocha` diff --git a/apps/docs/content/docs/es/tools/bocha.mdx b/apps/docs/content/docs/es/tools/bocha.mdx new file mode 100644 index 0000000000..8a1245d273 --- /dev/null +++ b/apps/docs/content/docs/es/tools/bocha.mdx @@ -0,0 +1,48 @@ +--- +title: BoCha +description: Buscar en la web con BoCha +--- + +[BoCha](https://bocha.cn/) es una API de búsqueda impulsada por IA diseñada específicamente para aplicaciones LLM. Proporciona recuperación de información en tiempo real y está optimizada para casos de uso con IA. + +Con BoCha en Sim, puedes: + +- **Buscar en la web**: Encontrar instantáneamente respuestas, hechos y resúmenes +- **Obtener respuestas directas**: Recuperar resultados precisos para cálculos, conversiones o consultas factuales +- **Acceder a resúmenes**: Recibir descripciones breves de temas de búsqueda +- **Descubrir temas relacionados**: Explorar enlaces y referencias relacionadas + +Estas capacidades permiten a los agentes de Sim acceder automáticamente a conocimiento web actualizado, enriqueciendo flujos de trabajo, documentos y análisis. + +## Uso + +Utiliza la API de respuestas instantáneas de BoCha para buscar en la web. Devuelve respuestas directas, resúmenes y temas relacionados. + +## Herramienta + +### `bocha_search` + +Busca en la web utilizando la API de respuestas instantáneas de BoCha. + +#### Entradas + +| Parámetro | Tipo | Requerido | Descripción | +| --------- | ---- | ---- | ----------- | +| `query` | string | Sí | Consulta de búsqueda (ej.: "latest AI research papers 2024") | +| `freshness` | string | No | Rango de tiempo de los resultados | +| `summary` | boolean | No | Si se debe devolver un resumen | +| `count` | number | No | Número máximo de resultados | +| `include` | string | No | Dominios incluidos | +| `exclude` | string | No | Dominios excluidos | + +#### Salidas + +| Parámetro | Tipo | Descripción | +| --------- | ---- | ----------- | +| `query` | string | Consulta ejecutada | +| `results` | array | Resultados devueltos | + +## Notas + +- Categoría: `tools` +- Tipo: `bocha` diff --git a/apps/docs/content/docs/fr/tools/bocha.mdx b/apps/docs/content/docs/fr/tools/bocha.mdx new file mode 100644 index 0000000000..365d4fb07b --- /dev/null +++ b/apps/docs/content/docs/fr/tools/bocha.mdx @@ -0,0 +1,48 @@ +--- +title: BoCha +description: Recherche web avec BoCha +--- + +[BoCha](https://bocha.cn/) est une API de recherche alimentée par l’IA, conçue pour les applications LLM. Elle fournit un accès fiable à des informations en temps réel, optimisées pour les usages IA. + +Avec BoCha dans Sim, vous pouvez : + +- **Rechercher sur le web** : Obtenir instantanément des réponses et des faits +- **Recevoir des réponses directes** : Pour des calculs, conversions ou requêtes factuelles +- **Accéder à des résumés** : Descriptions concises de sujets de recherche +- **Découvrir des sujets connexes** : Liens et références associés + +Ces fonctionnalités permettent aux agents Sim d’accéder automatiquement aux connaissances web les plus récentes. + +## Utilisation + +Utilisez l’API Instant Answer de BoCha pour effectuer des recherches web. + +## Outil + +### `bocha_search` + +Recherche sur le web via l’API Instant Answer de BoCha. + +#### Entrées + +| Paramètre | Type | Requis | Description | +| --------- | ---- | ---- | ----------- | +| `query` | string | Oui | Requête de recherche | +| `freshness` | string | Non | Période temporelle | +| `summary` | boolean | Non | Retourner un résumé | +| `count` | number | Non | Nombre maximal de résultats | +| `include` | string | Non | Domaines inclus | +| `exclude` | string | Non | Domaines exclus | + +#### Sorties + +| Paramètre | Type | Description | +| --------- | ---- | ----------- | +| `query` | string | Requête exécutée | +| `results` | array | Résultats retournés | + +## Remarques + +- Catégorie : `tools` +- Type : `bocha` diff --git a/apps/docs/content/docs/ja/tools/bocha.mdx b/apps/docs/content/docs/ja/tools/bocha.mdx new file mode 100644 index 0000000000..5c7830457f --- /dev/null +++ b/apps/docs/content/docs/ja/tools/bocha.mdx @@ -0,0 +1,48 @@ +--- +title: BoCha +description: BoCha を使用した Web 検索 +--- + +[BoCha](https://bocha.cn/) は、LLM アプリケーション向けに設計された AI 駆動の検索 API です。信頼性の高いリアルタイム情報検索を提供し、AI 利用シナリオに最適化されています。 + +Sim で BoCha を使用すると、次のことが可能です: + +- **Web 検索**:検索クエリに対する回答・事実・概要を即座に取得 +- **直接回答の取得**:計算、変換、事実ベースの質問への正確な回答 +- **要約の取得**:検索トピックの簡潔な要約 +- **関連トピックの発見**:関連リンクや参考資料の探索 + +これらの機能により、Sim エージェントは最新の Web 知識に自動的にアクセスできます。 + +## 使用方法 + +BoCha の Instant Answer API を使用して Web を検索します。 + +## ツール + +### `bocha_search` + +BoCha Instant Answer API を使用して Web を検索します。 + +#### 入力 + +| パラメータ | 型 | 必須 | 説明 | +| --------- | ---- | ---- | ----------- | +| `query` | string | はい | 実行する検索クエリ | +| `freshness` | string | いいえ | 検索結果の期間 | +| `summary` | boolean | いいえ | 要約を返すかどうか | +| `count` | number | いいえ | 最大結果数 | +| `include` | string | いいえ | 含めるドメイン | +| `exclude` | string | いいえ | 除外するドメイン | + +#### 出力 + +| パラメータ | 型 | 説明 | +| --------- | ---- | ----------- | +| `query` | string | 実行された検索クエリ | +| `results` | array | 検索結果 | + +## 注意事項 + +- カテゴリ:`tools` +- タイプ:`bocha` diff --git a/apps/docs/content/docs/zh/tools/bocha.mdx b/apps/docs/content/docs/zh/tools/bocha.mdx new file mode 100644 index 0000000000..09f06c2643 --- /dev/null +++ b/apps/docs/content/docs/zh/tools/bocha.mdx @@ -0,0 +1,58 @@ +--- +title: BoCha +description: 使用 BoCha 搜索 +--- + +import { BlockInfoCard } from "@/components/ui/block-info-card" + + + +{/* MANUAL-CONTENT-START:intro */} +[BoCha](https://bocha.cn/) 是一款专为 LLM 应用设计的 AI 驱动搜索 API。它提供可靠的实时信息检索功能,并针对 AI 使用场景优化了功能. + +在 Sim 中使用 BoCha,您可以: + +- **搜索网页**:即时找到答案、事实和搜索查询的概述 +- **获取直接答案**:检索计算、转换或事实查询的具体响应 +- **访问摘要**:接收搜索主题的简短总结或描述 +- **获取相关主题**:发现与搜索相关的链接和参考资料 + +这些功能使您的 Sim 代理能够自动访问最新的网络知识——从在工作流程中呈现事实,到通过最新信息丰富文档和分析。。 +{/* MANUAL-CONTENT-END */} + +## 使用说明 + +使用 BoCha 即时答案 API 搜索网页。返回即时答案、摘要、相关主题等。 + +## 工具 + +### `bocha_search` + +使用 BoCha 即时答案 API 搜索网页。返回查询的即时答案、摘要和相关主题。 + +#### 输入 + +| 参数 | 类型 | 必需 | 描述 | +| --------- | ---- | ---- | ----------- | +| `query` | string | 是 | 要执行的搜索查询(例如:"latest AI research papers 2024") | +| `freshness` | string | 否 | 指定搜索结果的时间范围(noLimit / oneDay / oneWeek / oneMonth / oneYear / YYYY-MM-DD / YYYY-MM-DD..YYYY-MM-DD) | +| `summary` | boolean | 否 | 是否返回文本摘要 | +| `count` | number | 否 | 返回结果的最大数量(1–50,例如:5) | +| `include` | string | 否 | 限定搜索的网站域名范围,多个域名用 `|` 或 `,` 分隔,最多 100 个 | +| `exclude` | string | 否 | 从搜索结果中排除指定网站域名,多个域名用 `|` 或 `,` 分隔,最多 100 个 | + + +#### 输出 + +| 参数 | 类型 | 描述 | +| --------- | ---- | ----------- | +| `query` | 字符串 | 已执行的搜索查询 | +| `results` | 数组 | 工具输出的结果 | + +## 注意事项 + +- 类别:`tools` +- 类型:`bocha` diff --git a/apps/sim/blocks/blocks/bocha.ts b/apps/sim/blocks/blocks/bocha.ts new file mode 100644 index 0000000000..63e18391e8 --- /dev/null +++ b/apps/sim/blocks/blocks/bocha.ts @@ -0,0 +1,86 @@ +import { BoChaIcon } from '@/components/icons' +import type { BlockConfig } from '@/blocks/types' +import type { BoChaSearchResponse } from '@/tools/bocha/types' + +export const BoChaBlock: BlockConfig = { + type: 'bocha', + name: 'BoCha', + description: 'Search with BoCha', + longDescription: + 'Search the web using BoCha Instant Answers API. Returns instant answers, abstracts, related topics, and more.', + docsLink: 'https://docs.sim.ai/tools/bocha', + category: 'tools', + bgColor: '#FFFFFF', + icon: BoChaIcon, + subBlocks: [ + { + id: 'query', + title: 'Search Query', + type: 'long-input', + placeholder: 'Enter your search query', + required: true, + }, + { + id: 'freshness', + title: 'Freshness', + type: 'long-input', + placeholder: 'noLimit', + description: 'Search for web pages within a specified time range(noLimit/oneDay/oneWeek/oneMonth/oneYear/YYYY-MM-DD/YYYY-MM-DD/YYYY-MM-DD..YYYY-MM-DD)', + }, + { + id: 'summary', + title: 'Show Summary', + type: 'switch', + defaultValue: false, + }, + { + id: 'count', + title: 'Result Count', + type: 'short-input', + min: 1, + max: 50, + placeholder: 'e.g. 5', + }, + { + id: 'include', + title: 'Include Domains', + type: 'long-input', + placeholder: 'example.com | arxiv.org', + description: 'Limit search to specific domains (separate by | or ,)', + }, + { + id: 'exclude', + title: 'Exclude Domains', + type: 'long-input', + placeholder: 'spam.com | ads.example', + description: 'Exclude specific domains from search results', + }, + { + id: 'apiKey', + title: 'API Key', + type: 'short-input', + placeholder: 'Enter your BoCha API key', + password: true, + required: true, + }, + ], + tools: { + access: ['bocha_search'], + config: { + tool: () => 'bocha_search', + }, + }, + inputs: { + query: { type: 'string', description: 'Search query terms' }, + freshness: { type: 'string', description: 'Time range filter for search results' }, + summary: { type: 'boolean', description: 'Whether to return a text summary' }, + count: { type: 'number', description: 'Maximum number of search results to return' }, + include: { type: 'string', description: 'Domains to include in search results' }, + exclude: { type: 'string', description: 'Domains to exclude from search results' }, + apiKey: { type: 'string', description: 'BoCha API key' }, + }, + outputs: { + query: { type: 'string', description: 'Search query used' }, + results: { type: 'json', description: 'Array of external link results' }, + }, +} diff --git a/apps/sim/blocks/registry.ts b/apps/sim/blocks/registry.ts index 4fbaf27660..8dbbb1c094 100644 --- a/apps/sim/blocks/registry.ts +++ b/apps/sim/blocks/registry.ts @@ -23,6 +23,7 @@ import { DiscordBlock } from '@/blocks/blocks/discord' import { DropboxBlock } from '@/blocks/blocks/dropbox' import { DSPyBlock } from '@/blocks/blocks/dspy' import { DuckDuckGoBlock } from '@/blocks/blocks/duckduckgo' +import {BoChaBlock} from '@/blocks/blocks/bocha.ts' import { DynamoDBBlock } from '@/blocks/blocks/dynamodb' import { ElasticsearchBlock } from '@/blocks/blocks/elasticsearch' import { ElevenLabsBlock } from '@/blocks/blocks/elevenlabs' @@ -186,6 +187,7 @@ export const registry: Record = { dropbox: DropboxBlock, dspy: DSPyBlock, duckduckgo: DuckDuckGoBlock, + bocha: BoChaBlock, dynamodb: DynamoDBBlock, elasticsearch: ElasticsearchBlock, elevenlabs: ElevenLabsBlock, diff --git a/apps/sim/components/icons.tsx b/apps/sim/components/icons.tsx index 2e1e487780..cac87dbc1d 100644 --- a/apps/sim/components/icons.tsx +++ b/apps/sim/components/icons.tsx @@ -4459,6 +4459,41 @@ export function DuckDuckGoIcon(props: SVGProps) { ) } +export function BoChaIcon(props: SVGProps) { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +) +} + export function RssIcon(props: SVGProps) { return ( = { + id: 'bocha_search', + name: 'BoCha Search', + description: + "Perform AI-powered web searches using BoCha's search API. Returns structured results with titles, URLs, snippets, and optional raw content, optimized for relevance and accuracy.", + version: '1.0.0', + + params: { + query: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The search query to execute (e.g., "latest AI research papers 2024")', + }, + freshness: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Search for web pages within a specified time range(noLimit/oneDay/oneWeek/oneMonth/oneYear/YYYY-MM-DD/YYYY-MM-DD/YYYY-MM-DD..YYYY-MM-DD).', + }, + summary: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: 'Whether to display text summary.', + }, + count: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Maximum number of results (1-50, e.g., 5)', + }, + include: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Specify the search scope by website domains. Multiple domains should be separated by | or ,, with a maximum limit of 100 domains.', + }, + exclude: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Exclude specified websites from search results. Multiple domains should be separated by | or ,, with a maximum limit of 100 domains.', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'BoCha API Key', + }, + }, + + request: { + url: 'https://api.bochaai.com/v1/web-search', + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + body: (params) => { + const body: Record = { + query: params.query, + } + + // Only include optional parameters if explicitly set + if (params.freshness) body.freshness = params.freshness + if (params.summary !== undefined) body.summary = params.summary + if (params.count) body.count = Number(params.count) + if (params.include) body.include = params.include + if (params.exclude) body.exclude = params.exclude + return body + }, + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + return { + success: true, + output: { + query: data.data.queryContext.originalQuery, + results: data.data.webPages.value.map((result: any) => ({ + title: result.name, + url: result.url, + snippet: result.snippet, + })), + }, + } + }, + + outputs: { + query: { type: 'string', description: 'The search query that was executed' }, + results: { + type: 'array', + description: + 'Ranked search results with titles, URLs, content snippets', + items: { + type: 'object', + properties: BOCHA_SEARCH_RESULT_OUTPUT_PROPERTIES, + }, + }, + }, +} diff --git a/apps/sim/tools/bocha/types.ts b/apps/sim/tools/bocha/types.ts new file mode 100644 index 0000000000..873216d06f --- /dev/null +++ b/apps/sim/tools/bocha/types.ts @@ -0,0 +1,38 @@ +import type { OutputProperty, ToolResponse } from '@/tools/types' + +/** + * Output definition for search result items + */ +export const BOCHA_SEARCH_RESULT_OUTPUT_PROPERTIES = { + title: { type: 'string', description: 'Result title' }, + url: { type: 'string', description: 'Result URL' }, + snippet: { type: 'string', description: 'Brief description or content snippet' }, +} as const satisfies Record + + +export interface BoChaSearchResult { + title: string + url: string + snippet: string +} + +export interface BoChaSearchResponse extends ToolResponse { + output: { + results: BoChaSearchResult[] + query: string + } +} + + +export interface BoChaSearchParams { + query: string + freshness: string + summary: boolean + count: number + include: string + exclude: string + apiKey: string +} + + + diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index 6018a6f866..e25b420faf 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -207,6 +207,7 @@ import { } from '@/tools/dropbox' import { chainOfThoughtTool, predictTool, reactTool } from '@/tools/dspy' import { duckduckgoSearchTool } from '@/tools/duckduckgo' +import {bochaSearchTool} from "@/tools/bocha" import { dynamodbDeleteTool, dynamodbGetTool, @@ -2191,6 +2192,7 @@ export const tools: Record = { dropbox_create_shared_link: dropboxCreateSharedLinkTool, dropbox_search: dropboxSearchTool, duckduckgo_search: duckduckgoSearchTool, + bocha_search: bochaSearchTool, dspy_predict: predictTool, dspy_chain_of_thought: chainOfThoughtTool, dspy_react: reactTool,