跳到主要内容

NebulaAIFlow工具组件

工具组件通常通过工具端口连接到智能代理组件。智能代理使用大语言模型(LLMs)作为推理引擎,决定使用哪个已连接的工具组件来解决问题。

在智能代理功能中,工具本质上是代理可以调用的函数,用于执行任务或访问外部资源。 函数被封装为Tool对象,具有代理能够理解的通用接口。 智能代理通过工具注册了解工具,通常在代理初始化时提供可用工具列表。Tool对象的描述告诉代理该工具的功能。

然后,代理使用连接的大语言模型对问题进行推理,决定哪个工具最适合完成任务。

在流程中使用工具

工具组件通常通过工具端口连接到智能代理组件。

简单代理入门项目使用URL和计算器工具连接到智能代理组件来回答用户的问题。OpenAI大语言模型作为代理的大脑,决定使用哪个工具。

简单代理入门流程

要将组件转换为代理可以使用的工具,需要在组件中启用工具模式。启用工具模式会修改组件输入以接受来自代理的调用。 如果要连接到代理的组件没有工具模式选项,您可以修改组件的输入使其成为工具。 有关示例,请参阅将任意组件转换为工具

arXiv工具

此组件用于搜索和检索来自arXiv.org的论文。

输入参数

名称显示名称说明
search_query搜索查询arXiv论文的搜索查询(例如,quantum computing
search_type搜索字段要搜索的字段
max_results最大结果数要返回的最大结果数量

输出参数

名称显示名称说明
papers论文检索到的arXiv论文列表

Astra DB Tool

The Astra DB Tool allows agents to connect to and query data from Astra DB collections.

Inputs

NameTypeDescription
Tool NameStringThe name used to reference the tool in the agent's prompt.
Tool DescriptionStringA brief description of the tool. This helps the model decide when to use it.
Collection NameStringThe name of the Astra DB collection to query.
TokenSecretStringThe authentication token for accessing Astra DB.
API EndpointStringThe Astra DB API endpoint.
Projection FieldsStringThe attributes to return, separated by commas. Default: "*".
Tool ParametersDictParameters the model needs to fill to execute the tool. For required parameters, use an exclamation mark (for example, !customer_id).
Static FiltersDictAttribute-value pairs used to filter query results.
LimitStringThe number of documents to return.

Outputs

The Data output is primarily used when directly querying Astra DB, while the Tool output is used when integrating with LangChain agents or chains.

NameTypeDescription
DataList[Data]A list of Data objects containing the query results from Astra DB. Each Data object contains the document fields specified by the projection attributes. Limited by the number_of_results parameter.
ToolStructuredToolA LangChain StructuredTool object that can be used in agent workflows. Contains the tool name, description, argument schema based on tool parameters, and the query function.

Astra DB CQL Tool

The Astra DB CQL Tool allows agents to query data from CQL tables in Astra DB.

The main difference between this tool and the Astra DB Tool is that this tool is specifically designed for CQL tables and requires partition keys for querying, while also supporting clustering keys for more specific queries.

Inputs

NameTypeDescription
Tool NameStringThe name used to reference the tool in the agent's prompt.
Tool DescriptionStringA brief description of the tool to guide the model in using it.
KeyspaceStringThe name of the keyspace.
Table NameStringThe name of the Astra DB CQL table to query.
TokenSecretStringThe authentication token for Astra DB.
API EndpointStringThe Astra DB API endpoint.
Projection FieldsStringThe attributes to return, separated by commas. Default: "*".
Partition KeysDictRequired parameters that the model must fill to query the tool.
Clustering KeysDictOptional parameters the model can fill to refine the query. Required parameters should be marked with an exclamation mark (for example, !customer_id).
Static FiltersDictAttribute-value pairs used to filter query results.
LimitStringThe number of records to return.

Outputs

NameTypeDescription
DataList[Data]A list of Data objects containing the query results from the Astra DB CQL table. Each Data object contains the document fields specified by the projection fields. Limited by the number_of_results parameter.
ToolStructuredToolA LangChain StructuredTool object that can be used in agent workflows. Contains the tool name, description, argument schema based on partition and clustering keys, and the query function.

Bing Search API

This component allows you to call the Bing Search API.

Inputs

NameTypeDescription
bing_subscription_keySecretStringBing API subscription key
input_valueStringSearch query input
bing_search_urlStringCustom Bing Search URL (optional)
kIntegerNumber of search results to return

Outputs

NameTypeDescription
resultsList[Data]List of search results
toolToolBing Search tool for use in LangChain

Calculator Tool

This component creates a tool for performing basic arithmetic operations on a given expression.

Inputs

NameTypeDescription
expressionStringThe arithmetic expression to evaluate (for example, 4*4*(33/22)+12-20).

Outputs

NameTypeDescription
resultToolCalculator tool for use in LangChain

This component allows you to evaluate basic arithmetic expressions. It supports addition, subtraction, multiplication, division, and exponentiation. The tool uses a secure evaluation method that prevents the execution of arbitrary Python code.

Combinatorial Reasoner

This component runs Icosa's Combinatorial Reasoning (CR) pipeline on an input to create an optimized prompt with embedded reasons. Sign up for access here: https://forms.gle/oWNv2NKjBNaqqvCx6

Inputs

NameDisplay NameDescription
promptPromptInput to run CR on
openai_api_keyOpenAI API KeyOpenAI API key for authentication
usernameUsernameUsername for Icosa API authentication
passwordPasswordPassword for Icosa API authentication
model_nameModel NameOpenAI LLM to use for reason generation

Outputs

NameDisplay NameDescription
optimized_promptOptimized PromptA message object containing the optimized prompt
reasonsSelected ReasonsA list of the selected reasons that are embedded in the optimized prompt

This component performs web searches using the DuckDuckGo search engine with result-limiting capabilities.

Inputs

NameDisplay NameInfo
input_valueSearch QueryThe search query to execute with DuckDuckGo.
max_resultsMax ResultsThe maximum number of search results to return. Default: 5.
max_snippet_lengthMax Snippet LengthThe maximum length of each result snippet. Default: 100.

Outputs

NameDisplay NameInfo
dataDataList of search results as Data objects containing snippets and full content.
textTextSearch results formatted as a single text string.

This component provides an [https://exa.ai/](Exa Search) toolkit for search and content retrieval.

Inputs

NameDisplay NameInfo
metaphor_api_keyExa Search API KeyAPI key for Exa Search (entered as a password)
use_autopromptUse AutopromptWhether to use autoprompt feature (default: true)
search_num_resultsSearch Number of ResultsNumber of results to return for search (default: 5)
similar_num_resultsSimilar Number of ResultsNumber of similar results to return (default: 5)

Outputs

NameDisplay NameInfo
toolsToolsList of search tools provided by the toolkit

Glean Search API

This component allows you to call the Glean Search API.

Inputs

NameTypeDescription
glean_api_urlStringURL of the Glean API
glean_access_tokenSecretStringAccess token for Glean API authentication
queryStringSearch query input
page_sizeIntegerNumber of results per page (default: 10)
request_optionsDictAdditional options for the API request (optional)

Outputs

NameTypeDescription
resultsList[Data]List of search results
toolToolGlean Search tool for use in LangChain

Google Search API

This component allows you to call the Google Search API.

Inputs

NameTypeDescription
google_api_keySecretStringGoogle API key for authentication
google_cse_idSecretStringGoogle Custom Search Engine ID
input_valueStringSearch query input
kIntegerNumber of search results to return

Outputs

NameTypeDescription
resultsList[Data]List of search results
toolToolGoogle Search tool for use in LangChain

Google Serper API

This component allows you to call the Serper.dev Google Search API.

Inputs

NameTypeDescription
serper_api_keySecretStringAPI key for Serper.dev authentication
input_valueStringSearch query input
kIntegerNumber of search results to return

Outputs

NameTypeDescription
resultsList[Data]List of search results
toolToolGoogle Serper search tool for use in LangChain

MCP server

This component connects to a Model Context Protocol (MCP) server and exposes the MCP server's tools as tools.

In addition to being an MCP client that can leverage MCP servers, NebulaAIFlow is also an MCP server that exposes flows as tools through the /api/v1/mcp/sse API endpoint.

To use the MCP server component with an agent component, follow these steps:

  1. Add the MCP server component to your workflow.
  2. In the MCP server component, in the MCP Command field, enter the command to start your MCP server. For example, to start a Fetch server, the command is:

_10
uvx mcp-server-fetch

uvx is included with uv in the NebulaAIFlow package. For an example of starting npx MCP servers, see Connect an Astra DB MCP server.

  1. Click to get the server's list of Tools.
  2. In the Tool field, select the server tool you want the component to use. The available fields change based on the selected tool. For information on the parameters, see the MCP server's documentation.
  3. In the MCP server component, enable Tool mode. Connect the MCP server component's Toolset port to an Agent component's Tools port.

The flow looks similar to this: MCP server component

  1. Open the Playground. Ask the agent to summarize recent tech news. The agent calls the MCP server function fetch and returns the summary. This confirms the MCP server is connected, and its tools are being used in NebulaAIFlow.

MCP Server-Sent Events (SSE) mode

  1. In the MCP Server component, select SSE. A default address appears in the MCP SSE URL field.
  2. In the MCP SSE URL field, modify the default address to point at the SSE endpoint of the NebulaAIFlow server you're currently running. The default value is http://localhost:7860/api/v1/mcp/sse.
  3. In the MCP Server component, click to retrieve the server's list of Tools.
  4. Click the Tools field. All of your flows are listed as tools.
  5. Enable Tool Mode, and then connect the MCP Server component to an agent component's tool port. The flow looks like this: MCP server component
  6. Open the Playground and chat with your tool. The agent chooses the correct tool based on your query.

Inputs

NameTypeDescription
commandStringMCP command (default: uvx mcp-sse-shim@latest)

Outputs

NameTypeDescription
toolsList[Tool]List of tools exposed by the MCP server

Python Code Structured Tool

This component creates a structured tool from Python code using a dataclass.

The component dynamically updates its configuration based on the provided Python code, allowing for custom function arguments and descriptions.

Inputs

NameTypeDescription
tool_codeStringPython code for the tool's dataclass
tool_nameStringName of the tool
tool_descriptionStringDescription of the tool
return_directBooleanWhether to return the function output directly
tool_functionStringSelected function for the tool
global_variablesDictGlobal variables or data for the tool

Outputs

NameTypeDescription
result_toolTool │ Structured tool created from the Python code

Python REPL Tool

This component creates a Python REPL (Read-Eval-Print Loop) tool for executing Python code.

Inputs

NameTypeDescription
nameStringThe name of the tool (default: "python_repl")
descriptionStringA description of the tool's functionality
global_importsList[String]List of modules to import globally (default: ["math"])

Outputs

NameTypeDescription
toolToolPython REPL tool for use in LangChain

Retriever Tool

This component creates a tool for interacting with a retriever in LangChain.

Inputs

NameTypeDescription
retrieverBaseRetrieverThe retriever to interact with
nameStringThe name of the tool
descriptionStringA description of the tool's functionality

Outputs

NameTypeDescription
toolToolRetriever tool for use in LangChain

SearXNG Search Tool

This component creates a tool for searching using SearXNG, a metasearch engine.

Inputs

NameTypeDescription
urlStringThe URL of the SearXNG instance
max_resultsIntegerMaximum number of results to return
categoriesList[String]Categories to search in
languageStringLanguage for the search results

Outputs

NameTypeDescription
result_toolToolSearXNG search tool for use in LangChain

Search API

This component calls the searchapi.io API. It can be used to search the web for information.

For more information, see the SearchAPI documentation.

Inputs

NameDisplay NameInfo
engineEngineThe search engine to use (default: "google")
api_keySearchAPI API KeyThe API key for authenticating with SearchAPI
input_valueInputThe search query or input for the API call
search_paramsSearch parametersAdditional parameters for customizing the search

Outputs

NameDisplay NameInfo
dataSearch ResultsList of Data objects containing search results
toolSearch API ToolA Tool object for use in LangChain workflows

Serp Search API

This component creates a tool for searching using the Serp API.

Inputs

NameTypeDescription
serpapi_api_keySecretStringAPI key for Serp API authentication
input_valueStringSearch query input
search_paramsDictAdditional search parameters (optional)

Outputs

NameTypeDescription
resultsList[Data]List of search results
toolToolSerp API search tool for use in LangChain

This component performs searches using the Tavily AI search engine, which is optimized for LLMs and RAG applications.

Inputs

NameDisplay NameInfo
api_keyTavily API KeyYour Tavily API Key.
querySearch QueryThe search query you want to execute with Tavily.
search_depthSearch DepthThe depth of the search.
topicSearch TopicThe category of the search.
max_resultsMax ResultsThe maximum number of search results to return.
include_imagesInclude ImagesInclude a list of query-related images in the response.
include_answerInclude AnswerInclude a short answer to original query.

Outputs

NameDisplay NameInfo
dataDataThe search results as a list of Data objects.
textTextThe search results formatted as a text string.

Wikidata

This component performs a search using the Wikidata API.

Inputs

NameDisplay NameInfo
queryQueryThe text query for similarity search on Wikidata.

Outputs

NameDisplay NameInfo
dataDataThe search results from Wikidata API as a list of Data objects.
textMessageThe search results formatted as a text message.

Wikipedia API

This component creates a tool for searching and retrieving information from Wikipedia.

Inputs

NameTypeDescription
input_valueStringSearch query input
langStringLanguage code for Wikipedia (default: "en")
kIntegerNumber of results to return
load_all_available_metaBooleanWhether to load all available metadata (advanced)
doc_content_chars_maxIntegerMaximum number of characters for document content (advanced)

Outputs

NameTypeDescription
resultsList[Data]List of Wikipedia search results
toolToolWikipedia search tool for use in LangChain

Wolfram Alpha API

This component creates a tool for querying the Wolfram Alpha API.

Inputs

NameTypeDescription
input_valueStringQuery input for Wolfram Alpha
app_idSecretStringWolfram Alpha API App ID

Outputs

NameTypeDescription
resultsList[Data]List containing the Wolfram Alpha API response
toolToolWolfram Alpha API tool for use in LangChain

Yahoo Finance News Tool

This component creates a tool for retrieving news from Yahoo Finance.

Inputs

This component does not have any input parameters.

Outputs

NameTypeDescription
toolToolYahoo Finance News tool for use in LangChain