langchain-youdotcom 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- langchain_youdotcom-0.1.0/.claude/settings.local.json +12 -0
- langchain_youdotcom-0.1.0/.github/workflows/publish.yml +182 -0
- langchain_youdotcom-0.1.0/.github/workflows/test.yml +51 -0
- langchain_youdotcom-0.1.0/.gitignore +14 -0
- langchain_youdotcom-0.1.0/CLAUDE.md +27 -0
- langchain_youdotcom-0.1.0/LICENSE +21 -0
- langchain_youdotcom-0.1.0/Makefile +42 -0
- langchain_youdotcom-0.1.0/PKG-INFO +164 -0
- langchain_youdotcom-0.1.0/README.md +139 -0
- langchain_youdotcom-0.1.0/langchain_youdotcom/__init__.py +12 -0
- langchain_youdotcom-0.1.0/langchain_youdotcom/_utilities.py +318 -0
- langchain_youdotcom-0.1.0/langchain_youdotcom/py.typed +0 -0
- langchain_youdotcom-0.1.0/langchain_youdotcom/retrievers.py +69 -0
- langchain_youdotcom-0.1.0/langchain_youdotcom/tools.py +124 -0
- langchain_youdotcom-0.1.0/pyproject.toml +120 -0
- langchain_youdotcom-0.1.0/scripts/check_imports.py +19 -0
- langchain_youdotcom-0.1.0/scripts/lint_imports.sh +13 -0
- langchain_youdotcom-0.1.0/tests/__init__.py +1 -0
- langchain_youdotcom-0.1.0/tests/integration_tests/__init__.py +1 -0
- langchain_youdotcom-0.1.0/tests/integration_tests/test_compile.py +11 -0
- langchain_youdotcom-0.1.0/tests/integration_tests/test_retriever.py +38 -0
- langchain_youdotcom-0.1.0/tests/integration_tests/test_tools.py +33 -0
- langchain_youdotcom-0.1.0/tests/integration_tests/test_utilities.py +69 -0
- langchain_youdotcom-0.1.0/tests/unit_tests/__init__.py +1 -0
- langchain_youdotcom-0.1.0/tests/unit_tests/conftest.py +96 -0
- langchain_youdotcom-0.1.0/tests/unit_tests/test_imports.py +23 -0
- langchain_youdotcom-0.1.0/tests/unit_tests/test_retrievers.py +54 -0
- langchain_youdotcom-0.1.0/tests/unit_tests/test_tools.py +129 -0
- langchain_youdotcom-0.1.0/tests/unit_tests/test_utilities.py +225 -0
- langchain_youdotcom-0.1.0/uv.lock +1314 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
name: Publish Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
bump:
|
|
7
|
+
description: "Version bump type"
|
|
8
|
+
required: true
|
|
9
|
+
type: choice
|
|
10
|
+
options:
|
|
11
|
+
- patch
|
|
12
|
+
- minor
|
|
13
|
+
- major
|
|
14
|
+
prerelease:
|
|
15
|
+
description: "Prerelease number (optional, creates x.y.z.devN)"
|
|
16
|
+
required: false
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: write
|
|
20
|
+
id-token: write
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
update-version:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
name: Update Version
|
|
26
|
+
permissions:
|
|
27
|
+
contents: write
|
|
28
|
+
outputs:
|
|
29
|
+
version: ${{ steps.set_version.outputs.version }}
|
|
30
|
+
is_prerelease: ${{ steps.set_version.outputs.is_prerelease }}
|
|
31
|
+
steps:
|
|
32
|
+
- name: Validate inputs
|
|
33
|
+
env:
|
|
34
|
+
INPUT_BUMP: ${{ inputs.bump }}
|
|
35
|
+
INPUT_PRERELEASE: ${{ inputs.prerelease }}
|
|
36
|
+
run: |
|
|
37
|
+
if [[ "$INPUT_BUMP" != "patch" && "$INPUT_BUMP" != "minor" && "$INPUT_BUMP" != "major" ]]; then
|
|
38
|
+
echo "::error::Invalid bump type: $INPUT_BUMP"
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
if [[ -n "$INPUT_PRERELEASE" ]] && ! echo "$INPUT_PRERELEASE" | grep -qE '^[0-9]+$'; then
|
|
43
|
+
echo "::error::Prerelease must be a number, got: $INPUT_PRERELEASE"
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
echo "✓ Input validation passed"
|
|
48
|
+
|
|
49
|
+
- uses: actions/checkout@v4
|
|
50
|
+
with:
|
|
51
|
+
token: ${{ secrets.PUBLISH_TOKEN }}
|
|
52
|
+
|
|
53
|
+
- name: Compute version
|
|
54
|
+
id: set_version
|
|
55
|
+
env:
|
|
56
|
+
INPUT_BUMP: ${{ inputs.bump }}
|
|
57
|
+
INPUT_PRERELEASE: ${{ inputs.prerelease }}
|
|
58
|
+
BRANCH_NAME: ${{ github.ref_name }}
|
|
59
|
+
run: |
|
|
60
|
+
CURRENT=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
|
|
61
|
+
echo "Current version: $CURRENT"
|
|
62
|
+
|
|
63
|
+
BASE=$(echo "$CURRENT" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
|
|
64
|
+
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE"
|
|
65
|
+
|
|
66
|
+
case "$INPUT_BUMP" in
|
|
67
|
+
major) BASE_VERSION="$((MAJOR + 1)).0.0" ;;
|
|
68
|
+
minor) BASE_VERSION="${MAJOR}.$((MINOR + 1)).0" ;;
|
|
69
|
+
patch) BASE_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;;
|
|
70
|
+
esac
|
|
71
|
+
|
|
72
|
+
echo "Bumped base: $BASE_VERSION"
|
|
73
|
+
|
|
74
|
+
if [[ -n "$INPUT_PRERELEASE" ]]; then
|
|
75
|
+
echo "version=${BASE_VERSION}.dev${INPUT_PRERELEASE}" >> "$GITHUB_OUTPUT"
|
|
76
|
+
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
|
|
77
|
+
else
|
|
78
|
+
echo "version=${BASE_VERSION}" >> "$GITHUB_OUTPUT"
|
|
79
|
+
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
echo "✅ Computed version: $(grep '^version=' "$GITHUB_OUTPUT" | head -1)"
|
|
83
|
+
|
|
84
|
+
- name: Validate computed version
|
|
85
|
+
env:
|
|
86
|
+
VERSION: ${{ steps.set_version.outputs.version }}
|
|
87
|
+
run: |
|
|
88
|
+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$ ]]; then
|
|
89
|
+
echo "::error::Invalid version: $VERSION"
|
|
90
|
+
exit 1
|
|
91
|
+
fi
|
|
92
|
+
echo "✅ Version format valid: $VERSION"
|
|
93
|
+
|
|
94
|
+
- uses: astral-sh/setup-uv@v4
|
|
95
|
+
with:
|
|
96
|
+
version: "latest"
|
|
97
|
+
|
|
98
|
+
- name: Configure Git
|
|
99
|
+
env:
|
|
100
|
+
GIT_AUTHOR_NAME: ${{ github.actor }}
|
|
101
|
+
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
|
|
102
|
+
run: |
|
|
103
|
+
git config user.name "$GIT_AUTHOR_NAME"
|
|
104
|
+
git config user.email "$GIT_AUTHOR_EMAIL"
|
|
105
|
+
|
|
106
|
+
- name: Bump version in pyproject.toml and lock
|
|
107
|
+
env:
|
|
108
|
+
VERSION: ${{ steps.set_version.outputs.version }}
|
|
109
|
+
BRANCH_NAME: ${{ github.ref_name }}
|
|
110
|
+
run: |
|
|
111
|
+
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
|
|
112
|
+
uv lock
|
|
113
|
+
|
|
114
|
+
WRITTEN=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
|
|
115
|
+
if [[ "$WRITTEN" != "$VERSION" ]]; then
|
|
116
|
+
echo "::error::Version mismatch after write: $WRITTEN != $VERSION"
|
|
117
|
+
exit 1
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
git add pyproject.toml uv.lock
|
|
121
|
+
if ! git diff --staged --quiet; then
|
|
122
|
+
git commit -m "ci: publish v${VERSION} [skip ci]"
|
|
123
|
+
git push origin "$BRANCH_NAME"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
pypi-publish:
|
|
127
|
+
runs-on: ubuntu-latest
|
|
128
|
+
name: Publish to PyPI
|
|
129
|
+
needs: [update-version]
|
|
130
|
+
permissions:
|
|
131
|
+
contents: read
|
|
132
|
+
id-token: write
|
|
133
|
+
steps:
|
|
134
|
+
- uses: actions/checkout@v4
|
|
135
|
+
with:
|
|
136
|
+
ref: ${{ github.ref_name }}
|
|
137
|
+
|
|
138
|
+
- uses: astral-sh/setup-uv@v4
|
|
139
|
+
with:
|
|
140
|
+
version: "latest"
|
|
141
|
+
|
|
142
|
+
- name: Install dependencies
|
|
143
|
+
run: uv sync --all-groups
|
|
144
|
+
|
|
145
|
+
- name: Build
|
|
146
|
+
run: uv build
|
|
147
|
+
|
|
148
|
+
- name: Publish to PyPI (Trusted Publishing)
|
|
149
|
+
env:
|
|
150
|
+
IS_PRERELEASE: ${{ needs.update-version.outputs.is_prerelease }}
|
|
151
|
+
run: uv publish --trusted-publishing always
|
|
152
|
+
|
|
153
|
+
create-release:
|
|
154
|
+
runs-on: ubuntu-latest
|
|
155
|
+
name: Create GitHub Release
|
|
156
|
+
needs: [update-version, pypi-publish]
|
|
157
|
+
if: always() && needs.pypi-publish.result == 'success'
|
|
158
|
+
permissions:
|
|
159
|
+
contents: write
|
|
160
|
+
steps:
|
|
161
|
+
- uses: actions/checkout@v4
|
|
162
|
+
with:
|
|
163
|
+
ref: ${{ github.ref_name }}
|
|
164
|
+
|
|
165
|
+
- name: Create GitHub Release
|
|
166
|
+
env:
|
|
167
|
+
GH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
|
|
168
|
+
VERSION: ${{ needs.update-version.outputs.version }}
|
|
169
|
+
IS_PRERELEASE: ${{ needs.update-version.outputs.is_prerelease }}
|
|
170
|
+
run: |
|
|
171
|
+
TAG="v${VERSION}"
|
|
172
|
+
|
|
173
|
+
if [[ "$IS_PRERELEASE" == "true" ]]; then
|
|
174
|
+
gh release create "${TAG}" \
|
|
175
|
+
--title "${TAG}" \
|
|
176
|
+
--generate-notes \
|
|
177
|
+
--prerelease
|
|
178
|
+
else
|
|
179
|
+
gh release create "${TAG}" \
|
|
180
|
+
--title "${TAG}" \
|
|
181
|
+
--generate-notes
|
|
182
|
+
fi
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
run_integration:
|
|
11
|
+
description: "Run integration tests"
|
|
12
|
+
type: boolean
|
|
13
|
+
default: false
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
lint:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: astral-sh/setup-uv@v4
|
|
21
|
+
with:
|
|
22
|
+
version: "latest"
|
|
23
|
+
- run: uv sync --all-groups
|
|
24
|
+
- run: make lint
|
|
25
|
+
|
|
26
|
+
test:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
strategy:
|
|
29
|
+
matrix:
|
|
30
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: astral-sh/setup-uv@v4
|
|
34
|
+
with:
|
|
35
|
+
version: "latest"
|
|
36
|
+
- run: uv python install ${{ matrix.python-version }}
|
|
37
|
+
- run: uv sync --all-groups --python ${{ matrix.python-version }}
|
|
38
|
+
- run: make test
|
|
39
|
+
|
|
40
|
+
integration:
|
|
41
|
+
if: github.event_name == 'workflow_dispatch' && inputs.run_integration
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- uses: astral-sh/setup-uv@v4
|
|
46
|
+
with:
|
|
47
|
+
version: "latest"
|
|
48
|
+
- run: uv sync --all-groups
|
|
49
|
+
- run: make integration_tests
|
|
50
|
+
env:
|
|
51
|
+
YDC_API_KEY: ${{ secrets.YDC_API_KEY }}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# langchain-youdotcom
|
|
2
|
+
|
|
3
|
+
LangChain partner package for You.com search and content APIs.
|
|
4
|
+
|
|
5
|
+
## Build & test
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv sync --all-groups # install all deps
|
|
9
|
+
make format # ruff format + fix
|
|
10
|
+
make lint # ruff check + format diff + mypy
|
|
11
|
+
make test # unit tests (pytest)
|
|
12
|
+
make integration_tests # integration tests (needs YDC_API_KEY)
|
|
13
|
+
make check_imports # verify all .py files importable
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
- `langchain_youdotcom/_utilities.py` — `YouSearchAPIWrapper` (API client)
|
|
19
|
+
- `langchain_youdotcom/retrievers.py` — `YouRetriever` (BaseRetriever subclass)
|
|
20
|
+
- `langchain_youdotcom/tools.py` — `YouSearchTool` + `YouContentsTool` (BaseTool subclasses)
|
|
21
|
+
|
|
22
|
+
## Conventions
|
|
23
|
+
|
|
24
|
+
- Depends on `langchain-core` only, never full `langchain`
|
|
25
|
+
- Delegates HTTP to the `youdotcom` SDK
|
|
26
|
+
- Google-style docstrings, full type hints
|
|
27
|
+
- Ruff for linting/formatting, mypy for type checking
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 You.com Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.PHONY: all format lint type test tests integration_tests check_imports help
|
|
2
|
+
|
|
3
|
+
.EXPORT_ALL_VARIABLES:
|
|
4
|
+
UV_FROZEN = true
|
|
5
|
+
|
|
6
|
+
PYTHON_FILES = langchain_youdotcom tests scripts
|
|
7
|
+
MYPY_CACHE = .mypy_cache
|
|
8
|
+
|
|
9
|
+
TEST_FILE ?= tests/unit_tests/
|
|
10
|
+
integration_tests: TEST_FILE=tests/integration_tests/
|
|
11
|
+
|
|
12
|
+
test tests integration_tests:
|
|
13
|
+
uv run --all-groups pytest $(TEST_FILE)
|
|
14
|
+
|
|
15
|
+
check_imports: $(shell find langchain_youdotcom -name '*.py')
|
|
16
|
+
uv run --all-groups python ./scripts/check_imports.py $^
|
|
17
|
+
|
|
18
|
+
lint lint_diff lint_package lint_tests:
|
|
19
|
+
./scripts/lint_imports.sh
|
|
20
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES)
|
|
21
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff
|
|
22
|
+
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
|
|
23
|
+
|
|
24
|
+
type:
|
|
25
|
+
mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
|
|
26
|
+
|
|
27
|
+
format format_diff:
|
|
28
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES)
|
|
29
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES)
|
|
30
|
+
|
|
31
|
+
lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d main | grep -E '\.py$$|\.ipynb$$')
|
|
32
|
+
lint_package: PYTHON_FILES=langchain_youdotcom
|
|
33
|
+
lint_tests: PYTHON_FILES=tests
|
|
34
|
+
|
|
35
|
+
help:
|
|
36
|
+
@echo "Available targets:"
|
|
37
|
+
@echo " format - Format code with ruff"
|
|
38
|
+
@echo " lint - Run ruff check, ruff format --diff, and mypy"
|
|
39
|
+
@echo " type - Run mypy type checking"
|
|
40
|
+
@echo " test - Run unit tests"
|
|
41
|
+
@echo " integration_tests - Run integration tests"
|
|
42
|
+
@echo " check_imports - Verify all modules are importable"
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-youdotcom
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An integration package connecting You.com and LangChain
|
|
5
|
+
Project-URL: Homepage, https://you.com
|
|
6
|
+
Project-URL: Documentation, https://docs.you.com
|
|
7
|
+
Project-URL: Repository, https://github.com/youdotcom-oss/langchain-youdotcom
|
|
8
|
+
Project-URL: Issues, https://github.com/youdotcom-oss/langchain-youdotcom/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/youdotcom-oss/langchain-youdotcom/releases
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: <4.0.0,>=3.10.0
|
|
22
|
+
Requires-Dist: langchain-core<2.0.0,>=1.0.0
|
|
23
|
+
Requires-Dist: youdotcom<3.0.0,>=2.2.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# langchain-youdotcom
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/langchain-youdotcom/#history)
|
|
29
|
+
[](https://opensource.org/licenses/MIT)
|
|
30
|
+
[](https://pypistats.org/packages/langchain-youdotcom)
|
|
31
|
+
|
|
32
|
+
LangChain partner package for [You.com](https://you.com) search and content APIs.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install -U langchain-youdotcom
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Credentials
|
|
41
|
+
|
|
42
|
+
Get an API key at [you.com/platform/api-keys](https://you.com/platform/api-keys), then set it as an environment variable:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
export YDC_API_KEY="your-api-key"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or pass it directly when instantiating any component:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
retriever = YouRetriever(ydc_api_key="your-api-key")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Retriever
|
|
55
|
+
|
|
56
|
+
The simplest way to get You.com search results as LangChain documents.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from langchain_youdotcom import YouRetriever
|
|
60
|
+
|
|
61
|
+
retriever = YouRetriever()
|
|
62
|
+
docs = retriever.invoke("latest AI news")
|
|
63
|
+
|
|
64
|
+
for doc in docs:
|
|
65
|
+
print(doc.metadata["title"])
|
|
66
|
+
print(doc.page_content[:200])
|
|
67
|
+
print()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
All search parameters are available directly on the retriever:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
retriever = YouRetriever(
|
|
74
|
+
k=5, # max documents to return
|
|
75
|
+
count=10, # max results per API section
|
|
76
|
+
livecrawl="web", # fetch live page content
|
|
77
|
+
livecrawl_formats="markdown",
|
|
78
|
+
country="US",
|
|
79
|
+
freshness="week", # day, week, month, year
|
|
80
|
+
safesearch="moderate", # off, moderate, strict
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Tools
|
|
85
|
+
|
|
86
|
+
### YouSearchTool
|
|
87
|
+
|
|
88
|
+
Search the web with You.com. Works with any LangChain agent.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from langchain_youdotcom import YouSearchTool
|
|
92
|
+
|
|
93
|
+
tool = YouSearchTool()
|
|
94
|
+
result = tool.invoke("what is retrieval augmented generation")
|
|
95
|
+
print(result)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### YouContentsTool
|
|
99
|
+
|
|
100
|
+
Fetch and extract content from web pages.
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from langchain_youdotcom import YouContentsTool
|
|
104
|
+
|
|
105
|
+
tool = YouContentsTool()
|
|
106
|
+
result = tool.invoke({"urls": ["https://example.com"]})
|
|
107
|
+
print(result)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Using with an agent
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from langchain_openai import ChatOpenAI
|
|
114
|
+
from langgraph.prebuilt import create_react_agent
|
|
115
|
+
|
|
116
|
+
from langchain_youdotcom import YouSearchTool
|
|
117
|
+
|
|
118
|
+
tools = [YouSearchTool()]
|
|
119
|
+
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)
|
|
120
|
+
|
|
121
|
+
response = agent.invoke(
|
|
122
|
+
{"messages": [{"role": "user", "content": "what happened in AI today?"}]}
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## YouSearchAPIWrapper
|
|
127
|
+
|
|
128
|
+
For more control, use the wrapper directly. It powers the retriever and tools under the hood.
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from langchain_youdotcom import YouSearchAPIWrapper
|
|
132
|
+
|
|
133
|
+
wrapper = YouSearchAPIWrapper()
|
|
134
|
+
|
|
135
|
+
# search -> list[Document]
|
|
136
|
+
docs = wrapper.results("latest AI news")
|
|
137
|
+
|
|
138
|
+
# raw SDK response
|
|
139
|
+
raw = wrapper.raw_results("latest AI news")
|
|
140
|
+
|
|
141
|
+
# contents API -> list[Document]
|
|
142
|
+
pages = wrapper.contents(
|
|
143
|
+
["https://example.com"],
|
|
144
|
+
formats=["markdown", "metadata"],
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Async variants are available as `results_async`, `raw_results_async`, and `contents_async`.
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
- [You.com API docs](https://docs.you.com)
|
|
153
|
+
- [You.com API keys](https://you.com/platform/api-keys)
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
uv sync --all-groups
|
|
159
|
+
make format # ruff format + fix
|
|
160
|
+
make lint # ruff check + format diff + mypy
|
|
161
|
+
make test # unit tests
|
|
162
|
+
make integration_tests # requires YDC_API_KEY
|
|
163
|
+
make check_imports # verify all modules importable
|
|
164
|
+
```
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# langchain-youdotcom
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/langchain-youdotcom/#history)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://pypistats.org/packages/langchain-youdotcom)
|
|
6
|
+
|
|
7
|
+
LangChain partner package for [You.com](https://you.com) search and content APIs.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install -U langchain-youdotcom
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Credentials
|
|
16
|
+
|
|
17
|
+
Get an API key at [you.com/platform/api-keys](https://you.com/platform/api-keys), then set it as an environment variable:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export YDC_API_KEY="your-api-key"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or pass it directly when instantiating any component:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
retriever = YouRetriever(ydc_api_key="your-api-key")
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Retriever
|
|
30
|
+
|
|
31
|
+
The simplest way to get You.com search results as LangChain documents.
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from langchain_youdotcom import YouRetriever
|
|
35
|
+
|
|
36
|
+
retriever = YouRetriever()
|
|
37
|
+
docs = retriever.invoke("latest AI news")
|
|
38
|
+
|
|
39
|
+
for doc in docs:
|
|
40
|
+
print(doc.metadata["title"])
|
|
41
|
+
print(doc.page_content[:200])
|
|
42
|
+
print()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
All search parameters are available directly on the retriever:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
retriever = YouRetriever(
|
|
49
|
+
k=5, # max documents to return
|
|
50
|
+
count=10, # max results per API section
|
|
51
|
+
livecrawl="web", # fetch live page content
|
|
52
|
+
livecrawl_formats="markdown",
|
|
53
|
+
country="US",
|
|
54
|
+
freshness="week", # day, week, month, year
|
|
55
|
+
safesearch="moderate", # off, moderate, strict
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Tools
|
|
60
|
+
|
|
61
|
+
### YouSearchTool
|
|
62
|
+
|
|
63
|
+
Search the web with You.com. Works with any LangChain agent.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from langchain_youdotcom import YouSearchTool
|
|
67
|
+
|
|
68
|
+
tool = YouSearchTool()
|
|
69
|
+
result = tool.invoke("what is retrieval augmented generation")
|
|
70
|
+
print(result)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### YouContentsTool
|
|
74
|
+
|
|
75
|
+
Fetch and extract content from web pages.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from langchain_youdotcom import YouContentsTool
|
|
79
|
+
|
|
80
|
+
tool = YouContentsTool()
|
|
81
|
+
result = tool.invoke({"urls": ["https://example.com"]})
|
|
82
|
+
print(result)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Using with an agent
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from langchain_openai import ChatOpenAI
|
|
89
|
+
from langgraph.prebuilt import create_react_agent
|
|
90
|
+
|
|
91
|
+
from langchain_youdotcom import YouSearchTool
|
|
92
|
+
|
|
93
|
+
tools = [YouSearchTool()]
|
|
94
|
+
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)
|
|
95
|
+
|
|
96
|
+
response = agent.invoke(
|
|
97
|
+
{"messages": [{"role": "user", "content": "what happened in AI today?"}]}
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## YouSearchAPIWrapper
|
|
102
|
+
|
|
103
|
+
For more control, use the wrapper directly. It powers the retriever and tools under the hood.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from langchain_youdotcom import YouSearchAPIWrapper
|
|
107
|
+
|
|
108
|
+
wrapper = YouSearchAPIWrapper()
|
|
109
|
+
|
|
110
|
+
# search -> list[Document]
|
|
111
|
+
docs = wrapper.results("latest AI news")
|
|
112
|
+
|
|
113
|
+
# raw SDK response
|
|
114
|
+
raw = wrapper.raw_results("latest AI news")
|
|
115
|
+
|
|
116
|
+
# contents API -> list[Document]
|
|
117
|
+
pages = wrapper.contents(
|
|
118
|
+
["https://example.com"],
|
|
119
|
+
formats=["markdown", "metadata"],
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Async variants are available as `results_async`, `raw_results_async`, and `contents_async`.
|
|
124
|
+
|
|
125
|
+
## Documentation
|
|
126
|
+
|
|
127
|
+
- [You.com API docs](https://docs.you.com)
|
|
128
|
+
- [You.com API keys](https://you.com/platform/api-keys)
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
uv sync --all-groups
|
|
134
|
+
make format # ruff format + fix
|
|
135
|
+
make lint # ruff check + format diff + mypy
|
|
136
|
+
make test # unit tests
|
|
137
|
+
make integration_tests # requires YDC_API_KEY
|
|
138
|
+
make check_imports # verify all modules importable
|
|
139
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""LangChain integration for You.com."""
|
|
2
|
+
|
|
3
|
+
from langchain_youdotcom._utilities import YouSearchAPIWrapper
|
|
4
|
+
from langchain_youdotcom.retrievers import YouRetriever
|
|
5
|
+
from langchain_youdotcom.tools import YouContentsTool, YouSearchTool
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"YouContentsTool",
|
|
9
|
+
"YouRetriever",
|
|
10
|
+
"YouSearchAPIWrapper",
|
|
11
|
+
"YouSearchTool",
|
|
12
|
+
]
|