A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/tools/valyu_search below:

ValyuContext | 🦜️🔗 LangChain

ValyuContext

Valyu allows AI applications and agents to search the internet and proprietary data sources for relevant LLM ready information.

This notebook goes over how to use Valyu context tool in LangChain.

First, get an Valyu API key and add it as an environment variable. Get $10 free credit by signing up here.

Overview Integration details Setup

The integration lives in the langchain-valyu package.

%pip install -qU langchain-valyu

In order to use the package, you will also need to set the VALYU_API_KEY environment variable to your Valyu API key.

import getpass
import os

if not os.environ.get("VALYU_API_KEY"):
os.environ["VALYU_API_KEY"] = getpass.getpass("Valyu API key:\n")
Instantiation

Here we show how to instantiate an instance of the Valyu search tool. This tool allows you to complete search queries using Valyu's Context API endpoint.

from langchain_valyu import ValyuSearchTool

tool = ValyuSearchTool()
Invocation Invoke directly with args

The Valyu search tool accepts the following arguments during invocation:

For reliability and performance reasons, certain parameters may be required or restricted. See the Valyu API documentation for details.

search_results = tool._run(
query="What are agentic search-enhanced large reasoning models?",
search_type="all",
max_num_results=5,
similarity_threshold=0.4,
query_rewrite=False,
max_price=20.0,
)

print("Search Results:", search_results)
Use within an agent

We can use our tools directly with an agent executor by binding the tool to the agent. This gives the agent the ability to dynamically set the available arguments to the Valyu search tool.

if not os.environ.get("OPENAI_API_KEY"):
os.environ["OPENAI_API_KEY"] = getpass.getpass("OPENAI_API_KEY:\n")
from langchain_valyu import ValyuSearchTool
from langgraph.prebuilt import create_react_agent

valyu_search_tool = ValyuSearchTool()

agent = create_react_agent(llm, [valyu_search_tool])

user_input = "What are the key factors driving recent stock market volatility, and how do macroeconomic indicators influence equity prices across different sectors?"

for step in agent.stream(
{"messages": user_input},
stream_mode="values",
):
step["messages"][-1].pretty_print()
API reference

For detailed documentation of all Valyu Context API features and configurations head to the API reference: https://docs.valyu.network/overview


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4