DuckDuckGoSearchTool
org.llm4s.toolapi.builtin.search.DuckDuckGoSearchTool
object DuckDuckGoSearchTool
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) - Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
DuckDuckGoSearchTool.type
Members list
In this article