langchain-valyu
This package contains the LangChain integration with Valyu
Installation
pip install -U langchain-valyu
Note: This package requires valyu >= 2.0.0 for the updated search API.
And you should configure credentials by setting the following environment variable:
VALYU_API_KEY(required): Your Valyu API key.
Valyu Search Tool
You can use ValyuSearchTool directly for search operations:
import os
from langchain_valyu import ValyuSearchTool
# Set your API key
os.environ["VALYU_API_KEY"] = "your-api-key-here"
# Initialize the search tool
tool = ValyuSearchTool()
# Perform a search
search_results = tool._run(
query="What are agentic search-enhanced large reasoning models?",
search_type="all", # "all", "web", or "proprietary"
max_num_results=5,
relevance_threshold=0.5,
max_price=30.0
)
print("Search Results:", search_results.results)
Valyu Retriever
You can retrieve search results from Valyu's deep search API as documents:
from langchain_valyu import ValyuRetriever
# Initialize retriever
retriever = ValyuRetriever(
k=5, # Number of results
search_type="proprietary",
relevance_threshold=0.6,
max_price=30.0
)
# Search for a query and get documents
docs = retriever.get_relevant_documents("What are the benefits of renewable energy?")
# Print the results
for doc in docs:
print(f"Title: {doc.metadata['title']}")
print(f"Content: {doc.page_content[:200]}...")
print(f"Source: {doc.metadata['url']}")
print("---")
Agent Integration
The most powerful way to use Valyu is within LangChain agents, where the AI can dynamically decide when and how to search:
import os
from langchain_valyu import ValyuSearchTool
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent
from langchain_core.messages import HumanMessage
# Set API keys
os.environ["VALYU_API_KEY"] = "your-valyu-api-key"
os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-api-key"
# Initialize components
llm = ChatAnthropic(model="claude-3-5-sonnet-20241022")
valyu_search_tool = ValyuSearchTool()
# Create agent with Valyu search capability
agent = create_react_agent(llm, [valyu_search_tool])
# Use the agent
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": [HumanMessage(content=user_input)]},
stream_mode="values",
):
step["messages"][-1].pretty_print()
Academic Research Example
Configure for academic research with proprietary data sources:
from langchain_valyu import ValyuSearchTool
# Configure for academic research
academic_tool = ValyuSearchTool()
# Search academic sources specifically
academic_results = academic_tool._run(
query="CRISPR gene editing safety protocols",
search_type="proprietary", # Focus on academic datasets
max_num_results=8,
relevance_threshold=0.6,
)
print("Academic Sources Found:", len(academic_results.results))
for result in academic_results.results:
print(f"Title: {result['title']}")
print(f"Source: {result['source']}")
print(f"Relevance: {result['relevance_score']}")
print("---")
You can learn more about our API from our docs.
Metadata
Release files for langchain-valyu 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_valyu-0.3.5.tar.gz | 6.2 kB | Without provenance | Details for langchain_valyu-0.3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_valyu-0.3.5-py3-none-any.whl | Python 3 | none | any | Details for langchain_valyu-0.3.5-py3-none-any.whl |
Total release size: 14.1 kB
Release files / langchain_valyu-0.3.5.tar.gz
| Download URL | langchain_valyu-0.3.5.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2518cc34c2fb4501b37d4c980c056a9fc0f9e98df0c895e969bfd54bfa41cbf
|
|
BLAKE2b-256 checksum How to use checksums |
b5a142d79b2d108c8f2d88a984f593c402f629e961c0b17d983609f1fef9a6c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / langchain_valyu-0.3.5-py3-none-any.whl
| Download URL | langchain_valyu-0.3.5-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27cce13558dbb494ce6467119034e3a89cbcedd868b8a3829eb3b32ddcde5db1
|
|
BLAKE2b-256 checksum How to use checksums |
39afc044a4dc92291ae8bb3fb40ed724b9508ba56e4f36d0baae1120da7f14a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for langchain-valyu 0.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.