diff --git a/libs/partners/xai/pyproject.toml b/libs/partners/xai/pyproject.toml index e17c3dc7675..2ec05ed4666 100644 --- a/libs/partners/xai/pyproject.toml +++ b/libs/partners/xai/pyproject.toml @@ -9,11 +9,11 @@ license = { text = "MIT" } readme = "README.md" authors = [] -version = "1.2.1" +version = "1.2.2" requires-python = ">=3.10.0,<4.0.0" dependencies = [ - "langchain-openai>=1.1.6,<2.0.0", - "langchain-core>=1.2.6,<2.0.0", + "langchain-openai>=1.1.7,<2.0.0", + "langchain-core>=1.2.7,<2.0.0", "requests>=2.0.0,<3.0.0", "aiohttp>=3.9.1,<4.0.0", ] diff --git a/libs/partners/xai/tests/integration_tests/test_chat_models.py b/libs/partners/xai/tests/integration_tests/test_chat_models.py index 6a192b5dc99..64c06c6d6d7 100644 --- a/libs/partners/xai/tests/integration_tests/test_chat_models.py +++ b/libs/partners/xai/tests/integration_tests/test_chat_models.py @@ -95,21 +95,21 @@ def test_reasoning(output_version: Literal["", "v1"]) -> None: def test_web_search() -> None: - llm = ChatXAI( - model=MODEL_NAME, - search_parameters={"mode": "on", "max_search_results": 3}, - ) + llm = ChatXAI(model=MODEL_NAME).bind_tools([{"type": "web_search"}]) # Test invoke - response = llm.invoke("Provide me a digest of world news in the last 24 hours.") + response = llm.invoke("Look up the current time in Boston, MA.") assert response.content - assert response.additional_kwargs["citations"] - assert len(response.additional_kwargs["citations"]) <= 3 + content_types = {block["type"] for block in response.content_blocks} + assert content_types == {"server_tool_call", "server_tool_result", "text"} + assert response.content_blocks[0]["name"] == "web_search" # type: ignore[typeddict-item] # Test streaming - full = None - for chunk in llm.stream("Provide me a digest of world news in the last 24 hours."): + full: AIMessageChunk | None = None + for chunk in llm.stream("Look up the current time in Boston, MA."): + assert isinstance(chunk, AIMessageChunk) full = chunk if full is None else full + chunk assert isinstance(full, AIMessageChunk) - assert full.additional_kwargs["citations"] - assert len(full.additional_kwargs["citations"]) <= 3 + content_types = {block["type"] for block in full.content_blocks} + assert content_types == {"server_tool_call", "server_tool_result", "text"} + assert full.content_blocks[0]["name"] == "web_search" # type: ignore[typeddict-item] diff --git a/libs/partners/xai/uv.lock b/libs/partners/xai/uv.lock index c7752b71c60..22caabd6512 100644 --- a/libs/partners/xai/uv.lock +++ b/libs/partners/xai/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.10.0, <4.0.0" resolution-markers = [ "python_full_version >= '3.13' and platform_python_implementation == 'PyPy'", @@ -672,7 +672,7 @@ dependencies = [ requires-dist = [ { name = "jsonpatch", specifier = ">=1.33.0,<2.0.0" }, { name = "langsmith", specifier = ">=0.3.45,<1.0.0" }, - { name = "packaging", specifier = ">=23.2.0,<26.0.0" }, + { name = "packaging", specifier = ">=23.2.0" }, { name = "pydantic", specifier = ">=2.7.4,<3.0.0" }, { name = "pyyaml", specifier = ">=5.3.0,<7.0.0" }, { name = "tenacity", specifier = ">=8.1.0,!=8.4.0,<10.0.0" }, @@ -684,7 +684,7 @@ requires-dist = [ dev = [ { name = "grandalf", specifier = ">=0.8.0,<1.0.0" }, { name = "jupyter", specifier = ">=1.0.0,<2.0.0" }, - { name = "setuptools", specifier = ">=67.6.1,<68.0.0" }, + { name = "setuptools", specifier = ">=67.6.1,<79.0.0" }, ] lint = [{ name = "ruff", specifier = ">=0.14.11,<0.15.0" }] test = [ @@ -810,7 +810,7 @@ typing = [ [[package]] name = "langchain-xai" -version = "1.2.1" +version = "1.2.2" source = { editable = "." } dependencies = [ { name = "aiohttp" },