knowhere-python-sdk 0.3.1__tar.gz → 0.4.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.
- knowhere_python_sdk-0.4.0/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- knowhere_python_sdk-0.4.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- knowhere_python_sdk-0.4.0/.github/ISSUE_TEMPLATE/feature-request.yml +25 -0
- knowhere_python_sdk-0.4.0/.github/pull_request_template.md +15 -0
- knowhere_python_sdk-0.4.0/.release-please-manifest.json +3 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/CHANGELOG.md +15 -0
- knowhere_python_sdk-0.4.0/CODE_OF_CONDUCT.md +29 -0
- knowhere_python_sdk-0.4.0/CONTRIBUTING.md +44 -0
- knowhere_python_sdk-0.4.0/LICENSE +21 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/PKG-INFO +23 -1
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/README.md +21 -0
- knowhere_python_sdk-0.4.0/SECURITY.md +24 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/docs/usage.md +16 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/pyproject.toml +1 -1
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/__init__.py +14 -1
- knowhere_python_sdk-0.4.0/src/knowhere/_version.py +1 -0
- knowhere_python_sdk-0.4.0/src/knowhere/resources/documents.py +191 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/types/__init__.py +14 -1
- knowhere_python_sdk-0.4.0/src/knowhere/types/document.py +78 -0
- knowhere_python_sdk-0.4.0/tests/test_documents.py +219 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_logging.py +1 -1
- knowhere_python_sdk-0.3.1/.release-please-manifest.json +0 -3
- knowhere_python_sdk-0.3.1/src/knowhere/_version.py +0 -1
- knowhere_python_sdk-0.3.1/src/knowhere/resources/documents.py +0 -74
- knowhere_python_sdk-0.3.1/src/knowhere/types/document.py +0 -28
- knowhere_python_sdk-0.3.1/tests/test_documents.py +0 -106
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/.github/workflows/ci.yml +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/.github/workflows/publish-pypi.yml +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/.github/workflows/publish.yml +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/.gitignore +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/examples/async_usage.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/examples/error_handling.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/examples/parse_file.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/examples/parse_url.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/examples/step_by_step.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/release-please-config.json +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_base_client.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_client.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_constants.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_exceptions.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_logging.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_response.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/_types.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/lib/__init__.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/lib/polling.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/lib/result_parser.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/lib/upload.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/py.typed +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/resources/__init__.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/resources/_base.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/resources/jobs.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/resources/retrieval.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/types/job.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/types/params.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/types/result.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/types/retrieval.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/src/knowhere/types/shared.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/__init__.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/conftest.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/fixtures/real_result.zip +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_client.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_exceptions.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_jobs.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_models.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_parse.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_polling.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_result_parser.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_retrieval.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_retry.py +0 -0
- {knowhere_python_sdk-0.3.1 → knowhere_python_sdk-0.4.0}/tests/test_upload.py +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Report a reproducible problem in the Python SDK.
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels:
|
|
5
|
+
- bug
|
|
6
|
+
body:
|
|
7
|
+
- type: textarea
|
|
8
|
+
id: summary
|
|
9
|
+
attributes:
|
|
10
|
+
label: Summary
|
|
11
|
+
description: What happened, and what did you expect instead?
|
|
12
|
+
validations:
|
|
13
|
+
required: true
|
|
14
|
+
- type: input
|
|
15
|
+
id: sdk-version
|
|
16
|
+
attributes:
|
|
17
|
+
label: SDK version
|
|
18
|
+
placeholder: 0.3.1
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
- type: input
|
|
22
|
+
id: python-version
|
|
23
|
+
attributes:
|
|
24
|
+
label: Python version
|
|
25
|
+
placeholder: 3.11.9
|
|
26
|
+
validations:
|
|
27
|
+
required: true
|
|
28
|
+
- type: input
|
|
29
|
+
id: os
|
|
30
|
+
attributes:
|
|
31
|
+
label: Operating system
|
|
32
|
+
placeholder: macOS 15.4 / Ubuntu 24.04
|
|
33
|
+
- type: textarea
|
|
34
|
+
id: reproduction
|
|
35
|
+
attributes:
|
|
36
|
+
label: Reproduction
|
|
37
|
+
description: Minimal code or steps to reproduce the issue.
|
|
38
|
+
render: python
|
|
39
|
+
validations:
|
|
40
|
+
required: true
|
|
41
|
+
- type: textarea
|
|
42
|
+
id: logs
|
|
43
|
+
attributes:
|
|
44
|
+
label: Relevant logs or tracebacks
|
|
45
|
+
render: text
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: Knowhere documentation
|
|
4
|
+
url: https://docs.knowhereto.ai
|
|
5
|
+
about: Check the public docs before opening a support issue.
|
|
6
|
+
- name: Security report
|
|
7
|
+
url: mailto:team@knowhereto.ai?subject=Security%20report%20for%20knowhere-python-sdk
|
|
8
|
+
about: Report vulnerabilities privately by email.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Propose an improvement for the Python SDK.
|
|
3
|
+
title: "[Feature]: "
|
|
4
|
+
labels:
|
|
5
|
+
- enhancement
|
|
6
|
+
body:
|
|
7
|
+
- type: textarea
|
|
8
|
+
id: problem
|
|
9
|
+
attributes:
|
|
10
|
+
label: Problem statement
|
|
11
|
+
description: What developer problem are you trying to solve?
|
|
12
|
+
validations:
|
|
13
|
+
required: true
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: proposal
|
|
16
|
+
attributes:
|
|
17
|
+
label: Proposed solution
|
|
18
|
+
description: Describe the API or behavior you want to add or improve.
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
- type: textarea
|
|
22
|
+
id: alternatives
|
|
23
|
+
attributes:
|
|
24
|
+
label: Alternatives considered
|
|
25
|
+
description: Describe any workarounds or alternative designs you considered.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
- describe the change
|
|
4
|
+
- describe any public API impact
|
|
5
|
+
|
|
6
|
+
## Verification
|
|
7
|
+
|
|
8
|
+
- list the commands you ran
|
|
9
|
+
- list any manual checks you performed
|
|
10
|
+
|
|
11
|
+
## Checklist
|
|
12
|
+
|
|
13
|
+
- [ ] Tests were added or updated when behavior changed
|
|
14
|
+
- [ ] Public docs or examples were updated when needed
|
|
15
|
+
- [ ] The pull request description explains any breaking or user-visible change
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.0](https://github.com/Ontos-AI/knowhere-python-sdk/compare/v0.3.2...v0.4.0) (2026-04-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add document chunks resource methods ([73094d4](https://github.com/Ontos-AI/knowhere-python-sdk/commit/73094d4f95ef693785fa3965f6f2a223dfd2a350))
|
|
9
|
+
|
|
10
|
+
## [0.3.2](https://github.com/Ontos-AI/knowhere-python-sdk/compare/v0.3.1...v0.3.2) (2026-04-23)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Chores
|
|
14
|
+
|
|
15
|
+
* harden python sdk OSS surface ([e7d9779](https://github.com/Ontos-AI/knowhere-python-sdk/commit/e7d9779502327d2bd9e4f27e666244d34f8fafb7))
|
|
16
|
+
* harden Python SDK OSS surface ([a9396cd](https://github.com/Ontos-AI/knowhere-python-sdk/commit/a9396cda70eabcba66172884e38045caefc85a01))
|
|
17
|
+
|
|
3
18
|
## [0.3.1](https://github.com/Ontos-AI/knowhere-python-sdk/compare/v0.3.0...v0.3.1) (2026-04-22)
|
|
4
19
|
|
|
5
20
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
We want the Knowhere Python SDK community to be respectful, constructive, and
|
|
4
|
+
welcoming.
|
|
5
|
+
|
|
6
|
+
## Expected Behavior
|
|
7
|
+
|
|
8
|
+
- Be respectful in discussions and code review.
|
|
9
|
+
- Assume good intent and give actionable feedback.
|
|
10
|
+
- Focus on technical substance instead of personal attacks.
|
|
11
|
+
- Help keep the project useful for a broad developer audience.
|
|
12
|
+
|
|
13
|
+
## Unacceptable Behavior
|
|
14
|
+
|
|
15
|
+
- Harassment, discrimination, or hateful conduct
|
|
16
|
+
- Threats, intimidation, or doxxing
|
|
17
|
+
- Spam, trolling, or intentionally disruptive behavior
|
|
18
|
+
- Sharing private information without permission
|
|
19
|
+
|
|
20
|
+
## Enforcement
|
|
21
|
+
|
|
22
|
+
Maintainers may edit or remove content, close discussions, or restrict access
|
|
23
|
+
when behavior harms the project or its contributors.
|
|
24
|
+
|
|
25
|
+
To report a problem, email `team@knowhereto.ai` with:
|
|
26
|
+
|
|
27
|
+
- the repository name
|
|
28
|
+
- a link or screenshot if available
|
|
29
|
+
- a short description of what happened
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for contributing to the Knowhere Python SDK.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
Requirements:
|
|
8
|
+
|
|
9
|
+
- Python 3.9+
|
|
10
|
+
- `uv`
|
|
11
|
+
|
|
12
|
+
Clone the repository and install the full development environment:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
uv sync --all-extras
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Local Checks
|
|
19
|
+
|
|
20
|
+
Run these commands before opening a pull request:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
uv run ruff check src/
|
|
24
|
+
uv run mypy src/knowhere
|
|
25
|
+
uv run pytest -q
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If you change public behavior, also update the relevant documentation in:
|
|
29
|
+
|
|
30
|
+
- `README.md`
|
|
31
|
+
- `docs/usage.md`
|
|
32
|
+
- `examples/`
|
|
33
|
+
|
|
34
|
+
## Pull Requests
|
|
35
|
+
|
|
36
|
+
Please keep pull requests focused and easy to review.
|
|
37
|
+
|
|
38
|
+
Recommended checklist:
|
|
39
|
+
|
|
40
|
+
1. Add or update tests for behavior changes.
|
|
41
|
+
2. Keep public types and examples in sync with the implementation.
|
|
42
|
+
3. Document any breaking or user-visible changes in the pull request description.
|
|
43
|
+
|
|
44
|
+
Maintainers handle versioning and release automation through GitHub Actions.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Knowhere Team
|
|
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.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: knowhere-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Official Python SDK for the Knowhere document parsing API
|
|
5
5
|
Project-URL: Homepage, https://knowhereto.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.knowhereto.ai
|
|
7
7
|
Project-URL: Repository, https://github.com/Ontos-AI/knowhere-python-sdk
|
|
8
8
|
Author-email: Knowhere Team <team@knowhereto.ai>
|
|
9
9
|
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
10
11
|
Classifier: Development Status :: 3 - Alpha
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -117,6 +118,21 @@ update_job = client.jobs.create(
|
|
|
117
118
|
document = client.documents.get(document_id)
|
|
118
119
|
print(document.status)
|
|
119
120
|
|
|
121
|
+
chunks = client.documents.list_chunks(
|
|
122
|
+
document_id,
|
|
123
|
+
page=1,
|
|
124
|
+
page_size=50,
|
|
125
|
+
chunk_type="text",
|
|
126
|
+
)
|
|
127
|
+
print(chunks.pagination.total)
|
|
128
|
+
if chunks.chunks:
|
|
129
|
+
chunk = client.documents.get_chunk(
|
|
130
|
+
document_id,
|
|
131
|
+
chunks.chunks[0].id,
|
|
132
|
+
include_asset_urls=True,
|
|
133
|
+
)
|
|
134
|
+
print(chunk.chunk.content)
|
|
135
|
+
|
|
120
136
|
client.documents.archive(document_id)
|
|
121
137
|
```
|
|
122
138
|
|
|
@@ -305,6 +321,12 @@ We publish stable releases to [PyPI](https://pypi.org/project/knowhere-python-sd
|
|
|
305
321
|
- [pydantic](https://docs.pydantic.dev/) `>=2.0.0,<3.0`
|
|
306
322
|
- [typing-extensions](https://pypi.org/project/typing-extensions/) `>=4.7.0`
|
|
307
323
|
|
|
324
|
+
## Community
|
|
325
|
+
|
|
326
|
+
- Contributing guide: [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
327
|
+
- Security policy: [SECURITY.md](./SECURITY.md)
|
|
328
|
+
- Code of conduct: [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md)
|
|
329
|
+
|
|
308
330
|
## License
|
|
309
331
|
|
|
310
332
|
MIT
|
|
@@ -85,6 +85,21 @@ update_job = client.jobs.create(
|
|
|
85
85
|
document = client.documents.get(document_id)
|
|
86
86
|
print(document.status)
|
|
87
87
|
|
|
88
|
+
chunks = client.documents.list_chunks(
|
|
89
|
+
document_id,
|
|
90
|
+
page=1,
|
|
91
|
+
page_size=50,
|
|
92
|
+
chunk_type="text",
|
|
93
|
+
)
|
|
94
|
+
print(chunks.pagination.total)
|
|
95
|
+
if chunks.chunks:
|
|
96
|
+
chunk = client.documents.get_chunk(
|
|
97
|
+
document_id,
|
|
98
|
+
chunks.chunks[0].id,
|
|
99
|
+
include_asset_urls=True,
|
|
100
|
+
)
|
|
101
|
+
print(chunk.chunk.content)
|
|
102
|
+
|
|
88
103
|
client.documents.archive(document_id)
|
|
89
104
|
```
|
|
90
105
|
|
|
@@ -273,6 +288,12 @@ We publish stable releases to [PyPI](https://pypi.org/project/knowhere-python-sd
|
|
|
273
288
|
- [pydantic](https://docs.pydantic.dev/) `>=2.0.0,<3.0`
|
|
274
289
|
- [typing-extensions](https://pypi.org/project/typing-extensions/) `>=4.7.0`
|
|
275
290
|
|
|
291
|
+
## Community
|
|
292
|
+
|
|
293
|
+
- Contributing guide: [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
294
|
+
- Security policy: [SECURITY.md](./SECURITY.md)
|
|
295
|
+
- Code of conduct: [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md)
|
|
296
|
+
|
|
276
297
|
## License
|
|
277
298
|
|
|
278
299
|
MIT
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Only the latest published release line is supported for security fixes.
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| Latest release | Yes |
|
|
10
|
+
| Older releases | No |
|
|
11
|
+
|
|
12
|
+
## Reporting a Vulnerability
|
|
13
|
+
|
|
14
|
+
Please do not open public GitHub issues for suspected vulnerabilities.
|
|
15
|
+
|
|
16
|
+
Instead, email `team@knowhereto.ai` with:
|
|
17
|
+
|
|
18
|
+
- the repository name
|
|
19
|
+
- a clear description of the issue
|
|
20
|
+
- reproduction steps or a proof of concept
|
|
21
|
+
- impact assessment if known
|
|
22
|
+
|
|
23
|
+
We will acknowledge the report, validate it, and coordinate remediation before
|
|
24
|
+
public disclosure.
|
|
@@ -521,6 +521,22 @@ for document in document_list.documents:
|
|
|
521
521
|
document = client.documents.get("doc_123")
|
|
522
522
|
print(document.current_job_result_id)
|
|
523
523
|
|
|
524
|
+
chunks = client.documents.list_chunks(
|
|
525
|
+
"doc_123",
|
|
526
|
+
page=1,
|
|
527
|
+
page_size=50,
|
|
528
|
+
chunk_type="text",
|
|
529
|
+
)
|
|
530
|
+
for chunk in chunks.chunks:
|
|
531
|
+
print(chunk.id, chunk.content)
|
|
532
|
+
|
|
533
|
+
image_chunk = client.documents.get_chunk(
|
|
534
|
+
"doc_123",
|
|
535
|
+
"dchk_123",
|
|
536
|
+
include_asset_urls=True,
|
|
537
|
+
)
|
|
538
|
+
print(image_chunk.chunk.asset_url)
|
|
539
|
+
|
|
524
540
|
archived = client.documents.archive("doc_123")
|
|
525
541
|
print(archived.status) # "archived"
|
|
526
542
|
```
|
|
@@ -35,7 +35,15 @@ from knowhere._exceptions import (
|
|
|
35
35
|
)
|
|
36
36
|
from knowhere._types import PollProgressCallback, UploadProgressCallback
|
|
37
37
|
from knowhere._version import __version__
|
|
38
|
-
from knowhere.types.document import
|
|
38
|
+
from knowhere.types.document import (
|
|
39
|
+
Document,
|
|
40
|
+
DocumentChunk,
|
|
41
|
+
DocumentChunkListResponse,
|
|
42
|
+
DocumentChunkPagination,
|
|
43
|
+
DocumentChunkResponse,
|
|
44
|
+
DocumentChunkType,
|
|
45
|
+
DocumentListResponse,
|
|
46
|
+
)
|
|
39
47
|
from knowhere.types.job import Job, JobError, JobProgress, JobResult
|
|
40
48
|
from knowhere.types.params import ParsingParams, WebhookConfig
|
|
41
49
|
from knowhere.types.retrieval import (
|
|
@@ -98,6 +106,11 @@ __all__: list[str] = [
|
|
|
98
106
|
"JobResult",
|
|
99
107
|
# Document types
|
|
100
108
|
"Document",
|
|
109
|
+
"DocumentChunk",
|
|
110
|
+
"DocumentChunkListResponse",
|
|
111
|
+
"DocumentChunkPagination",
|
|
112
|
+
"DocumentChunkResponse",
|
|
113
|
+
"DocumentChunkType",
|
|
101
114
|
"DocumentListResponse",
|
|
102
115
|
# Retrieval types
|
|
103
116
|
"RetrievalChannel",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.0" # x-release-please-version
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"""Documents resource for canonical document lifecycle operations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
from knowhere.resources._base import AsyncAPIResource, SyncAPIResource
|
|
8
|
+
from knowhere.types.document import (
|
|
9
|
+
Document,
|
|
10
|
+
DocumentChunkListResponse,
|
|
11
|
+
DocumentChunkResponse,
|
|
12
|
+
DocumentChunkType,
|
|
13
|
+
DocumentListResponse,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Documents(SyncAPIResource):
|
|
18
|
+
"""Synchronous interface for ``/v1/documents`` endpoints."""
|
|
19
|
+
|
|
20
|
+
def list(self, *, namespace: Optional[str] = None) -> DocumentListResponse:
|
|
21
|
+
"""List canonical documents in a namespace."""
|
|
22
|
+
params: Dict[str, Any] = {}
|
|
23
|
+
if namespace is not None:
|
|
24
|
+
params["namespace"] = namespace
|
|
25
|
+
|
|
26
|
+
return self._request(
|
|
27
|
+
"GET",
|
|
28
|
+
"v1/documents",
|
|
29
|
+
params=params or None,
|
|
30
|
+
cast_to=DocumentListResponse,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def get(self, document_id: str) -> Document:
|
|
34
|
+
"""Get one canonical document by ID."""
|
|
35
|
+
return self._request(
|
|
36
|
+
"GET",
|
|
37
|
+
f"v1/documents/{document_id}",
|
|
38
|
+
cast_to=Document,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def list_chunks(
|
|
42
|
+
self,
|
|
43
|
+
document_id: str,
|
|
44
|
+
*,
|
|
45
|
+
page: int = 1,
|
|
46
|
+
page_size: int = 50,
|
|
47
|
+
chunk_type: Optional[DocumentChunkType] = None,
|
|
48
|
+
include_asset_urls: bool = False,
|
|
49
|
+
) -> DocumentChunkListResponse:
|
|
50
|
+
"""List current-revision chunks for one canonical document."""
|
|
51
|
+
params: Dict[str, Any] = _build_chunk_list_params(
|
|
52
|
+
page=page,
|
|
53
|
+
page_size=page_size,
|
|
54
|
+
chunk_type=chunk_type,
|
|
55
|
+
include_asset_urls=include_asset_urls,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
return self._request(
|
|
59
|
+
"GET",
|
|
60
|
+
f"v1/documents/{document_id}/chunks",
|
|
61
|
+
params=params or None,
|
|
62
|
+
cast_to=DocumentChunkListResponse,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def get_chunk(
|
|
66
|
+
self,
|
|
67
|
+
document_id: str,
|
|
68
|
+
document_chunk_id: str,
|
|
69
|
+
*,
|
|
70
|
+
include_asset_urls: bool = False,
|
|
71
|
+
) -> DocumentChunkResponse:
|
|
72
|
+
"""Get one current-revision chunk for one canonical document."""
|
|
73
|
+
params: Dict[str, Any] = _build_chunk_get_params(
|
|
74
|
+
include_asset_urls=include_asset_urls,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
return self._request(
|
|
78
|
+
"GET",
|
|
79
|
+
f"v1/documents/{document_id}/chunks/{document_chunk_id}",
|
|
80
|
+
params=params or None,
|
|
81
|
+
cast_to=DocumentChunkResponse,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def archive(self, document_id: str) -> Document:
|
|
85
|
+
"""Archive one canonical document by ID."""
|
|
86
|
+
return self._request(
|
|
87
|
+
"POST",
|
|
88
|
+
f"v1/documents/{document_id}/archive",
|
|
89
|
+
cast_to=Document,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AsyncDocuments(AsyncAPIResource):
|
|
94
|
+
"""Asynchronous interface for ``/v1/documents`` endpoints."""
|
|
95
|
+
|
|
96
|
+
async def list(self, *, namespace: Optional[str] = None) -> DocumentListResponse:
|
|
97
|
+
"""List canonical documents in a namespace."""
|
|
98
|
+
params: Dict[str, Any] = {}
|
|
99
|
+
if namespace is not None:
|
|
100
|
+
params["namespace"] = namespace
|
|
101
|
+
|
|
102
|
+
return await self._request(
|
|
103
|
+
"GET",
|
|
104
|
+
"v1/documents",
|
|
105
|
+
params=params or None,
|
|
106
|
+
cast_to=DocumentListResponse,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
async def get(self, document_id: str) -> Document:
|
|
110
|
+
"""Get one canonical document by ID."""
|
|
111
|
+
return await self._request(
|
|
112
|
+
"GET",
|
|
113
|
+
f"v1/documents/{document_id}",
|
|
114
|
+
cast_to=Document,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
async def list_chunks(
|
|
118
|
+
self,
|
|
119
|
+
document_id: str,
|
|
120
|
+
*,
|
|
121
|
+
page: int = 1,
|
|
122
|
+
page_size: int = 50,
|
|
123
|
+
chunk_type: Optional[DocumentChunkType] = None,
|
|
124
|
+
include_asset_urls: bool = False,
|
|
125
|
+
) -> DocumentChunkListResponse:
|
|
126
|
+
"""List current-revision chunks for one canonical document."""
|
|
127
|
+
params: Dict[str, Any] = _build_chunk_list_params(
|
|
128
|
+
page=page,
|
|
129
|
+
page_size=page_size,
|
|
130
|
+
chunk_type=chunk_type,
|
|
131
|
+
include_asset_urls=include_asset_urls,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
return await self._request(
|
|
135
|
+
"GET",
|
|
136
|
+
f"v1/documents/{document_id}/chunks",
|
|
137
|
+
params=params or None,
|
|
138
|
+
cast_to=DocumentChunkListResponse,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
async def get_chunk(
|
|
142
|
+
self,
|
|
143
|
+
document_id: str,
|
|
144
|
+
document_chunk_id: str,
|
|
145
|
+
*,
|
|
146
|
+
include_asset_urls: bool = False,
|
|
147
|
+
) -> DocumentChunkResponse:
|
|
148
|
+
"""Get one current-revision chunk for one canonical document."""
|
|
149
|
+
params: Dict[str, Any] = _build_chunk_get_params(
|
|
150
|
+
include_asset_urls=include_asset_urls,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return await self._request(
|
|
154
|
+
"GET",
|
|
155
|
+
f"v1/documents/{document_id}/chunks/{document_chunk_id}",
|
|
156
|
+
params=params or None,
|
|
157
|
+
cast_to=DocumentChunkResponse,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
async def archive(self, document_id: str) -> Document:
|
|
161
|
+
"""Archive one canonical document by ID."""
|
|
162
|
+
return await self._request(
|
|
163
|
+
"POST",
|
|
164
|
+
f"v1/documents/{document_id}/archive",
|
|
165
|
+
cast_to=Document,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _build_chunk_list_params(
|
|
170
|
+
*,
|
|
171
|
+
page: int,
|
|
172
|
+
page_size: int,
|
|
173
|
+
chunk_type: Optional[DocumentChunkType],
|
|
174
|
+
include_asset_urls: bool,
|
|
175
|
+
) -> Dict[str, Any]:
|
|
176
|
+
params: Dict[str, Any] = {}
|
|
177
|
+
if page != 1:
|
|
178
|
+
params["page"] = page
|
|
179
|
+
if page_size != 50:
|
|
180
|
+
params["page_size"] = page_size
|
|
181
|
+
if chunk_type is not None:
|
|
182
|
+
params["chunk_type"] = chunk_type
|
|
183
|
+
if include_asset_urls:
|
|
184
|
+
params["include_asset_urls"] = True
|
|
185
|
+
return params
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _build_chunk_get_params(*, include_asset_urls: bool) -> Dict[str, Any]:
|
|
189
|
+
if not include_asset_urls:
|
|
190
|
+
return {}
|
|
191
|
+
return {"include_asset_urls": True}
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from knowhere.types.document import
|
|
5
|
+
from knowhere.types.document import (
|
|
6
|
+
Document,
|
|
7
|
+
DocumentChunk,
|
|
8
|
+
DocumentChunkListResponse,
|
|
9
|
+
DocumentChunkPagination,
|
|
10
|
+
DocumentChunkResponse,
|
|
11
|
+
DocumentChunkType,
|
|
12
|
+
DocumentListResponse,
|
|
13
|
+
)
|
|
6
14
|
from knowhere.types.job import Job, JobError, JobResult
|
|
7
15
|
from knowhere.types.params import ParsingParams, WebhookConfig
|
|
8
16
|
from knowhere.types.retrieval import (
|
|
@@ -39,6 +47,11 @@ __all__: list[str] = [
|
|
|
39
47
|
"JobResult",
|
|
40
48
|
# document
|
|
41
49
|
"Document",
|
|
50
|
+
"DocumentChunk",
|
|
51
|
+
"DocumentChunkListResponse",
|
|
52
|
+
"DocumentChunkPagination",
|
|
53
|
+
"DocumentChunkResponse",
|
|
54
|
+
"DocumentChunkType",
|
|
42
55
|
"DocumentListResponse",
|
|
43
56
|
# retrieval
|
|
44
57
|
"RetrievalChannel",
|