org.llm4s.toolapi.builtin.search
Search tools for web searches and lookups.
These tools provide web search capabilities using various search engines. All search tools follow the "config at the edge" pattern where configuration is loaded at the application boundary via org.llm4s.config.Llm4sConfig and passed to the tool's create() method.
== Available Tools ==
-
DuckDuckGoSearchTool: Search using DuckDuckGo Instant Answer API
-
Best for definitions, facts, quick lookups
-
No API key required
-
Returns abstracts, related topics, and infobox data
-
Configuration: API URL
-
BraveSearchTool: Search using Brave Search API
-
Comprehensive web search results
-
Requires API key (paid service)
-
Returns web pages, snippets, and metadata
-
Configuration: API key, URL, result count, safe search settings
== Usage Pattern ==
All search tools require configuration to be loaded at the application edge:
Attributes
- Example
-
import org.llm4s.config.Llm4sConfig import org.llm4s.toolapi.builtin.search._ import org.llm4s.toolapi.ToolRegistry // Load DuckDuckGo configuration val duckDuckGoConfig = Llm4sConfig.loadDuckDuckGoSearchTool().getOrElse( throw new RuntimeException("Failed to load DuckDuckGo config") ) val duckDuckGoTool = DuckDuckGoSearchTool.create(duckDuckGoConfig) // Load Brave Search configuration val braveConfig = Llm4sConfig.loadBraveSearchTool().getOrElse( throw new RuntimeException("Failed to load Brave Search config") ) val braveTool = BraveSearchTool.create(braveConfig) // Register tools with the agent val tools = new ToolRegistry(Seq(duckDuckGoTool, braveTool))== Configuration == Configure search tools in your application.conf:
llm4s { tools { duckduckgo { apiUrl = "https://api.duckduckgo.com" } brave { apiKey = "your-api-key" apiUrl = "https://api.search.brave.com/res/v1" count = 10 safeSearch = "moderate" } } }
Members list
Type members
Classlikes
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BraveImageResult.type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BraveNewsResult.type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BraveSearchCategory.type
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
BraveSearchTool.type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BraveVideoResult.type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BraveWebResult.type
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BraveWebSearchResult.type
Configuration for DuckDuckGo search tool.
Configuration for DuckDuckGo search tool.
Value parameters
- maxResults
-
Maximum number of related topics to return.
- safeSearch
-
Whether to enable safe search.
- timeoutMs
-
Request timeout in milliseconds.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
DuckDuckGo search result.
DuckDuckGo search result.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Tool for web searching using DuckDuckGo's Instant Answer API.
Tool for web searching using DuckDuckGo's Instant Answer API.
This tool provides quick answers and definitions without requiring an API key. It's best suited for factual queries, definitions, and quick lookups.
Note: This uses DuckDuckGo's free Instant Answer API which provides:
- Definitions from Wikipedia
- Quick facts
- Related topics
- Disambiguation pages
It does NOT provide full web search results (that would require a paid API).
Architecture: This tool follows the "config at the edge" pattern:
- Configuration is loaded at the application boundary via Llm4sConfig.loadDuckDuckGoSearchTool()
- The loaded DuckDuckGoSearchToolConfig is passed to create() method
- The tool operates with the provided configuration
This keeps the tool implementation pure and testable without direct config dependencies.
Attributes
- Example
-
import org.llm4s.config.Llm4sConfig import org.llm4s.toolapi.builtin.search._ // Load configuration at the application edge val toolConfigResult = Llm4sConfig.loadDuckDuckGoSearchTool() toolConfigResult match { case Right(toolConfig) => // Create the tool with loaded configuration val searchTool = DuckDuckGoSearchTool.create(toolConfig) val tools = new ToolRegistry(Seq(searchTool)) agent.run("What is Scala programming language?", tools) case Left(error) => println(s"Failed to load DuckDuckGo config: $error") }For testing, you can create a config directly:
import org.llm4s.config.DuckDuckGoSearchToolConfig val testConfig = DuckDuckGoSearchToolConfig(apiUrl = "https://api.duckduckgo.com") val searchTool = DuckDuckGoSearchTool.create(testConfig) - Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
DuckDuckGoSearchTool.type
A related topic from web search.
A related topic from web search.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
RelatedTopic.type
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
SafeSearch.type