[UPDATE] Valyu 0.2.0 langchain package (#31363)

docs: update Valyu integration notebooks to reflect current
langchain-valyu package implementation

Updated the Valyu integration documentation notebooks to align with the
current implementation of the langchain-valyu package. The changes
include:

- Updated ValyuContextRetriever to ValyuRetriever class name
- Changed parameter name from similarity_threshold to
relevance_threshold
- Removed query_rewrite parameter from search tool examples
- Added start_date and end_date parameters for time filtering
- Updated default values to match current implementation
(relevance_threshold: 0.5)
- Enhanced parameter documentation with proper descriptions and
constraints
- Updated section titles to reflect "Deep Search" functionality
This commit is contained in:
Alexander Ng 2025-05-27 21:06:05 +01:00 committed by GitHub
parent 5a13ad02ca
commit 60119b9ba6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 23 deletions

View File

@ -4,13 +4,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# ValyuContext\n",
"\n",
"# Valyu Deep Search\n",
">[Valyu](https://www.valyu.network/) allows AI applications and agents to search the internet and proprietary data sources for relevant LLM ready information.\n",
"\n",
"This notebook goes over how to use Valyu in LangChain.\n",
"\n",
"First, get an Valyu API key and add it as an environment variable. Get $10 free credit by [signing up here](https://exchange.valyu.network/).\n",
"First, get an Valyu API key and add it as an environment variable. Get $10 free credit by [signing up here](https://platform.valyu.network/).\n",
"\n",
"## Setup\n",
"\n",
@ -43,12 +42,20 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain_valyu import ValyuContextRetriever\n",
"from langchain_valyu import ValyuRetriever\n",
"\n",
"valyu_api_key = \"YOUR API KEY\"\n",
"\n",
"# Create a new instance of the ValyuContextRetriever\n",
"valyu_retriever = ValyuContextRetriever(valyu_api_key=valyu_api_key)\n",
"# Create a new instance of the ValyuRetriever\n",
"valyu_retriever = ValyuRetriever(\n",
" k=5,\n",
" search_type=\"all\",\n",
" relevance_threshold=0.5,\n",
" max_price=20.0,\n",
" start_date=\"2024-01-01\",\n",
" end_date=\"2024-12-31\",\n",
" valyu_api_key=valyu_api_key,\n",
")\n",
"\n",
"# Search for a query and save the results\n",
"docs = valyu_retriever.invoke(\"What are the benefits of renewable energy?\")\n",
@ -84,9 +91,10 @@
" query=\"What are agentic search-enhanced large reasoning models?\",\n",
" search_type=\"all\",\n",
" max_num_results=5,\n",
" similarity_threshold=0.4,\n",
" query_rewrite=False,\n",
" relevance_threshold=0.5,\n",
" max_price=20.0,\n",
" start_date=\"2024-01-01\",\n",
" end_date=\"2024-12-31\",\n",
")\n",
"\n",
"print(\"Search Results:\", search_results)"

View File

@ -8,9 +8,9 @@
"\n",
">[Valyu](https://www.valyu.network/) allows AI applications and agents to search the internet and proprietary data sources for relevant LLM ready information.\n",
"\n",
"This notebook goes over how to use Valyu context tool in LangChain.\n",
"This notebook goes over how to use Valyu deep search tool in LangChain.\n",
"\n",
"First, get an Valyu API key and add it as an environment variable. Get $10 free credit by [signing up here](https://exchange.valyu.network/).\n",
"First, get an Valyu API key and add it as an environment variable. Get $10 free credit by [signing up here](https://platform.valyu.network/).\n",
"\n",
"## Setup\n",
"\n",
@ -57,22 +57,25 @@
" The number of top results to return for each query.\n",
"\n",
"- `search_type: str = \"all\"` \n",
" The type of search to perform. Options may include \"all\", \"web\", \"proprietary\", etc., depending on your use case.\n",
" The type of search to perform: 'all', 'proprietary', or 'web'. Defaults to 'all'.\n",
"\n",
"- `similarity_threshold: float = 0.4` \n",
" The minimum similarity score (between 0 and 1) required for a document to be considered relevant.\n",
"\n",
"- `query_rewrite: bool = False` \n",
" Whether to enable automatic rewriting of the query to improve search results.\n",
"- `relevance_threshold: float = 0.5` \n",
" The minimum relevance score (between 0 and 1) required for a document to be considered relevant. Defaults to 0.5.\n",
" \n",
"- `max_price: float = 20.0`\n",
" The maximum price (in USD) you are willing to spend per query.\n",
" The maximum price (in USD) you are willing to spend per query. Defaults to 20.0.\n",
"\n",
"- `start_date: Optional[str] = None`\n",
" Start date for time filtering in YYYY-MM-DD format (optional).\n",
"\n",
"- `end_date: Optional[str] = None`\n",
" End date for time filtering in YYYY-MM-DD format (optional).\n",
"\n",
"- `client: Optional[Valyu] = None` \n",
" An optional custom Valyu client instance. If not provided, a new client will be created internally.\n",
" \n",
"- `valyu_api_key: Optional[str] = None` \n",
" Your Valyu API key. If not provided, the retriever will look for the `VALYU_API_KEY` environment variable.\n"
" Your Valyu API key. If not provided, the retriever will look for the `VALYU_API_KEY` environment variable."
]
},
{
@ -81,14 +84,15 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain_valyu import ValyuContextRetriever\n",
"from langchain_valyu import ValyuRetriever\n",
"\n",
"retriever = ValyuContextRetriever(\n",
"retriever = ValyuRetriever(\n",
" k=5,\n",
" search_type=\"all\",\n",
" similarity_threshold=0.4,\n",
" query_rewrite=False,\n",
" relevance_threshold=0.5,\n",
" max_price=20.0,\n",
" start_date=\"2024-01-01\",\n",
" end_date=\"2024-12-31\",\n",
" client=None,\n",
" valyu_api_key=os.environ[\"VALYU_API_KEY\"],\n",
")"

View File

@ -10,7 +10,7 @@
"\n",
"This notebook goes over how to use Valyu context tool in LangChain.\n",
"\n",
"First, get an Valyu API key and add it as an environment variable. Get $10 free credit by [signing up here](https://exchange.valyu.network/).\n",
"First, get an Valyu API key and add it as an environment variable. Get $10 free credit by [signing up here](https://platform.valyu.network/).\n",
"\n",
"## Overview\n",
"\n",