Add LangChain TinyFish integration#14
Conversation
Bumps the TinyFish Python SDK dependency to 0.2.5 and exposes SDK-backed LangChain tools for web search, content fetch, and browser session creation. Updates package metadata, README examples, unit coverage, and adds LangChain CI plus PyPI trusted-publishing workflows.
b9cc376 to
46fedc9
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
langchain/tests/integration_tests/test_standard.py (1)
12-27:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd API-key skip guard for this integration harness.
This integration suite currently lacks the
TINYFISH_API_KEYskip condition used in the other integration tests, so it can fail in environments where secrets are intentionally absent.Proposed patch
from __future__ import annotations +import os from typing import Any +import pytest from langchain_tests.integration_tests import ToolsIntegrationTests from langchain_tinyfish import TinyFishWebAutomation +skip_no_key = pytest.mark.skipif( + not os.environ.get("TINYFISH_API_KEY"), + reason="TINYFISH_API_KEY not set", +) + +@skip_no_key class TestTinyFishToolIntegration(ToolsIntegrationTests):🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@langchain/tests/integration_tests/test_standard.py` around lines 12 - 27, The TestTinyFishToolIntegration class lacks the environment-key skip guard used in other integration tests; add a skip condition that checks for the TINYFISH_API_KEY env var and skips the whole class when it's missing (e.g., using pytestmark = pytest.mark.skipif(os.environ.get("TINYFISH_API_KEY") is None, reason="TINYFISH_API_KEY not set") or an equivalent pytest.skip mechanism). Update the top of the test class TestTinyFishToolIntegration so the guard runs before any tests or property access, and import or reference pytest and os as needed to implement the check.
🧹 Nitpick comments (2)
langchain/tests/unit_tests/test_packaging.py (1)
14-16: ⚡ Quick winMake the tinyfish floor check resilient to additional constraints.
Line 16 requires an exact string match, so a valid change like
tinyfish>=0.2.5,<1would fail this test unnecessarily.💡 Suggested fix
dependencies = pyproject["project"]["dependencies"] - - assert "tinyfish>=0.2.5" in dependencies + tinyfish_dep = next((dep for dep in dependencies if dep.startswith("tinyfish")), None) + assert tinyfish_dep is not None + assert ">=0.2.5" in tinyfish_dep🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@langchain/tests/unit_tests/test_packaging.py` around lines 14 - 16, The test currently asserts an exact string match against dependencies, which fails when extra version specifiers are present; update the assertion that references the dependencies variable in test_packaging.py to check that at least one dependency entry corresponds to tinyfish and includes the minimum floor ">=0.2.5" (for example by using any(...) over dependencies to find an entry that starts with "tinyfish" or matches the package name and contains ">=0.2.5"), so the test accepts entries like "tinyfish>=0.2.5,<1"..github/workflows/langchain-ci.yml (1)
35-39: ⚡ Quick winAdd a packaging build smoke-check in CI.
The workflow validates lint/tests but skips
python -m build, so packaging breakages can slip through until release workflows.💡 Suggested fix
- run: python -m pip install -e . -r requirements-dev.txt @@ - run: make test + - run: python -m pip install build + - run: python -m build🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/langchain-ci.yml around lines 35 - 39, Add a packaging smoke-check step to the CI by inserting a new job step that runs package build (e.g., install the build tool and invoke python -m build) after installing deps and before/after lint/tests; specifically ensure the workflow runs something like `python -m pip install build` (or include build in requirements-dev) and then `python -m build` so packaging errors are surfaced in CI—update the workflow steps adjacent to the existing `python -m pip install -e . -r requirements-dev.txt`, `make lint`, and `make test` commands.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@langchain/langchain_tinyfish/tool.py`:
- Around line 326-340: The _run and _arun methods currently forward any number
of URLs to api_wrapper.fetch despite TinyFishFetchInput documenting 1–10 URLs;
add a fast pre-call validation in both TinyFishTool._run and TinyFishTool._arun
that checks len(urls) is between 1 and 10 and raise a clear ValueError (e.g.
"urls must contain between 1 and 10 items") before calling
self.api_wrapper.fetch; reference the TinyFishFetchInput contract and ensure the
same check and error message are applied to both synchronous (_run) and
asynchronous (_arun) paths so invalid payloads fail predictably.
- Around line 224-228: The SSE consumer loops calling self.api_wrapper.run_sse
are not stopping when a terminal event is received; modify the loops that call
self._dispatch_event(writer, event) (the ones iterating over
self.api_wrapper.run_sse) so that when _dispatch_event returns a non-None
terminal value (e.g., the COMPLETE sentinel) you assign result and then
immediately break out of the for loop (or return) to stop consuming the stream;
apply the same change to both occurrences that handle SSE (the loop using writer
and the similar loop around lines 254-258) so the stream is not read after a
terminal event.
---
Outside diff comments:
In `@langchain/tests/integration_tests/test_standard.py`:
- Around line 12-27: The TestTinyFishToolIntegration class lacks the
environment-key skip guard used in other integration tests; add a skip condition
that checks for the TINYFISH_API_KEY env var and skips the whole class when it's
missing (e.g., using pytestmark =
pytest.mark.skipif(os.environ.get("TINYFISH_API_KEY") is None,
reason="TINYFISH_API_KEY not set") or an equivalent pytest.skip mechanism).
Update the top of the test class TestTinyFishToolIntegration so the guard runs
before any tests or property access, and import or reference pytest and os as
needed to implement the check.
---
Nitpick comments:
In @.github/workflows/langchain-ci.yml:
- Around line 35-39: Add a packaging smoke-check step to the CI by inserting a
new job step that runs package build (e.g., install the build tool and invoke
python -m build) after installing deps and before/after lint/tests; specifically
ensure the workflow runs something like `python -m pip install build` (or
include build in requirements-dev) and then `python -m build` so packaging
errors are surfaced in CI—update the workflow steps adjacent to the existing
`python -m pip install -e . -r requirements-dev.txt`, `make lint`, and `make
test` commands.
In `@langchain/tests/unit_tests/test_packaging.py`:
- Around line 14-16: The test currently asserts an exact string match against
dependencies, which fails when extra version specifiers are present; update the
assertion that references the dependencies variable in test_packaging.py to
check that at least one dependency entry corresponds to tinyfish and includes
the minimum floor ">=0.2.5" (for example by using any(...) over dependencies to
find an entry that starts with "tinyfish" or matches the package name and
contains ">=0.2.5"), so the test accepts entries like "tinyfish>=0.2.5,<1".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ac0cfb0f-4b22-4ad1-98b5-2281cf3cdfce
📒 Files selected for processing (24)
.github/workflows/langchain-ci.yml.github/workflows/langchain-publish.ymllangchain/.gitignorelangchain/LICENSElangchain/Makefilelangchain/README.mdlangchain/langchain_tinyfish/__init__.pylangchain/langchain_tinyfish/_api_wrapper.pylangchain/langchain_tinyfish/py.typedlangchain/langchain_tinyfish/tool.pylangchain/pyproject.tomllangchain/requirements-dev.txtlangchain/scripts/check_imports.pylangchain/tests/__init__.pylangchain/tests/integration_tests/__init__.pylangchain/tests/integration_tests/test_compile.pylangchain/tests/integration_tests/test_integration.pylangchain/tests/integration_tests/test_standard.pylangchain/tests/unit_tests/__init__.pylangchain/tests/unit_tests/test_api_wrapper.pylangchain/tests/unit_tests/test_imports.pylangchain/tests/unit_tests/test_packaging.pylangchain/tests/unit_tests/test_standard.pylangchain/tests/unit_tests/test_tool.py
Stop SSE consumption after terminal events, validate fetch URL counts, skip integration tests without credentials, and add CI build coverage.
Add the build package to LangChain dev requirements so the CI packaging smoke test can run python -m build.
Summary
Tests