tool_tavily

command
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 9 Imported by: 0

README

Tavily Search Agent Example

This example demonstrates how to use the Tavily Search tool with a LangGraph ReAct Agent.

Prerequisites

You need a Tavily API key and an OpenAI-compatible API key (e.g., DeepSeek, OpenAI).

Set the environment variables:

export TAVILY_API_KEY=your_tavily_key
export OPENAI_API_KEY=your_openai_key
# OR
export DEEPSEEK_API_KEY=your_deepseek_key

Usage

Run the example:

go run main.go

How it Works

  1. Initialize LLM: Connects to the LLM (defaulting to DeepSeek-V3).
  2. Initialize Tool: Creates the Tavily search tool.
  3. Create Agent: Uses prebuilt.CreateReactAgent to build a graph-based agent that has access to the tool.
  4. Execute: The agent receives a query, decides to use the Tavily tool to find information, and then synthesizes the answer.

Code Overview

// Create the agent with LLM and Tools
agent, err := prebuilt.CreateReactAgent(llm, []tools.Tool{tavilyTool})

// Invoke the agent
response, err := agent.Invoke(ctx, inputs)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL