langchain-openapi-tools 1.0.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_openapi_tools-1.0.0/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
- langchain_openapi_tools-1.0.0/.github/ISSUE_TEMPLATE/documentation.md +20 -0
- langchain_openapi_tools-1.0.0/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
- langchain_openapi_tools-1.0.0/.github/PULL_REQUEST_TEMPLATE.md +22 -0
- langchain_openapi_tools-1.0.0/.github/dependabot.yml +17 -0
- langchain_openapi_tools-1.0.0/.github/workflows/ci.yml +84 -0
- langchain_openapi_tools-1.0.0/.github/workflows/pages.yml +32 -0
- langchain_openapi_tools-1.0.0/.github/workflows/publish.yml +40 -0
- langchain_openapi_tools-1.0.0/.github/workflows/release.yml +47 -0
- langchain_openapi_tools-1.0.0/.gitignore +91 -0
- langchain_openapi_tools-1.0.0/.pre-commit-config.yaml +22 -0
- langchain_openapi_tools-1.0.0/ARCHITECTURE.md +224 -0
- langchain_openapi_tools-1.0.0/CHANGELOG.md +22 -0
- langchain_openapi_tools-1.0.0/CODE_OF_CONDUCT.md +60 -0
- langchain_openapi_tools-1.0.0/CONTRIBUTING.md +97 -0
- langchain_openapi_tools-1.0.0/LICENSE +19 -0
- langchain_openapi_tools-1.0.0/Makefile +24 -0
- langchain_openapi_tools-1.0.0/PKG-INFO +279 -0
- langchain_openapi_tools-1.0.0/README.md +239 -0
- langchain_openapi_tools-1.0.0/benchmarks/benchmark.py +73 -0
- langchain_openapi_tools-1.0.0/docs/api/executor.md +5 -0
- langchain_openapi_tools-1.0.0/docs/api/loader.md +3 -0
- langchain_openapi_tools-1.0.0/docs/api/middleware.md +8 -0
- langchain_openapi_tools-1.0.0/docs/api/parser.md +4 -0
- langchain_openapi_tools-1.0.0/docs/api/toolkit.md +4 -0
- langchain_openapi_tools-1.0.0/docs/architecture.md +60 -0
- langchain_openapi_tools-1.0.0/docs/authentication.md +88 -0
- langchain_openapi_tools-1.0.0/docs/contributing.md +43 -0
- langchain_openapi_tools-1.0.0/docs/examples/crossref.md +37 -0
- langchain_openapi_tools-1.0.0/docs/examples/petstore.md +31 -0
- langchain_openapi_tools-1.0.0/docs/index.md +44 -0
- langchain_openapi_tools-1.0.0/docs/installation.md +40 -0
- langchain_openapi_tools-1.0.0/docs/middleware.md +106 -0
- langchain_openapi_tools-1.0.0/docs/quickstart.md +72 -0
- langchain_openapi_tools-1.0.0/docs/toolkit.md +79 -0
- langchain_openapi_tools-1.0.0/examples/README.md +15 -0
- langchain_openapi_tools-1.0.0/examples/crossref/README.md +10 -0
- langchain_openapi_tools-1.0.0/examples/crossref/crossref.json +35 -0
- langchain_openapi_tools-1.0.0/examples/crossref/main.py +37 -0
- langchain_openapi_tools-1.0.0/examples/crossref/requirements.txt +1 -0
- langchain_openapi_tools-1.0.0/examples/petstore/README.md +10 -0
- langchain_openapi_tools-1.0.0/examples/petstore/main.py +30 -0
- langchain_openapi_tools-1.0.0/examples/petstore/petstore.json +36 -0
- langchain_openapi_tools-1.0.0/examples/petstore/requirements.txt +1 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/__init__.py +143 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/enums.py +35 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/exceptions.py +41 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/executor.py +266 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/loader.py +148 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/middleware.py +412 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/models.py +146 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/parser.py +434 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/providers.py +164 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/py.typed +1 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/schema_converter.py +251 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/toolkit.py +325 -0
- langchain_openapi_tools-1.0.0/langchain_openapi/utils.py +108 -0
- langchain_openapi_tools-1.0.0/mkdocs.yml +73 -0
- langchain_openapi_tools-1.0.0/pyproject.toml +110 -0
- langchain_openapi_tools-1.0.0/site/404.html +857 -0
- langchain_openapi_tools-1.0.0/site/api/executor/index.html +1560 -0
- langchain_openapi_tools-1.0.0/site/api/loader/index.html +2073 -0
- langchain_openapi_tools-1.0.0/site/api/middleware/index.html +2035 -0
- langchain_openapi_tools-1.0.0/site/api/parser/index.html +2007 -0
- langchain_openapi_tools-1.0.0/site/api/toolkit/index.html +1567 -0
- langchain_openapi_tools-1.0.0/site/architecture/index.html +1199 -0
- langchain_openapi_tools-1.0.0/site/assets/_mkdocstrings.css +237 -0
- langchain_openapi_tools-1.0.0/site/assets/images/favicon.png +0 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/bundle.d7400e89.min.js +16 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/bundle.d7400e89.min.js.map +7 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/tinyseg.js +206 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/lunr/wordcut.js +6708 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/workers/search.2c215733.min.js +42 -0
- langchain_openapi_tools-1.0.0/site/assets/javascripts/workers/search.2c215733.min.js.map +7 -0
- langchain_openapi_tools-1.0.0/site/assets/stylesheets/main.ec1eaa64.min.css +1 -0
- langchain_openapi_tools-1.0.0/site/assets/stylesheets/main.ec1eaa64.min.css.map +1 -0
- langchain_openapi_tools-1.0.0/site/assets/stylesheets/palette.ab4e12ef.min.css +1 -0
- langchain_openapi_tools-1.0.0/site/assets/stylesheets/palette.ab4e12ef.min.css.map +1 -0
- langchain_openapi_tools-1.0.0/site/authentication/index.html +1151 -0
- langchain_openapi_tools-1.0.0/site/contributing/index.html +1048 -0
- langchain_openapi_tools-1.0.0/site/examples/crossref/index.html +999 -0
- langchain_openapi_tools-1.0.0/site/examples/petstore/index.html +993 -0
- langchain_openapi_tools-1.0.0/site/index.html +1045 -0
- langchain_openapi_tools-1.0.0/site/installation/index.html +1076 -0
- langchain_openapi_tools-1.0.0/site/middleware/index.html +1187 -0
- langchain_openapi_tools-1.0.0/site/objects.inv +0 -0
- langchain_openapi_tools-1.0.0/site/quickstart/index.html +1082 -0
- langchain_openapi_tools-1.0.0/site/search/search_index.json +1 -0
- langchain_openapi_tools-1.0.0/site/sitemap.xml +63 -0
- langchain_openapi_tools-1.0.0/site/sitemap.xml.gz +0 -0
- langchain_openapi_tools-1.0.0/site/toolkit/index.html +1145 -0
- langchain_openapi_tools-1.0.0/tests/test_e2e.py +128 -0
- langchain_openapi_tools-1.0.0/tests/test_executor.py +334 -0
- langchain_openapi_tools-1.0.0/tests/test_import.py +6 -0
- langchain_openapi_tools-1.0.0/tests/test_loader.py +233 -0
- langchain_openapi_tools-1.0.0/tests/test_middleware.py +242 -0
- langchain_openapi_tools-1.0.0/tests/test_parser.py +260 -0
- langchain_openapi_tools-1.0.0/tests/test_providers.py +200 -0
- langchain_openapi_tools-1.0.0/tests/test_resolver.py +113 -0
- langchain_openapi_tools-1.0.0/tests/test_schema_converter.py +245 -0
- langchain_openapi_tools-1.0.0/tests/test_toolkit.py +234 -0
- langchain_openapi_tools-1.0.0/uv.lock +2165 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Create a report to help us fix a bug or unexpected behavior.
|
|
3
|
+
title: "[BUG]: "
|
|
4
|
+
labels: ["bug"]
|
|
5
|
+
assignees: []
|
|
6
|
+
body:
|
|
7
|
+
- type: textarea
|
|
8
|
+
id: description
|
|
9
|
+
attributes:
|
|
10
|
+
label: Bug Description
|
|
11
|
+
description: Clear and concise description of what the bug is.
|
|
12
|
+
validations:
|
|
13
|
+
required: true
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: reproduction
|
|
16
|
+
attributes:
|
|
17
|
+
label: Steps to Reproduce
|
|
18
|
+
description: Steps to reproduce the behavior or code sample.
|
|
19
|
+
placeholder: |
|
|
20
|
+
from langchain_openapi import OpenAPIToolkit
|
|
21
|
+
toolkit = OpenAPIToolkit.from_url("...")
|
|
22
|
+
validations:
|
|
23
|
+
required: true
|
|
24
|
+
- type: textarea
|
|
25
|
+
id: environment
|
|
26
|
+
attributes:
|
|
27
|
+
label: Environment
|
|
28
|
+
description: Python version, OS, langchain-openapi version.
|
|
29
|
+
placeholder: |
|
|
30
|
+
- Python version: 3.11.0
|
|
31
|
+
- OS: Linux / macOS / Windows
|
|
32
|
+
- langchain-openapi version: 0.1.0
|
|
33
|
+
validations:
|
|
34
|
+
required: false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Documentation Improvement
|
|
2
|
+
description: Suggest improvements or report errors in documentation.
|
|
3
|
+
title: "[DOCS]: "
|
|
4
|
+
labels: ["documentation"]
|
|
5
|
+
assignees: []
|
|
6
|
+
body:
|
|
7
|
+
- type: textarea
|
|
8
|
+
id: summary
|
|
9
|
+
attributes:
|
|
10
|
+
label: Summary
|
|
11
|
+
description: What section of the documentation needs improvement?
|
|
12
|
+
validations:
|
|
13
|
+
required: true
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: content
|
|
16
|
+
attributes:
|
|
17
|
+
label: Suggested Changes
|
|
18
|
+
description: Describe the changes or corrections you would like to see.
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest an idea or enhancement for langchain-openapi.
|
|
3
|
+
title: "[FEATURE]: "
|
|
4
|
+
labels: ["enhancement"]
|
|
5
|
+
assignees: []
|
|
6
|
+
body:
|
|
7
|
+
- type: textarea
|
|
8
|
+
id: problem
|
|
9
|
+
attributes:
|
|
10
|
+
label: Is your feature request related to a problem?
|
|
11
|
+
description: Clear and concise description of what the problem is.
|
|
12
|
+
validations:
|
|
13
|
+
required: true
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: solution
|
|
16
|
+
attributes:
|
|
17
|
+
label: Describe the solution you'd like
|
|
18
|
+
description: Clear description of what you want to happen.
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
- type: textarea
|
|
22
|
+
id: alternatives
|
|
23
|
+
attributes:
|
|
24
|
+
label: Describe alternatives you've considered
|
|
25
|
+
description: Description of any alternative solutions or features considered.
|
|
26
|
+
validations:
|
|
27
|
+
required: false
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
Brief summary of the changes made in this pull request.
|
|
4
|
+
|
|
5
|
+
## Related Issue
|
|
6
|
+
|
|
7
|
+
Fixes #(issue_number)
|
|
8
|
+
|
|
9
|
+
## Type of Change
|
|
10
|
+
|
|
11
|
+
- [ ] Bug fix (non-breaking change fixing an issue)
|
|
12
|
+
- [ ] New feature (non-breaking change adding functionality)
|
|
13
|
+
- [ ] Breaking change (fix or feature causing existing functionality to change)
|
|
14
|
+
- [ ] Documentation update
|
|
15
|
+
|
|
16
|
+
## Checklist
|
|
17
|
+
|
|
18
|
+
- [ ] Code formatted with `uv run ruff format .`
|
|
19
|
+
- [ ] Linting checked with `uv run ruff check .`
|
|
20
|
+
- [ ] Static type checking passed with `uv run mypy langchain_openapi tests examples`
|
|
21
|
+
- [ ] Tests passed with `uv run pytest`
|
|
22
|
+
- [ ] Added/updated relevant unit or e2e tests
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "pip"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
open-pull-requests-limit: 10
|
|
8
|
+
labels:
|
|
9
|
+
- "dependencies"
|
|
10
|
+
|
|
11
|
+
- package-ecosystem: "github-actions"
|
|
12
|
+
directory: "/"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: "weekly"
|
|
15
|
+
open-pull-requests-limit: 10
|
|
16
|
+
labels:
|
|
17
|
+
- "dependencies"
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint-and-test:
|
|
14
|
+
name: Lint & Test (Python ${{ matrix.python-version }})
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: true
|
|
18
|
+
matrix:
|
|
19
|
+
python-version: ["3.11", "3.12"]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout repository
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
uses: astral-sh/setup-uv@v5
|
|
27
|
+
with:
|
|
28
|
+
enable-cache: true
|
|
29
|
+
|
|
30
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
31
|
+
uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
uv sync --all-extras --dev
|
|
38
|
+
|
|
39
|
+
- name: Run Ruff (lint)
|
|
40
|
+
run: |
|
|
41
|
+
uv run ruff check .
|
|
42
|
+
|
|
43
|
+
- name: Run Ruff (format check)
|
|
44
|
+
run: |
|
|
45
|
+
uv run ruff format --check .
|
|
46
|
+
|
|
47
|
+
- name: Run MyPy (type check)
|
|
48
|
+
run: |
|
|
49
|
+
uv run mypy langchain_openapi tests examples
|
|
50
|
+
|
|
51
|
+
- name: Run Pytest
|
|
52
|
+
run: |
|
|
53
|
+
uv run pytest
|
|
54
|
+
|
|
55
|
+
- name: Build Documentation (MkDocs)
|
|
56
|
+
run: |
|
|
57
|
+
uv run mkdocs build
|
|
58
|
+
|
|
59
|
+
build-package:
|
|
60
|
+
name: Package Build & Twine Check
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
steps:
|
|
63
|
+
- name: Checkout repository
|
|
64
|
+
uses: actions/checkout@v4
|
|
65
|
+
|
|
66
|
+
- name: Install uv
|
|
67
|
+
uses: astral-sh/setup-uv@v5
|
|
68
|
+
|
|
69
|
+
- name: Set up Python
|
|
70
|
+
uses: actions/setup-python@v5
|
|
71
|
+
with:
|
|
72
|
+
python-version: "3.11"
|
|
73
|
+
|
|
74
|
+
- name: Install build & twine
|
|
75
|
+
run: |
|
|
76
|
+
uv sync --extra dev
|
|
77
|
+
|
|
78
|
+
- name: Build distribution packages
|
|
79
|
+
run: |
|
|
80
|
+
uv run python -m build
|
|
81
|
+
|
|
82
|
+
- name: Check package artifacts with twine
|
|
83
|
+
run: |
|
|
84
|
+
uv run twine check dist/*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Deploy Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
deploy-docs:
|
|
12
|
+
name: Deploy MkDocs to GitHub Pages
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout repository
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v5
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.11"
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
uv sync --extra dev
|
|
29
|
+
|
|
30
|
+
- name: Deploy documentation to GitHub Pages
|
|
31
|
+
run: |
|
|
32
|
+
uv run mkdocs gh-deploy --force
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
pypi-publish:
|
|
13
|
+
name: Publish to PyPI
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout repository
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.11"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
uv sync --extra dev
|
|
30
|
+
|
|
31
|
+
- name: Build sdist and wheel
|
|
32
|
+
run: |
|
|
33
|
+
uv run python -m build
|
|
34
|
+
|
|
35
|
+
- name: Check distribution artifacts
|
|
36
|
+
run: |
|
|
37
|
+
uv run twine check dist/*
|
|
38
|
+
|
|
39
|
+
- name: Publish to PyPI via Trusted Publishing
|
|
40
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: GitHub Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release:
|
|
13
|
+
name: Create GitHub Release
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout repository
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
|
|
24
|
+
- name: Set up Python
|
|
25
|
+
uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.11"
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: |
|
|
31
|
+
uv sync --extra dev
|
|
32
|
+
|
|
33
|
+
- name: Build sdist and wheel
|
|
34
|
+
run: |
|
|
35
|
+
uv run python -m build
|
|
36
|
+
|
|
37
|
+
- name: Check distribution artifacts
|
|
38
|
+
run: |
|
|
39
|
+
uv run twine check dist/*
|
|
40
|
+
|
|
41
|
+
- name: Create GitHub Release
|
|
42
|
+
uses: softprops/action-gh-release@v2
|
|
43
|
+
with:
|
|
44
|
+
files: dist/*
|
|
45
|
+
generate_release_notes: true
|
|
46
|
+
draft: false
|
|
47
|
+
prerelease: false
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.nox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
*.py.xml
|
|
48
|
+
.hypothesis/
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
pytestdebug.log
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
|
|
59
|
+
# Sphinx documentation
|
|
60
|
+
docs/_build/
|
|
61
|
+
|
|
62
|
+
# PyBuilder
|
|
63
|
+
target/
|
|
64
|
+
|
|
65
|
+
# Jupyter Notebook
|
|
66
|
+
.ipynb_checkpoints
|
|
67
|
+
|
|
68
|
+
# IPython
|
|
69
|
+
profile_default/
|
|
70
|
+
ipython_config.py
|
|
71
|
+
|
|
72
|
+
# environments
|
|
73
|
+
.env
|
|
74
|
+
.venv
|
|
75
|
+
env/
|
|
76
|
+
venv/
|
|
77
|
+
ENV/
|
|
78
|
+
env.bak/
|
|
79
|
+
venv.bak/
|
|
80
|
+
|
|
81
|
+
# MyPy & Ruff cache
|
|
82
|
+
.mypy_cache/
|
|
83
|
+
.ruff_cache/
|
|
84
|
+
|
|
85
|
+
# IDE files
|
|
86
|
+
.vscode/
|
|
87
|
+
.idea/
|
|
88
|
+
*.swp
|
|
89
|
+
*.swo
|
|
90
|
+
*~
|
|
91
|
+
.DS_Store
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v4.6.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-added-large-files
|
|
10
|
+
|
|
11
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
12
|
+
rev: v0.5.0
|
|
13
|
+
hooks:
|
|
14
|
+
- id: ruff
|
|
15
|
+
args: [--fix]
|
|
16
|
+
- id: ruff-format
|
|
17
|
+
|
|
18
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
19
|
+
rev: v1.10.1
|
|
20
|
+
hooks:
|
|
21
|
+
- id: mypy
|
|
22
|
+
additional_dependencies: []
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# `langchain-openapi` Architecture Specification
|
|
2
|
+
|
|
3
|
+
This document details the planned software architecture for `langchain-openapi`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Design Goals
|
|
8
|
+
|
|
9
|
+
* **Framework Native**: Seamless integration with `langchain-core` tool interfaces (`BaseTool`), ensuring drop-in compatibility with LangChain agents and LangGraph workflows.
|
|
10
|
+
* **Type Safety & Reliability**: Full static typing across the pipeline, converting OpenAPI definitions into strict Pydantic schemas to validate LLM tool calls before network invocation.
|
|
11
|
+
* **Robust Spec Support**: Comprehensive parsing of OpenAPI v3.0 and v3.1 specifications, including complete parameter locations (path, query, header, cookie) and `$ref` schema resolution.
|
|
12
|
+
* **Decoupled Architecture**: Clear separation of concerns between specification parsing, internal model representation, schema generation, and network execution.
|
|
13
|
+
* **Security First**: Safe isolation of authentication credentials so API secrets are never exposed to LLM prompts or output logs.
|
|
14
|
+
* **Extensibility**: Modular interfaces allowing custom HTTP transports, custom authentication handlers, and custom tool filtering strategies.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 2. High-Level Architecture
|
|
19
|
+
|
|
20
|
+
The library is structured as a linear transform pipeline with isolated responsibilities:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
┌────────────────────────────────────────────────────────┐
|
|
24
|
+
│ OpenAPI Spec │
|
|
25
|
+
│ (File / URL / Dict) │
|
|
26
|
+
└───────────────────────────┬────────────────────────────┘
|
|
27
|
+
│
|
|
28
|
+
▼
|
|
29
|
+
┌────────────────────────────────────────────────────────┐
|
|
30
|
+
│ OpenAPI Loader │
|
|
31
|
+
│ - Parsing (JSON / YAML) │
|
|
32
|
+
│ - Ref Resolution ($ref expansion) │
|
|
33
|
+
└───────────────────────────┬────────────────────────────┘
|
|
34
|
+
│
|
|
35
|
+
▼
|
|
36
|
+
┌────────────────────────────────────────────────────────┐
|
|
37
|
+
│ Internal Models │
|
|
38
|
+
│ - Parsed Spec & Operation trees │
|
|
39
|
+
│ - Schema normalization │
|
|
40
|
+
└───────────────────────────┬────────────────────────────┘
|
|
41
|
+
│
|
|
42
|
+
▼
|
|
43
|
+
┌────────────────────────────────────────────────────────┐
|
|
44
|
+
│ Schema Converter │
|
|
45
|
+
│ - JSON Schema ──► Pydantic Model │
|
|
46
|
+
│ - Parameter & Body validation schemas │
|
|
47
|
+
└───────────────────────────┬────────────────────────────┘
|
|
48
|
+
│
|
|
49
|
+
▼
|
|
50
|
+
┌────────────────────────────────────────────────────────┐
|
|
51
|
+
│ HTTP Executor │
|
|
52
|
+
│ - Async Transport (httpx) │
|
|
53
|
+
│ - Auth Injection │
|
|
54
|
+
│ - Request Serialization & Response Parsing │
|
|
55
|
+
└───────────────────────────┬────────────────────────────┘
|
|
56
|
+
│
|
|
57
|
+
▼
|
|
58
|
+
┌────────────────────────────────────────────────────────┐
|
|
59
|
+
│ Tool Generator │
|
|
60
|
+
│ - langchain_core.tools.BaseTool Factory │
|
|
61
|
+
│ - Selective filtering (tags, endpoints) │
|
|
62
|
+
└───────────────────────────┬────────────────────────────┘
|
|
63
|
+
│
|
|
64
|
+
▼
|
|
65
|
+
┌────────────────────────────────────────────────────────┐
|
|
66
|
+
│ LangChain / Agent Loop │
|
|
67
|
+
└────────────────────────────────────────────────────────┘
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 3. Core Components
|
|
73
|
+
|
|
74
|
+
### 3.1 OpenAPI Loader
|
|
75
|
+
|
|
76
|
+
The **OpenAPI Loader** is responsible for reading OpenAPI specifications from local file paths, raw strings, or remote HTTP URLs. It handles format auto-detection (JSON vs. YAML), syntax validation, and recursively resolves relative and external `$ref` pointers into a unified, flattened schema representation.
|
|
77
|
+
|
|
78
|
+
### 3.2 Internal Models & Specification Parser
|
|
79
|
+
|
|
80
|
+
The **OpenAPI Parser** (`OpenAPIParser`) transforms an `OpenAPISpec` into strongly typed, normalized Python dataclasses using the `ReferenceResolver` for local `$ref` pointer resolution:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
OpenAPI Spec (File / URL / Dict)
|
|
84
|
+
│
|
|
85
|
+
▼
|
|
86
|
+
[ OpenAPISpec ]
|
|
87
|
+
│
|
|
88
|
+
▼
|
|
89
|
+
[ OpenAPIParser ] ◄── [ ReferenceResolver ($ref resolution) ]
|
|
90
|
+
│
|
|
91
|
+
▼
|
|
92
|
+
[ Operation Models ]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Public Model Definitions
|
|
96
|
+
|
|
97
|
+
* **`Operation`**: Represents a single executable API endpoint for a specific HTTP method (`name`, `method`, `path`, `summary`, `description`, `operation_id`, `tags`, `parameters`, `request_body`, `responses`, `deprecated`, `security`).
|
|
98
|
+
* **`Parameter`**: Defines an input parameter supplied in a request (`name`, `location` [`path`, `query`, `header`, `cookie`], `required`, `description`, `schema`, `default`, `example`, `style`, `explode`).
|
|
99
|
+
* **`RequestBody`**: Defines the payload expected by POST/PUT/PATCH operations (`required`, `description`, `content`).
|
|
100
|
+
* **`Response`**: Defines an HTTP response status definition (`status_code`, `description`, `content`).
|
|
101
|
+
* **`MediaType`**: Maps a MIME content-type string to its schema and example payloads (`content_type`, `schema`, `example`, `examples`).
|
|
102
|
+
* **`Schema`**: Normalized schema structure representing primitive and complex types (`type`, `format`, `properties`, `items`, `required`, `enum`, `default`, `nullable`, `description`).
|
|
103
|
+
|
|
104
|
+
#### Current Scope Limitations
|
|
105
|
+
|
|
106
|
+
The Milestone 3 parser intentionally skips:
|
|
107
|
+
- Polymorphic composition keywords (`oneOf`, `anyOf`, `allOf`, `discriminator`).
|
|
108
|
+
- OpenAPI callbacks, links, and webhooks.
|
|
109
|
+
- Advanced example inheritance chains.
|
|
110
|
+
|
|
111
|
+
### 3.3 Schema Converter
|
|
112
|
+
|
|
113
|
+
The **Schema Converter** (`SchemaConverter` and `PydanticFactory`) converts internal schema models (`Schema`) into dynamic Pydantic `BaseModel` classes using `pydantic.create_model()`.
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
OpenAPI Schema
|
|
117
|
+
|
|
118
|
+
│
|
|
119
|
+
▼
|
|
120
|
+
Internal Schema Model
|
|
121
|
+
|
|
122
|
+
│
|
|
123
|
+
▼
|
|
124
|
+
Dynamic Pydantic Model (type[BaseModel])
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### OpenAPI to Python / Pydantic Mapping Table
|
|
128
|
+
|
|
129
|
+
| OpenAPI Type | Python / Pydantic Target Type | Notes / Examples |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `string` | `str` | Includes optional field descriptions |
|
|
132
|
+
| `integer` | `int` | Maps default values |
|
|
133
|
+
| `number` | `float` | Supports floats |
|
|
134
|
+
| `boolean` | `bool` | True / False |
|
|
135
|
+
| `array` | `list[T]` | Recursively typed items (e.g. `list[str]`) |
|
|
136
|
+
| `object` | Dynamic `BaseModel` | Dynamic nested models (e.g. `SearchWorksInput_Address`) |
|
|
137
|
+
| `enum` | Dynamic `Enum` | String Enum subclass (e.g. `SortEnum`) |
|
|
138
|
+
|
|
139
|
+
#### Model Naming Conventions
|
|
140
|
+
|
|
141
|
+
* **Operation Models**: `{CamelCaseOperationName}Input` (e.g., `SearchWorksInput`).
|
|
142
|
+
* **Nested Object Models**: `{ParentModel}_{CamelCaseFieldName}` (e.g., `SearchWorksInput_Address`).
|
|
143
|
+
* **Dynamic Enums**: `{ParentModel}_{CamelCaseFieldName}Enum` (e.g., `SearchWorksInput_SortEnum`).
|
|
144
|
+
|
|
145
|
+
#### Current Limitations
|
|
146
|
+
|
|
147
|
+
The converter currently skips:
|
|
148
|
+
- Polymorphic composition keywords (`oneOf`, `anyOf`, `allOf`, `discriminator`).
|
|
149
|
+
- Recursive schemas.
|
|
150
|
+
- XML schema options.
|
|
151
|
+
- Complex union types beyond `Optional`.
|
|
152
|
+
|
|
153
|
+
### 3.4 Async HTTP Executor Engine
|
|
154
|
+
|
|
155
|
+
The **Async HTTP Executor** (`AsyncHTTPExecutor`) executes an `Operation` asynchronously using `httpx.AsyncClient`, transforming inputs into normalized `ResponseData` instances.
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
Operation + Validated Arguments
|
|
159
|
+
│
|
|
160
|
+
▼
|
|
161
|
+
[ RequestBuilder ]
|
|
162
|
+
│
|
|
163
|
+
▼
|
|
164
|
+
[ AuthProvider ]
|
|
165
|
+
│
|
|
166
|
+
▼
|
|
167
|
+
[ AsyncHTTPExecutor ] ──► ( httpx.AsyncClient )
|
|
168
|
+
│
|
|
169
|
+
▼
|
|
170
|
+
[ ResponseParser ]
|
|
171
|
+
│
|
|
172
|
+
▼
|
|
173
|
+
ResponseData
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Key Architecture Components
|
|
177
|
+
|
|
178
|
+
* **`RequestBuilder`**: Translates path, query, header, cookie, and JSON body parameters into a `BuiltRequest` object.
|
|
179
|
+
* **`AuthProvider`**: Abstract interface (`NoAuth`, `BearerAuth`, `APIKeyHeaderAuth`, `APIKeyQueryAuth`, `BasicAuth`) for injecting security credentials.
|
|
180
|
+
* **`ResponseParser`**: Normalizes HTTP response payloads into `ResponseData` (`status_code`, `headers`, `body`, `raw`), attempting JSON decoding with graceful plain text fallback.
|
|
181
|
+
|
|
182
|
+
#### Exception Hierarchy
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
OpenAPIError
|
|
186
|
+
└── HTTPExecutionError
|
|
187
|
+
├── AuthenticationError
|
|
188
|
+
├── RequestValidationError
|
|
189
|
+
├── ResponseParsingError
|
|
190
|
+
└── ExecutionTimeoutError
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 3.5 Authentication Provider
|
|
194
|
+
|
|
195
|
+
The **Authentication Provider** manages auth headers and query parameters dynamically. It supports multiple authentication schemes (API Key, HTTP Bearer, HTTP Basic, OAuth2) and securely injects credentials into outbound HTTP requests without exposing secret values to the LLM agent or tool definitions.
|
|
196
|
+
|
|
197
|
+
### 3.6 Tool Generator
|
|
198
|
+
|
|
199
|
+
The **Tool Generator** acts as the high-level factory interface for end users. It converts parsed operations into `langchain_core.tools.BaseTool` instances. It supports configuration options such as filtering by HTTP method, operation tags, or path patterns, as well as customizing tool naming conventions and prompt description templates.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 4. Data Flow
|
|
204
|
+
|
|
205
|
+
1. **Initialization**: The user passes an OpenAPI spec source (path, URL, or dict) to the `OpenAPIToolset` factory.
|
|
206
|
+
2. **Ingestion & Parsing**: The `OpenAPI Loader` reads the spec, resolves reference pointers, and creates an immutable `OpenAPISpec` internal model.
|
|
207
|
+
3. **Tool Creation**:
|
|
208
|
+
* For each selected operation in the specification, the `Schema Converter` builds a Pydantic input model (`args_schema`).
|
|
209
|
+
* The `Tool Generator` constructs a native `BaseTool` wrapping the operation metadata, input schema, and bound `HTTP Executor`.
|
|
210
|
+
4. **Agent Invocation**:
|
|
211
|
+
* An LLM agent invokes the tool with generated JSON arguments.
|
|
212
|
+
* LangChain validates the arguments against the tool's Pydantic `args_schema`.
|
|
213
|
+
* The tool forwards validated parameters to the `HTTP Executor`.
|
|
214
|
+
* The `Authentication Provider` attaches necessary headers/credentials.
|
|
215
|
+
* The `HTTP Executor` performs the request asynchronously and returns formatted response content back to the agent.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 5. Future Extensibility
|
|
220
|
+
|
|
221
|
+
* **Custom Transport Adapters**: Ability to plug in alternative HTTP execution engines (e.g., custom `aiohttp` or enterprise proxy clients).
|
|
222
|
+
* **Response Summarizers / Truncators**: Middleware hooks to format or summarize large API responses before returning them to LLM context windows.
|
|
223
|
+
* **Custom Auth Handlers**: Support for enterprise authentication mechanisms like AWS SigV4 or custom HMAC header signing.
|
|
224
|
+
* **GraphQL / gRPC Adapters**: Future extension of the tool generator interface to support multi-protocol tool synthesis alongside OpenAPI.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `langchain-openapi` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2026-08-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **First Production Release (v1.0.0)**.
|
|
14
|
+
- **OpenAPI Loader**: Load specs from remote URLs, local JSON/YAML files, or Python dictionaries.
|
|
15
|
+
- **OpenAPI Parser**: Strongly typed internal data models for operations, parameters, request bodies, and responses with local `$ref` resolution.
|
|
16
|
+
- **Schema Converter Engine**: Convert JSON Schema parameters and request bodies to dynamic Pydantic models at runtime with optional multi-page pagination controls.
|
|
17
|
+
- **Async HTTP Executor Engine**: Asynchronous execution using `httpx.AsyncClient` with dynamic parameter formatting and response parsing.
|
|
18
|
+
- **LangChain Tool Factory**: Convert OpenAPI operations into dynamic LangChain `StructuredTool` collections with filtering options.
|
|
19
|
+
- **Authentication & Request Providers**: Pluggable provider system (`BearerAuthProvider`, `APIKeyHeaderProvider`, `APIKeyQueryProvider`, `BasicAuthProvider`, `CompositeProvider`).
|
|
20
|
+
- **Production Middleware**: Onion-style pipeline (`RetryMiddleware`, `RateLimitMiddleware`, `CacheMiddleware`, `PaginationMiddleware`, `LoggingMiddleware`).
|
|
21
|
+
- **Documentation & Examples**: Comprehensive MkDocs site, complete example applications (Crossref, GitHub, Petstore, JSONPlaceholder), and benchmark suite.
|
|
22
|
+
- **CI/CD & Release Automation**: GitHub Actions for CI, Release generation, PyPI Trusted Publishing, and GitHub Pages deployment.
|