Skip to content

Add LangChain TinyFish integration#14

Open
pranavjana wants to merge 3 commits into
mainfrom
pranav/langchain-sdk-tools
Open

Add LangChain TinyFish integration#14
pranavjana wants to merge 3 commits into
mainfrom
pranav/langchain-sdk-tools

Conversation

@pranavjana
Copy link
Copy Markdown
Collaborator

Summary

  • add the LangChain TinyFish package under langchain/
  • bump to tinyfish>=0.2.5 and expose SDK-backed tools for web automation, search, fetch, and browser session creation
  • add LangChain CI and PyPI trusted-publishing workflow

Tests

  • make lint
  • make test
  • python3 scripts/check_imports.py langchain_tinyfish/_api_wrapper.py langchain_tinyfish/init.py langchain_tinyfish/tool.py
  • python3 -m build
  • OPENROUTER_API_KEY=sk-test TINYFISH_API_KEY=sk-test python3 demo-backend import check
  • npm install && npm run build in langchain/demo-app

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6ba936b6-5d10-48e2-8bfc-afa25872a821

📥 Commits

Reviewing files that changed from the base of the PR and between b33becc and ffd253a.

📒 Files selected for processing (1)
  • langchain/requirements-dev.txt
✅ Files skipped from review due to trivial changes (1)
  • langchain/requirements-dev.txt

📝 Walkthrough

Walkthrough

This PR adds a packaged langchain-tinyfish integration: a Pydantic TinyFishAPIWrapper (sync/async), four LangChain tools (web automation, search, fetch, browser session) with optional LangGraph SSE streaming, pyproject packaging, Makefile and helper script, CI and publish workflows, README and LICENSE, and comprehensive unit and integration tests covering wrapper and tool behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Agent as LangChain Agent
  participant Tool as TinyFishWebAutomation
  participant Wrapper as TinyFishAPIWrapper
  participant SDK as TinyFish SDK
  participant Writer as LangGraph StreamWriter

  Agent->>Tool: invoke(url, goal)
  Tool->>Wrapper: run_sse(url, goal) or run(url, goal)
  Wrapper->>SDK: agent.stream / agent.run (start run)
  SDK->>Wrapper: SSE events (STARTED, STREAMING_URL, PROGRESS, COMPLETE)
  Wrapper->>Tool: normalized events
  Tool->>Writer: write(streaming_url / progress) (when writer available)
  Wrapper->>Tool: result JSON from COMPLETE handling
  Tool-->>Agent: return result
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a LangChain TinyFish integration package with all supporting infrastructure.
Description check ✅ Passed The description is directly related to the changeset, providing a comprehensive summary of the package addition, dependency updates, and CI/publishing workflows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pranav/langchain-sdk-tools

Comment @coderabbitai help to get the list of available commands and usage tips.

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.
@pranavjana pranavjana force-pushed the pranav/langchain-sdk-tools branch from b9cc376 to 46fedc9 Compare May 11, 2026 09:40
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Add API-key skip guard for this integration harness.

This integration suite currently lacks the TINYFISH_API_KEY skip 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 win

Make the tinyfish floor check resilient to additional constraints.

Line 16 requires an exact string match, so a valid change like tinyfish>=0.2.5,<1 would 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 win

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between 23f22da and 46fedc9.

📒 Files selected for processing (24)
  • .github/workflows/langchain-ci.yml
  • .github/workflows/langchain-publish.yml
  • langchain/.gitignore
  • langchain/LICENSE
  • langchain/Makefile
  • langchain/README.md
  • langchain/langchain_tinyfish/__init__.py
  • langchain/langchain_tinyfish/_api_wrapper.py
  • langchain/langchain_tinyfish/py.typed
  • langchain/langchain_tinyfish/tool.py
  • langchain/pyproject.toml
  • langchain/requirements-dev.txt
  • langchain/scripts/check_imports.py
  • langchain/tests/__init__.py
  • langchain/tests/integration_tests/__init__.py
  • langchain/tests/integration_tests/test_compile.py
  • langchain/tests/integration_tests/test_integration.py
  • langchain/tests/integration_tests/test_standard.py
  • langchain/tests/unit_tests/__init__.py
  • langchain/tests/unit_tests/test_api_wrapper.py
  • langchain/tests/unit_tests/test_imports.py
  • langchain/tests/unit_tests/test_packaging.py
  • langchain/tests/unit_tests/test_standard.py
  • langchain/tests/unit_tests/test_tool.py

Comment thread langchain/langchain_tinyfish/tool.py
Comment thread langchain/langchain_tinyfish/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant