mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 23:00:00 +00:00
xai: document live search feature (#31381)
This commit is contained in:
parent
5bff018951
commit
6ecc85c163
@ -61,7 +61,9 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "72ee0c4b-9764-423a-9dbf-95129e185210",
|
||||
"metadata": {},
|
||||
"source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"
|
||||
"source": [
|
||||
"To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
@ -295,6 +297,47 @@
|
||||
"ai_msg"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "00297c44-9bd6-4f1f-b364-2a7ff77090fd",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Live Search\n",
|
||||
"\n",
|
||||
"xAI supports a [Live Search](https://docs.x.ai/docs/guides/live-search) feature that enables Grok to ground its answers using results from web searches:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d39cd1a4-80f2-48b2-8a74-3856d7706973",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_xai import ChatXAI\n",
|
||||
"\n",
|
||||
"llm = ChatXAI(\n",
|
||||
" model=\"grok-3-latest\",\n",
|
||||
" search_parameters={\n",
|
||||
" \"mode\": \"auto\",\n",
|
||||
" # Example optional parameters below:\n",
|
||||
" \"max_search_results\": 3,\n",
|
||||
" \"from_date\": \"2025-05-26\",\n",
|
||||
" \"to_date\": \"2025-05-27\",\n",
|
||||
" },\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"llm.invoke(\"Provide me a digest of world news in the last 24 hours.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "cc62dc4d-e3ce-4b8b-8b94-d3e2e1a48bd1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"See [xAI docs](https://docs.x.ai/docs/guides/live-search) for the full set of web search options."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3a5bb5ca-c3ae-4a58-be67-2cd18574b9a3",
|
||||
@ -322,7 +365,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.9"
|
||||
"version": "3.10.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -213,6 +213,26 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
rating=7
|
||||
)
|
||||
|
||||
Live Search:
|
||||
xAI supports a `Live Search <https://docs.x.ai/docs/guides/live-search>`_
|
||||
feature that enables Grok to ground its answers using results from web searches.
|
||||
|
||||
.. code-block:: python
|
||||
from langchain_xai import ChatXAI
|
||||
|
||||
llm = ChatXAI(
|
||||
model="grok-3-latest",
|
||||
search_parameters={
|
||||
"mode": "auto",
|
||||
# Example optional parameters below:
|
||||
"max_search_results": 3,
|
||||
"from_date": "2025-05-26",
|
||||
"to_date": "2025-05-27",
|
||||
}
|
||||
)
|
||||
|
||||
llm.invoke("Provide me a digest of world news in the last 24 hours.")
|
||||
|
||||
Token usage:
|
||||
.. code-block:: python
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user