caesar-search 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.
@@ -0,0 +1,35 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v5
16
+ - uses: astral-sh/setup-uv@v5
17
+ - run: uv sync --frozen
18
+ - run: uv run ruff check .
19
+ - run: uv run ruff format --check src tests
20
+ - run: uv run mypy
21
+ - run: uv run pytest
22
+ - name: Generated models are in sync with the vendored spec
23
+ run: |
24
+ uv run datamodel-codegen
25
+ git diff --exit-code src/caesar_search/models/_models.py
26
+
27
+ gitleaks:
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v5
31
+ with:
32
+ fetch-depth: 0
33
+ - run: |
34
+ docker run --rm -v "$PWD:/repo" ghcr.io/gitleaks/gitleaks:latest \
35
+ git --redact --no-banner /repo
@@ -0,0 +1,31 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+ workflow_dispatch: {}
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ pypi:
13
+ runs-on: ubuntu-latest
14
+ # Must match the trusted-publisher environment configured on PyPI.
15
+ environment: pypi
16
+ permissions:
17
+ contents: write
18
+ id-token: write
19
+ steps:
20
+ - uses: actions/checkout@v5
21
+ - uses: astral-sh/setup-uv@v5
22
+ - run: uv sync --frozen
23
+ - run: uv run pytest
24
+ - run: uv build
25
+ - name: Publish to PyPI (trusted publishing)
26
+ uses: pypa/gh-action-pypi-publish@release/v1
27
+ - name: Create GitHub release
28
+ if: startsWith(github.ref, 'refs/tags/')
29
+ env:
30
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31
+ run: gh release create "${GITHUB_REF_NAME}" --generate-notes || true
@@ -0,0 +1,124 @@
1
+ name: spec-sync
2
+
3
+ # Polls the live public OpenAPI spec, regenerates the models when it changes,
4
+ # classifies the change with oasdiff, and auto-releases non-breaking updates.
5
+ # Breaking changes open a PR that waits for review. Also replays the live
6
+ # contract flow nightly so server-side drift is caught even without spec
7
+ # changes. No monorepo credentials required: the spec travels over the public
8
+ # spec URL.
9
+
10
+ on:
11
+ schedule:
12
+ - cron: "23 */6 * * *"
13
+ workflow_dispatch: {}
14
+
15
+ env:
16
+ SPEC_URL: https://search-api-staging-779189860552.europe-west1.run.app/openapi/public.json
17
+
18
+ permissions:
19
+ contents: write
20
+ pull-requests: write
21
+ actions: write
22
+
23
+ jobs:
24
+ contract:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v5
28
+ - uses: astral-sh/setup-uv@v5
29
+ - run: uv sync --frozen
30
+ - name: Replay search -> read -> feedback against staging
31
+ env:
32
+ CAESAR_CONTRACT: "1"
33
+ run: uv run pytest tests/contract -v
34
+
35
+ sync:
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v5
39
+ - uses: astral-sh/setup-uv@v5
40
+ - name: Fetch live spec and detect drift
41
+ id: drift
42
+ run: |
43
+ curl -fsS "$SPEC_URL" -o /tmp/live-spec.json
44
+ jq -S . /tmp/live-spec.json > /tmp/live-normalized.json
45
+ jq -S . spec/openapi-public.json > /tmp/vendored-normalized.json
46
+ if cmp -s /tmp/live-normalized.json /tmp/vendored-normalized.json; then
47
+ echo "changed=false" >> "$GITHUB_OUTPUT"
48
+ else
49
+ echo "changed=true" >> "$GITHUB_OUTPUT"
50
+ fi
51
+ - name: Classify the change
52
+ id: classify
53
+ if: steps.drift.outputs.changed == 'true'
54
+ run: |
55
+ docker run --rm -v /tmp:/tmp -v "$PWD/spec:/spec" ghcr.io/oasdiff/oasdiff \
56
+ breaking /spec/openapi-public.json /tmp/live-spec.json > /tmp/breaking.txt || true
57
+ if [ -s /tmp/breaking.txt ]; then
58
+ echo "breaking=true" >> "$GITHUB_OUTPUT"
59
+ else
60
+ echo "breaking=false" >> "$GITHUB_OUTPUT"
61
+ fi
62
+ {
63
+ echo "summary<<EOF"
64
+ docker run --rm -v /tmp:/tmp -v "$PWD/spec:/spec" ghcr.io/oasdiff/oasdiff \
65
+ changelog /spec/openapi-public.json /tmp/live-spec.json || true
66
+ echo "EOF"
67
+ } >> "$GITHUB_OUTPUT"
68
+ - name: Regenerate and test
69
+ if: steps.drift.outputs.changed == 'true'
70
+ run: |
71
+ cp /tmp/live-spec.json spec/openapi-public.json
72
+ uv sync --frozen
73
+ uv run datamodel-codegen
74
+ uv run ruff check .
75
+ uv run mypy
76
+ uv run pytest
77
+ - name: Auto-release (non-breaking)
78
+ if: steps.drift.outputs.changed == 'true' && steps.classify.outputs.breaking == 'false'
79
+ env:
80
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81
+ run: |
82
+ git config user.name "caesar-spec-sync"
83
+ git config user.email "releases@caesar.xyz"
84
+ VERSION=$(uv run python -c "
85
+ import re
86
+ content = open('pyproject.toml').read()
87
+ current = re.search(r'version = \"(\d+)\.(\d+)\.(\d+)\"', content)
88
+ major, minor, patch = map(int, current.groups())
89
+ print(f'{major}.{minor}.{patch + 1}')
90
+ ")
91
+ uv run python - "$VERSION" <<'PYEOF'
92
+ import re, sys
93
+ version = sys.argv[1]
94
+ for path in ("pyproject.toml", "src/caesar_search/_version.py"):
95
+ content = open(path).read()
96
+ content = re.sub(r'version = "\d+\.\d+\.\d+"', f'version = "{version}"', content)
97
+ content = re.sub(r'__version__ = "\d+\.\d+\.\d+"', f'__version__ = "{version}"', content)
98
+ open(path, "w").write(content)
99
+ PYEOF
100
+ uv lock
101
+ git add -A
102
+ git commit -m "chore: regenerate from updated public spec (v${VERSION})"
103
+ git tag "v${VERSION}"
104
+ git push origin main "v${VERSION}"
105
+ # Tags pushed with GITHUB_TOKEN do not trigger workflows; dispatch
106
+ # the release workflow explicitly (workflow_dispatch is exempt).
107
+ gh workflow run release.yml --ref "v${VERSION}"
108
+ - name: Open review PR (breaking)
109
+ if: steps.drift.outputs.changed == 'true' && steps.classify.outputs.breaking == 'true'
110
+ env:
111
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112
+ SUMMARY: ${{ steps.classify.outputs.summary }}
113
+ run: |
114
+ git config user.name "caesar-spec-sync"
115
+ git config user.email "releases@caesar.xyz"
116
+ BRANCH="spec-sync/breaking-$(date -u +%Y%m%d%H%M)"
117
+ git checkout -b "$BRANCH"
118
+ git add -A
119
+ git commit -m "feat!: regenerate from updated public spec (breaking)"
120
+ git push origin "$BRANCH"
121
+ gh pr create --title "Breaking spec change: review required" \
122
+ --body "$(printf 'oasdiff classified this spec update as breaking.\n\n```\n%s\n```\n\nMerge and tag a minor release after review.' "$SUMMARY")" \
123
+ --label breaking || gh pr create --title "Breaking spec change: review required" \
124
+ --body "oasdiff classified this spec update as breaking. Merge and tag a minor release after review."
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
5
+ .mypy_cache/
6
+ .pytest_cache/
7
+ .ruff_cache/
@@ -0,0 +1,2 @@
1
+ [extend]
2
+ useDefault = true
@@ -0,0 +1,28 @@
1
+ # AGENTS.md
2
+
3
+ Guidance for AI agents using and maintaining `caesar-search` (Python).
4
+
5
+ ## Using the SDK
6
+
7
+ - The loop: `search()` → pick `doc_id` → `read()` → optionally `feedback()`. Thread provenance handles (`doc_id`, `search_id`) between calls.
8
+ - `read()` accepts a doc_id or URL positionally. A truncated read sets `content.truncated`; continue with `start_char=content.start_char + content.char_count` — do not retry with a bigger `max_chars`.
9
+ - `search(verbosity=...)` controls payload shape: `ids_only` (handles only), `compact`, `standard` (default), `full` (adds provenance). `max_chars_total=` sets a hard response budget.
10
+ - Set `CAESAR_API_KEY`; never hardcode keys. Exceptions: catch `AuthenticationError`/`RateLimitError`/`APIStatusError`.
11
+
12
+ ## Common mistakes
13
+
14
+ | Mistake | Correction |
15
+ |---|---|
16
+ | `client.search(query="...", limit=5)` | The parameter is `max_results` |
17
+ | `client.document(...)` / `client.get_document(...)` | The method is `read()` |
18
+ | Retrying truncated reads with bigger `max_chars` | Use `start_char` continuation |
19
+ | Expecting camelCase fields | Models are snake_case, matching the API |
20
+ | Hand-editing `models/_models.py` | Generated from `spec/openapi-public.json`; run the generator instead |
21
+
22
+ ## Maintaining this repo
23
+
24
+ - `spec/openapi-public.json` is the vendored contract; `uv run datamodel-codegen` regenerates `src/caesar_search/models/_models.py`. CI fails if the generated file is dirty against the spec.
25
+ - The spec-sync workflow polls the live public spec, regenerates, classifies the diff with oasdiff, and auto-releases non-breaking changes; breaking changes open a PR for review.
26
+ - `uv run pytest` (hermetic, httpx MockTransport) must pass; contract tests are gated behind `CAESAR_CONTRACT=1`.
27
+ - `uv run mypy` strict on the veneer; `uv run ruff check`.
28
+ - Never name upstream search/inference providers in code, docs, or errors.
@@ -0,0 +1,3 @@
1
+ # Changelog
2
+
3
+ Releases are documented on the [GitHub releases page](https://github.com/caesar-data/caesar-search-python/releases).
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Caesar
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,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: caesar-search
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the Caesar search API — web search with provenance, built for agents.
5
+ Project-URL: Homepage, https://github.com/caesar-data/caesar-search-python
6
+ Project-URL: Repository, https://github.com/caesar-data/caesar-search-python
7
+ Project-URL: Issues, https://github.com/caesar-data/caesar-search-python/issues
8
+ Project-URL: Changelog, https://github.com/caesar-data/caesar-search-python/releases
9
+ Author: Caesar
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agents,caesar,search,web-search
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
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: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: httpx>=0.27
23
+ Requires-Dist: pydantic>=2.7
24
+ Description-Content-Type: text/markdown
25
+
26
+ # caesar-search (Python)
27
+
28
+ Official Python SDK for the Caesar search API — web search with provenance, built for agents.
29
+
30
+ ## Quickstart
31
+
32
+ ```python
33
+ # pip install caesar-search (or: uv add caesar-search)
34
+ from caesar_search import Caesar
35
+
36
+ client = Caesar() # reads CAESAR_API_KEY; anonymous tier works without a key
37
+ results = client.search("rust async runtime comparison", max_results=5)
38
+ doc = client.read(results.results[0].doc_id, query="which runtime is fastest")
39
+ client.feedback("result_helpful", search_id=results.search_id, doc_id=doc.doc.doc_id)
40
+ ```
41
+
42
+ ## Clients
43
+
44
+ - `Caesar` — synchronous; `AsyncCaesar` — same surface with `async`/`await`. Both support context managers.
45
+ - Methods: `search()`, `read()` (doc_id **or** URL; `start_char=` continues truncated reads), `feedback()`.
46
+ - Responses are typed pydantic v2 models generated from the public OpenAPI spec; provenance fields (`doc_id`, `search_id`, `capture_id`, canonical/source URLs, crawl dates) are preserved verbatim.
47
+ - `client.with_raw_response.search(...)` returns the raw `httpx.Response`.
48
+ - Retries: 429/5xx with capped exponential backoff honoring `Retry-After` (`max_retries=` to tune, `0` to disable).
49
+ - Config: `api_key=` / `CAESAR_API_KEY`; `base_url=` / `CAESAR_BASE_URL`.
50
+
51
+ ## Errors
52
+
53
+ `CaesarError` → `APIConnectionError` / `APITimeoutError` and `APIStatusError` (with `.status_code`, `.code`, `.message`, `.request_id`) → `AuthenticationError` (401/403), `RateLimitError` (429).
54
+
55
+ ## License
56
+
57
+ [MIT](LICENSE)
@@ -0,0 +1,32 @@
1
+ # caesar-search (Python)
2
+
3
+ Official Python SDK for the Caesar search API — web search with provenance, built for agents.
4
+
5
+ ## Quickstart
6
+
7
+ ```python
8
+ # pip install caesar-search (or: uv add caesar-search)
9
+ from caesar_search import Caesar
10
+
11
+ client = Caesar() # reads CAESAR_API_KEY; anonymous tier works without a key
12
+ results = client.search("rust async runtime comparison", max_results=5)
13
+ doc = client.read(results.results[0].doc_id, query="which runtime is fastest")
14
+ client.feedback("result_helpful", search_id=results.search_id, doc_id=doc.doc.doc_id)
15
+ ```
16
+
17
+ ## Clients
18
+
19
+ - `Caesar` — synchronous; `AsyncCaesar` — same surface with `async`/`await`. Both support context managers.
20
+ - Methods: `search()`, `read()` (doc_id **or** URL; `start_char=` continues truncated reads), `feedback()`.
21
+ - Responses are typed pydantic v2 models generated from the public OpenAPI spec; provenance fields (`doc_id`, `search_id`, `capture_id`, canonical/source URLs, crawl dates) are preserved verbatim.
22
+ - `client.with_raw_response.search(...)` returns the raw `httpx.Response`.
23
+ - Retries: 429/5xx with capped exponential backoff honoring `Retry-After` (`max_retries=` to tune, `0` to disable).
24
+ - Config: `api_key=` / `CAESAR_API_KEY`; `base_url=` / `CAESAR_BASE_URL`.
25
+
26
+ ## Errors
27
+
28
+ `CaesarError` → `APIConnectionError` / `APITimeoutError` and `APIStatusError` (with `.status_code`, `.code`, `.message`, `.request_id`) → `AuthenticationError` (401/403), `RateLimitError` (429).
29
+
30
+ ## License
31
+
32
+ [MIT](LICENSE)
@@ -0,0 +1,4 @@
1
+ # Security
2
+
3
+ Report vulnerabilities privately via GitHub security advisories on this repository.
4
+ The SDK never logs API keys.
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://context7.com/schema/context7.json",
3
+ "projectTitle": "caesar-search Python SDK",
4
+ "description": "Official Python SDK for the Caesar search API: web search with provenance for agents",
5
+ "folders": [],
6
+ "excludeFolders": ["spec", ".venv"],
7
+ "rules": [
8
+ "Instantiate Caesar() or AsyncCaesar(); CAESAR_API_KEY is read from the environment",
9
+ "Methods are search(), read(), feedback(); the search size parameter is max_results",
10
+ "Continue truncated reads with start_char instead of increasing max_chars",
11
+ "Catch AuthenticationError, RateLimitError, APIStatusError from caesar_search",
12
+ "Models are generated pydantic v2; fields are snake_case"
13
+ ]
14
+ }
@@ -0,0 +1,82 @@
1
+ [project]
2
+ name = "caesar-search"
3
+ version = "0.1.0"
4
+ description = "Official Python SDK for the Caesar search API — web search with provenance, built for agents."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ authors = [{ name = "Caesar" }]
10
+ keywords = ["search", "web-search", "agents", "caesar"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Intended Audience :: Developers",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Typing :: Typed",
20
+ ]
21
+ dependencies = [
22
+ "httpx>=0.27",
23
+ "pydantic>=2.7",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/caesar-data/caesar-search-python"
28
+ Repository = "https://github.com/caesar-data/caesar-search-python"
29
+ Issues = "https://github.com/caesar-data/caesar-search-python/issues"
30
+ Changelog = "https://github.com/caesar-data/caesar-search-python/releases"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "pytest>=8",
35
+ "pytest-asyncio>=0.24",
36
+ "mypy>=1.13",
37
+ "ruff>=0.8",
38
+ "datamodel-code-generator[http]>=0.63",
39
+ ]
40
+
41
+ [build-system]
42
+ requires = ["hatchling"]
43
+ build-backend = "hatchling.build"
44
+
45
+ [tool.hatch.build.targets.wheel]
46
+ packages = ["src/caesar_search"]
47
+
48
+ [tool.ruff]
49
+ line-length = 110
50
+ target-version = "py310"
51
+ # Generated code is owned by the generator, not the formatter.
52
+ exclude = ["src/caesar_search/models/_models.py"]
53
+
54
+ [tool.ruff.lint]
55
+ select = ["E", "F", "I", "UP", "B", "SIM"]
56
+
57
+ [tool.mypy]
58
+ strict = true
59
+ files = ["src/caesar_search", "tests"]
60
+ exclude = ["src/caesar_search/models/_models\\.py"]
61
+
62
+ [[tool.mypy.overrides]]
63
+ module = "caesar_search.models._models"
64
+ ignore_errors = true
65
+
66
+ [tool.pytest.ini_options]
67
+ asyncio_mode = "auto"
68
+ testpaths = ["tests"]
69
+
70
+ [tool.datamodel-codegen]
71
+ input = "spec/openapi-public.json"
72
+ input-file-type = "openapi"
73
+ output = "src/caesar_search/models/_models.py"
74
+ output-model-type = "pydantic_v2.BaseModel"
75
+ target-python-version = "3.10"
76
+ use-schema-description = true
77
+ use-field-description = true
78
+ field-constraints = true
79
+ use-double-quotes = true
80
+ disable-timestamp = true
81
+ allow-extra-fields = true
82
+ formatters = ["black", "isort"]