unique-search-proxy 2026.46.0.dev6__tar.gz → 2026.46.0.dev8__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.
- unique_search_proxy-2026.46.0.dev6/README.md → unique_search_proxy-2026.46.0.dev8/PKG-INFO +33 -1
- unique_search_proxy-2026.46.0.dev6/PKG-INFO → unique_search_proxy-2026.46.0.dev8/README.md +4 -29
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/pyproject.toml +4 -3
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/__init__.py +0 -4
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/__init__.py +41 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/adapters/__init__.py +7 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/adapters/pypdf_adapter.py +42 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/adapters/pypdf_text.py +123 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/admit.py +37 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/extractor.py +81 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/process.py +207 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/runner.py +170 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/types.py +77 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf/wiring.py +69 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/registry.py +1 -2
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/service.py +144 -4
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/registry.py +2 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/monitoring/metrics.py +47 -0
- unique_search_proxy-2026.46.0.dev8/unique_search_proxy_client/web/settings/pdf.py +85 -0
- unique_search_proxy-2026.46.0.dev6/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/pdf.py +0 -10
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/health.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/agent_search.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/configuration.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/context_headers.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/crawl.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/openapi_examples.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/api/v1/search.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/app.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/context.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/bing/citation_instructions.j2 +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/bing/cleanup.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/bing/client.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/bing/instructions.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/bing/runner.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/bing/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/factory.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/service_base.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/vertexai/client.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/vertexai/gemini.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/vertexai/redirects.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/agent_engines/vertexai/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/client/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/client/azure_transport.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/client/credentials.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/client/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawl_limiter.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/errors.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/html_markdown.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/html.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/processing/processors/plain_text.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/settings.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/basic/user_agent.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/factory.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/firecrawl/polling.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/firecrawl/request_body.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/firecrawl/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/jina/request_body.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/jina/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/pinned_egress.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/tavily/request_body.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/crawlers/tavily/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/provider_response.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/providers.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/registry.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/brave/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/brave/pagination.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/brave/query_params.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/brave/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/custom_api/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/custom_api/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/descriptor.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/factory.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/google/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/google/pagination.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/google/query_params.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/google/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/pagination.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/perplexity/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/perplexity/request_body.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/perplexity/service.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/search_engines/service_base.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/url_safety/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/core/url_safety/gate.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/error_handlers.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/generator/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/generator/introspect.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/generator/schema.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/generator/template.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/generator/templates/provider_values_yaml.j2 +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/generator/values_yaml.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/metadata.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/helm/url_safety_registration.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/logging_config.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/middleware/context.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/monitoring/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/monitoring/setup.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/presets/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/presets/common.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/presets/crawl.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/presets/search.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/presets/types.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/app.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/base.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/client.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/monitoring.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/base.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/bing_agent.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/brave.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/firecrawl.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/google.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/jina.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/perplexity.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/tavily.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/providers/vertexai_agent.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/request_limits.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/settings/secret_str.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/startup_report.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/usage.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/utils/__init__.py +0 -0
- {unique_search_proxy-2026.46.0.dev6 → unique_search_proxy-2026.46.0.dev8}/unique_search_proxy_client/web/utils/url.py +0 -0
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: unique-search-proxy
|
|
3
|
+
Version: 2026.46.0.dev8
|
|
4
|
+
Summary: Web Search Proxy implementation
|
|
5
|
+
Author: ThePhilAz
|
|
6
|
+
Author-email: ThePhilAz <rami.azouz@philico.com>
|
|
7
|
+
Requires-Dist: aiohttp>=3.14.1,<4
|
|
8
|
+
Requires-Dist: fastapi>=0.133.0,<1.0.0
|
|
9
|
+
Requires-Dist: starlette>=1.3.1,<2.0.0
|
|
10
|
+
Requires-Dist: uvicorn[standard]>=0.32.0,<1.0.0
|
|
11
|
+
Requires-Dist: pydantic>=2.12.5,<3.0.0
|
|
12
|
+
Requires-Dist: httpx>=0.28.0,<0.29.0
|
|
13
|
+
Requires-Dist: python-dotenv>=1.2.1,<2.0.0
|
|
14
|
+
Requires-Dist: pydantic-settings>=2.12.0,<3.0.0
|
|
15
|
+
Requires-Dist: markdownify>=0.14.1,<1
|
|
16
|
+
Requires-Dist: azure-ai-projects>=2.3,<3
|
|
17
|
+
Requires-Dist: azure-identity>=1.25.0,<2
|
|
18
|
+
Requires-Dist: azure-core>=1.36.0,<2
|
|
19
|
+
Requires-Dist: certifi>=2025.11.12,<2027
|
|
20
|
+
Requires-Dist: google-genai>=1.73.0,<2
|
|
21
|
+
Requires-Dist: google-auth>=2.43.0,<3
|
|
22
|
+
Requires-Dist: jinja2>=3.1.6,<4
|
|
23
|
+
Requires-Dist: unique-toolkit[monitoring]>=2026.46.0.dev13,<2026.46.0rc0
|
|
24
|
+
Requires-Dist: unique-search-proxy-core>=2026.46.0.dev4,<2026.46.0rc0
|
|
25
|
+
Requires-Dist: openai>=1.105.0,<3
|
|
26
|
+
Requires-Dist: pypdf==6.21.4
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
1
30
|
# unique-search-proxy (client)
|
|
2
31
|
|
|
3
32
|
Part of [Unique Search Proxy](../README.md) · PyPI: `unique-search-proxy` · Helm: `unique-search-proxy`
|
|
@@ -214,6 +243,8 @@ Crawler discriminators: `Basic`, `Tavily`, `Jina`, `Firecrawl`.
|
|
|
214
243
|
|
|
215
244
|
**Timeout:** with `Basic`, URLs still loading just before `timeout` come back as per-URL `UPSTREAM_TIMEOUT` results next to the finished pages. A busy worker can send the response up to 5 s after `timeout`, so set your HTTP client timeout at least 5 s above it. The other crawlers fail the whole batch with a `504` at `timeout`.
|
|
216
245
|
|
|
246
|
+
**PDFs:** with `contentTypes.pdf` on (off by default), `Basic` returns a PDF's text in `content`; `raw` is always null for PDFs. The default pypdf extractor runs in `SubprocessExtractionRunner`: a short-lived child process that starts with an empty environment, has memory and CPU limits, and is killed at its time limit or the request deadline. Each worker reads `PDF_MAX_CONCURRENT_EXTRACTIONS` PDFs at a time (default 1); the rest wait. PDFs longer than `PDF_MAX_PDF_PAGES` or `PDF_MAX_EXTRACTED_CHARS` come back truncated, led by a note saying so. A PDF that can't be read fails its own URL (`PDF_UNSUPPORTED`, `UPSTREAM_ERROR`, or `UPSTREAM_TIMEOUT`). Extractors are adapters behind `PdfExtractor` in `processing/processors/pdf/adapters/`, selected with `PDF_EXTRACTOR`.
|
|
247
|
+
|
|
217
248
|
### 5.5 Errors
|
|
218
249
|
|
|
219
250
|
Structured envelope on all non-2xx responses:
|
|
@@ -250,6 +281,7 @@ Settings use pydantic-settings with per-provider env vars. Copy `.env.example` t
|
|
|
250
281
|
| Request context | (none) | `REQUIRE_CONTEXT_HEADERS`, `REJECT_UNATTRIBUTED_REQUESTS` |
|
|
251
282
|
| Prometheus | `PROMETHEUS_` | `PROMETHEUS_ENABLED` |
|
|
252
283
|
| URL safety | `URL_SAFETY_` | `URL_SAFETY_ENABLED` |
|
|
284
|
+
| PDF processing | `PDF_` | `PDF_EXTRACTOR`, `PDF_MAX_PDF_PAGES`, `PDF_EXTRACTION_TIMEOUT_SECONDS` |
|
|
253
285
|
| Container | (shell) | `HOST`, `PORT`, `WORKERS`, `LOG_LEVEL` |
|
|
254
286
|
|
|
255
287
|
`URL_SAFETY_ENABLED` defaults to `true` when unset. Setting it to `false`
|
|
@@ -266,7 +298,7 @@ or cloud metadata targets, or configure network routing or private DNS.
|
|
|
266
298
|
|
|
267
299
|
With `WORKERS > 1`, the entrypoint sets `PROMETHEUS_MULTIPROC_DIR` for correct metric aggregation.
|
|
268
300
|
|
|
269
|
-
**Sizing.** By default a pod runs 2 workers (`WORKERS`), and each worker runs up to 4 crawls at once (`REQUEST_LIMITS_MAX_CONCURRENT_CRAWLS`), so 8 per pod. The Helm chart requests 1 CPU and 2 GiB of memory with a 4 GiB limit, and the image sets `MALLOC_ARENA_MAX=2`. Each worker is a separate Python process with its own memory, so add replicas rather than workers for more capacity. Run at least 2 replicas in production.
|
|
301
|
+
**Sizing.** By default a pod runs 2 workers (`WORKERS`), and each worker runs up to 4 crawls at once (`REQUEST_LIMITS_MAX_CONCURRENT_CRAWLS`), so 8 per pod. The Helm chart requests 1 CPU and 2 GiB of memory with a 4 GiB limit, and the image sets `MALLOC_ARENA_MAX=2`. Each worker is a separate Python process with its own memory, so add replicas rather than workers for more capacity. Run at least 2 replicas in production. When PDFs are enabled, each PDF being read adds a subprocess of typically about 150 MiB, capped at `PDF_MAX_EXTRACTION_MEMORY_MB` (512 MiB), so the default adds at most about 1 GiB per pod.
|
|
270
302
|
|
|
271
303
|
---
|
|
272
304
|
|
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: unique-search-proxy
|
|
3
|
-
Version: 2026.46.0.dev6
|
|
4
|
-
Summary: Web Search Proxy implementation
|
|
5
|
-
Author: ThePhilAz
|
|
6
|
-
Author-email: ThePhilAz <rami.azouz@philico.com>
|
|
7
|
-
Requires-Dist: aiohttp>=3.14.1,<4
|
|
8
|
-
Requires-Dist: fastapi>=0.133.0,<1.0.0
|
|
9
|
-
Requires-Dist: starlette>=1.3.1,<2.0.0
|
|
10
|
-
Requires-Dist: uvicorn[standard]>=0.32.0,<1.0.0
|
|
11
|
-
Requires-Dist: pydantic>=2.12.5,<3.0.0
|
|
12
|
-
Requires-Dist: httpx>=0.28.0,<0.29.0
|
|
13
|
-
Requires-Dist: python-dotenv>=1.2.1,<2.0.0
|
|
14
|
-
Requires-Dist: pydantic-settings>=2.12.0,<3.0.0
|
|
15
|
-
Requires-Dist: markdownify>=0.14.1,<1
|
|
16
|
-
Requires-Dist: azure-ai-projects>=2.3,<3
|
|
17
|
-
Requires-Dist: azure-identity>=1.25.0,<2
|
|
18
|
-
Requires-Dist: azure-core>=1.36.0,<2
|
|
19
|
-
Requires-Dist: certifi>=2025.11.12,<2027
|
|
20
|
-
Requires-Dist: google-genai>=1.73.0,<2
|
|
21
|
-
Requires-Dist: google-auth>=2.43.0,<3
|
|
22
|
-
Requires-Dist: jinja2>=3.1.6,<4
|
|
23
|
-
Requires-Dist: unique-toolkit[monitoring]>=2026.46.0.dev10,<2026.46.0rc0
|
|
24
|
-
Requires-Dist: unique-search-proxy-core>=2026.46.0.dev2,<2026.46.0rc0
|
|
25
|
-
Requires-Dist: openai>=1.105.0,<3
|
|
26
|
-
Requires-Python: >=3.12
|
|
27
|
-
Description-Content-Type: text/markdown
|
|
28
|
-
|
|
29
1
|
# unique-search-proxy (client)
|
|
30
2
|
|
|
31
3
|
Part of [Unique Search Proxy](../README.md) · PyPI: `unique-search-proxy` · Helm: `unique-search-proxy`
|
|
@@ -242,6 +214,8 @@ Crawler discriminators: `Basic`, `Tavily`, `Jina`, `Firecrawl`.
|
|
|
242
214
|
|
|
243
215
|
**Timeout:** with `Basic`, URLs still loading just before `timeout` come back as per-URL `UPSTREAM_TIMEOUT` results next to the finished pages. A busy worker can send the response up to 5 s after `timeout`, so set your HTTP client timeout at least 5 s above it. The other crawlers fail the whole batch with a `504` at `timeout`.
|
|
244
216
|
|
|
217
|
+
**PDFs:** with `contentTypes.pdf` on (off by default), `Basic` returns a PDF's text in `content`; `raw` is always null for PDFs. The default pypdf extractor runs in `SubprocessExtractionRunner`: a short-lived child process that starts with an empty environment, has memory and CPU limits, and is killed at its time limit or the request deadline. Each worker reads `PDF_MAX_CONCURRENT_EXTRACTIONS` PDFs at a time (default 1); the rest wait. PDFs longer than `PDF_MAX_PDF_PAGES` or `PDF_MAX_EXTRACTED_CHARS` come back truncated, led by a note saying so. A PDF that can't be read fails its own URL (`PDF_UNSUPPORTED`, `UPSTREAM_ERROR`, or `UPSTREAM_TIMEOUT`). Extractors are adapters behind `PdfExtractor` in `processing/processors/pdf/adapters/`, selected with `PDF_EXTRACTOR`.
|
|
218
|
+
|
|
245
219
|
### 5.5 Errors
|
|
246
220
|
|
|
247
221
|
Structured envelope on all non-2xx responses:
|
|
@@ -278,6 +252,7 @@ Settings use pydantic-settings with per-provider env vars. Copy `.env.example` t
|
|
|
278
252
|
| Request context | (none) | `REQUIRE_CONTEXT_HEADERS`, `REJECT_UNATTRIBUTED_REQUESTS` |
|
|
279
253
|
| Prometheus | `PROMETHEUS_` | `PROMETHEUS_ENABLED` |
|
|
280
254
|
| URL safety | `URL_SAFETY_` | `URL_SAFETY_ENABLED` |
|
|
255
|
+
| PDF processing | `PDF_` | `PDF_EXTRACTOR`, `PDF_MAX_PDF_PAGES`, `PDF_EXTRACTION_TIMEOUT_SECONDS` |
|
|
281
256
|
| Container | (shell) | `HOST`, `PORT`, `WORKERS`, `LOG_LEVEL` |
|
|
282
257
|
|
|
283
258
|
`URL_SAFETY_ENABLED` defaults to `true` when unset. Setting it to `false`
|
|
@@ -294,7 +269,7 @@ or cloud metadata targets, or configure network routing or private DNS.
|
|
|
294
269
|
|
|
295
270
|
With `WORKERS > 1`, the entrypoint sets `PROMETHEUS_MULTIPROC_DIR` for correct metric aggregation.
|
|
296
271
|
|
|
297
|
-
**Sizing.** By default a pod runs 2 workers (`WORKERS`), and each worker runs up to 4 crawls at once (`REQUEST_LIMITS_MAX_CONCURRENT_CRAWLS`), so 8 per pod. The Helm chart requests 1 CPU and 2 GiB of memory with a 4 GiB limit, and the image sets `MALLOC_ARENA_MAX=2`. Each worker is a separate Python process with its own memory, so add replicas rather than workers for more capacity. Run at least 2 replicas in production.
|
|
272
|
+
**Sizing.** By default a pod runs 2 workers (`WORKERS`), and each worker runs up to 4 crawls at once (`REQUEST_LIMITS_MAX_CONCURRENT_CRAWLS`), so 8 per pod. The Helm chart requests 1 CPU and 2 GiB of memory with a 4 GiB limit, and the image sets `MALLOC_ARENA_MAX=2`. Each worker is a separate Python process with its own memory, so add replicas rather than workers for more capacity. Run at least 2 replicas in production. When PDFs are enabled, each PDF being read adds a subprocess of typically about 150 MiB, capped at `PDF_MAX_EXTRACTION_MEMORY_MB` (512 MiB), so the default adds at most about 1 GiB per pod.
|
|
298
273
|
|
|
299
274
|
---
|
|
300
275
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "unique-search-proxy"
|
|
3
|
-
version = "2026.46.0.
|
|
3
|
+
version = "2026.46.0.dev8"
|
|
4
4
|
description = "Web Search Proxy implementation"
|
|
5
5
|
authors = [{ name = "ThePhilAz", email = "rami.azouz@philico.com" }]
|
|
6
6
|
readme = "README.md"
|
|
@@ -22,9 +22,10 @@ dependencies = [
|
|
|
22
22
|
"google-genai>=1.73.0,<2",
|
|
23
23
|
"google-auth>=2.43.0,<3",
|
|
24
24
|
"jinja2>=3.1.6,<4",
|
|
25
|
-
"unique-toolkit[monitoring]>=2026.46.0.
|
|
26
|
-
"unique-search-proxy-core>=2026.46.0.
|
|
25
|
+
"unique-toolkit[monitoring]>=2026.46.0.dev13,<2026.46.0rc0",
|
|
26
|
+
"unique-search-proxy-core>=2026.46.0.dev4,<2026.46.0rc0",
|
|
27
27
|
"openai>=1.105.0,<3",
|
|
28
|
+
"pypdf==6.21.4",
|
|
28
29
|
]
|
|
29
30
|
|
|
30
31
|
[dependency-groups]
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.html import (
|
|
2
2
|
process_html,
|
|
3
3
|
)
|
|
4
|
-
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf import (
|
|
5
|
-
process_pdf,
|
|
6
|
-
)
|
|
7
4
|
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.plain_text import (
|
|
8
5
|
process_plain_text,
|
|
9
6
|
)
|
|
10
7
|
|
|
11
8
|
__all__ = [
|
|
12
9
|
"process_html",
|
|
13
|
-
"process_pdf",
|
|
14
10
|
"process_plain_text",
|
|
15
11
|
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.admit import (
|
|
2
|
+
admit_pdf_bytes,
|
|
3
|
+
)
|
|
4
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.extractor import (
|
|
5
|
+
FakePdfExtractor,
|
|
6
|
+
PdfExtractor,
|
|
7
|
+
UnconfiguredPdfExtractor,
|
|
8
|
+
)
|
|
9
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.process import (
|
|
10
|
+
PdfProcessingOutcome,
|
|
11
|
+
PdfProcessor,
|
|
12
|
+
join_page_chunks,
|
|
13
|
+
)
|
|
14
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.runner import (
|
|
15
|
+
ExtractionRunner,
|
|
16
|
+
InProcessExtractionRunner,
|
|
17
|
+
SubprocessExtractionRunner,
|
|
18
|
+
)
|
|
19
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.types import (
|
|
20
|
+
ExtractionLimits,
|
|
21
|
+
ExtractionOutcome,
|
|
22
|
+
ExtractionResult,
|
|
23
|
+
PageChunk,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"ExtractionLimits",
|
|
28
|
+
"ExtractionOutcome",
|
|
29
|
+
"ExtractionResult",
|
|
30
|
+
"ExtractionRunner",
|
|
31
|
+
"FakePdfExtractor",
|
|
32
|
+
"InProcessExtractionRunner",
|
|
33
|
+
"PageChunk",
|
|
34
|
+
"PdfExtractor",
|
|
35
|
+
"PdfProcessingOutcome",
|
|
36
|
+
"PdfProcessor",
|
|
37
|
+
"SubprocessExtractionRunner",
|
|
38
|
+
"UnconfiguredPdfExtractor",
|
|
39
|
+
"admit_pdf_bytes",
|
|
40
|
+
"join_page_chunks",
|
|
41
|
+
]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""pypdf (BSD-3-Clause) text-layer extractor adapter."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.adapters.pypdf_text import (
|
|
9
|
+
extract_text_layer,
|
|
10
|
+
)
|
|
11
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.types import (
|
|
12
|
+
ExtractionLimits,
|
|
13
|
+
ExtractionResult,
|
|
14
|
+
extraction_result_from_payload,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _extract_sync(path: Path, limits: ExtractionLimits) -> ExtractionResult:
|
|
19
|
+
payload = extract_text_layer(
|
|
20
|
+
str(path),
|
|
21
|
+
max_pages=limits.max_pages,
|
|
22
|
+
max_chars=limits.max_chars,
|
|
23
|
+
)
|
|
24
|
+
return extraction_result_from_payload(payload, adapter_name="pypdf")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PyPdfExtractor:
|
|
28
|
+
"""PdfExtractor adapter backed by the BSD-licensed pypdf library."""
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def name(self) -> str:
|
|
32
|
+
return "pypdf"
|
|
33
|
+
|
|
34
|
+
async def extract(
|
|
35
|
+
self,
|
|
36
|
+
path: Path,
|
|
37
|
+
limits: ExtractionLimits,
|
|
38
|
+
) -> ExtractionResult:
|
|
39
|
+
return await asyncio.to_thread(_extract_sync, path, limits)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = ["PyPdfExtractor"]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""pypdf text extraction, called in-process or run as a script by ``SubprocessExtractionRunner``.
|
|
2
|
+
|
|
3
|
+
Imports only the standard library and pypdf, so the child never loads proxy settings.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import resource
|
|
10
|
+
import sys
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from pypdf import PdfReader
|
|
14
|
+
from pypdf.errors import PdfReadError
|
|
15
|
+
|
|
16
|
+
# Only for failures that depend on the file's bytes alone.
|
|
17
|
+
_NOT_RETRYABLE = " Retrying will not help."
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _clean(text: str) -> str:
|
|
21
|
+
# Lone surrogates from broken font maps would fail encoding of the whole response.
|
|
22
|
+
return text.replace("\x00", "").encode("utf-8", "replace").decode("utf-8")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def extract_text_layer(
|
|
26
|
+
path: str,
|
|
27
|
+
*,
|
|
28
|
+
max_pages: int,
|
|
29
|
+
max_chars: int,
|
|
30
|
+
) -> dict[str, Any]:
|
|
31
|
+
"""Return an extraction payload (see ``extraction_result_from_payload``)."""
|
|
32
|
+
try:
|
|
33
|
+
reader = PdfReader(path, strict=False)
|
|
34
|
+
except PdfReadError:
|
|
35
|
+
return {
|
|
36
|
+
"outcome": "unsupported",
|
|
37
|
+
"reason": "PDF could not be parsed." + _NOT_RETRYABLE,
|
|
38
|
+
}
|
|
39
|
+
except Exception as exc: # noqa: BLE001 - library boundary
|
|
40
|
+
return {
|
|
41
|
+
"outcome": "failed",
|
|
42
|
+
"reason": f"Failed to open PDF: {exc.__class__.__name__}",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if reader.is_encrypted:
|
|
46
|
+
try:
|
|
47
|
+
unlocked = reader.decrypt("")
|
|
48
|
+
except Exception: # noqa: BLE001 - library boundary
|
|
49
|
+
unlocked = 0
|
|
50
|
+
if not unlocked:
|
|
51
|
+
# The page count is unreadable until the PDF is decrypted.
|
|
52
|
+
return {
|
|
53
|
+
"outcome": "unsupported",
|
|
54
|
+
"reason": "Encrypted PDFs are not supported." + _NOT_RETRYABLE,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
# The page tree is only read here, so a broken one fails late.
|
|
59
|
+
total_pages = len(reader.pages)
|
|
60
|
+
except PdfReadError:
|
|
61
|
+
return {
|
|
62
|
+
"outcome": "unsupported",
|
|
63
|
+
"reason": "PDF could not be parsed." + _NOT_RETRYABLE,
|
|
64
|
+
}
|
|
65
|
+
except Exception as exc: # noqa: BLE001 - library boundary
|
|
66
|
+
return {
|
|
67
|
+
"outcome": "failed",
|
|
68
|
+
"reason": f"Failed to read PDF pages: {exc.__class__.__name__}",
|
|
69
|
+
}
|
|
70
|
+
chunks: list[dict[str, Any]] = []
|
|
71
|
+
remaining = max_chars
|
|
72
|
+
for index in range(min(total_pages, max_pages)):
|
|
73
|
+
if remaining <= 0:
|
|
74
|
+
break
|
|
75
|
+
try:
|
|
76
|
+
text = _clean(reader.pages[index].extract_text() or "")
|
|
77
|
+
except Exception as exc: # noqa: BLE001 - library boundary
|
|
78
|
+
return {
|
|
79
|
+
"outcome": "failed",
|
|
80
|
+
"reason": f"Text extraction failed: {exc.__class__.__name__}",
|
|
81
|
+
"total_page_count": total_pages,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
truncated = len(text) > remaining
|
|
85
|
+
text = text[:remaining]
|
|
86
|
+
remaining -= len(text)
|
|
87
|
+
chunks.append(
|
|
88
|
+
{"page_number": index + 1, "text": text, "truncated": truncated},
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
outcome = "extracted" if any(chunk["text"].strip() for chunk in chunks) else "empty"
|
|
92
|
+
return {"outcome": outcome, "chunks": chunks, "total_page_count": total_pages}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _limit_resources(memory_bytes: int, cpu_seconds: int) -> None:
|
|
96
|
+
limits = (
|
|
97
|
+
(resource.RLIMIT_AS, memory_bytes, memory_bytes),
|
|
98
|
+
# Backstop for the parent's wall-clock kill.
|
|
99
|
+
(resource.RLIMIT_CPU, cpu_seconds, cpu_seconds + 1),
|
|
100
|
+
)
|
|
101
|
+
for limit, soft, hard in limits:
|
|
102
|
+
try:
|
|
103
|
+
resource.setrlimit(limit, (soft, hard))
|
|
104
|
+
except (ValueError, OSError):
|
|
105
|
+
# macOS rejects RLIMIT_AS; refuse to run unlimited where it matters.
|
|
106
|
+
if sys.platform.startswith("linux"):
|
|
107
|
+
raise
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main(argv: list[str]) -> int:
|
|
111
|
+
path = argv[1]
|
|
112
|
+
max_pages, max_chars, memory_bytes, cpu_seconds = (int(arg) for arg in argv[2:6])
|
|
113
|
+
_limit_resources(memory_bytes, cpu_seconds)
|
|
114
|
+
try:
|
|
115
|
+
payload = extract_text_layer(path, max_pages=max_pages, max_chars=max_chars)
|
|
116
|
+
except MemoryError:
|
|
117
|
+
payload = {"outcome": "failed", "reason": "PDF needed too much memory"}
|
|
118
|
+
json.dump(payload, sys.stdout)
|
|
119
|
+
return 0
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
sys.exit(main(sys.argv))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
PDF_MAGIC = b"%PDF-"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True)
|
|
9
|
+
class PdfAdmissionError:
|
|
10
|
+
code: str
|
|
11
|
+
message: str
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def admit_pdf_bytes(
|
|
15
|
+
body: bytes,
|
|
16
|
+
*,
|
|
17
|
+
media_type: str | None,
|
|
18
|
+
) -> PdfAdmissionError | None:
|
|
19
|
+
"""Return an admission error, or None when the body may be scanned/extracted.
|
|
20
|
+
|
|
21
|
+
Download size is enforced by the shared HTTP response cap, not here.
|
|
22
|
+
"""
|
|
23
|
+
normalized = (media_type or "").strip().lower()
|
|
24
|
+
if normalized != "application/pdf":
|
|
25
|
+
return PdfAdmissionError(
|
|
26
|
+
code="PDF_UNSUPPORTED",
|
|
27
|
+
message=f"Expected application/pdf, got {normalized or 'unknown'}",
|
|
28
|
+
)
|
|
29
|
+
if not body.startswith(PDF_MAGIC):
|
|
30
|
+
return PdfAdmissionError(
|
|
31
|
+
code="PDF_UNSUPPORTED",
|
|
32
|
+
message="Response body is not a PDF (missing %PDF- header)",
|
|
33
|
+
)
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
__all__ = ["PDF_MAGIC", "PdfAdmissionError", "admit_pdf_bytes"]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Protocol
|
|
5
|
+
|
|
6
|
+
from unique_search_proxy_client.web.core.crawlers.basic.processing.processors.pdf.types import (
|
|
7
|
+
ExtractionLimits,
|
|
8
|
+
ExtractionOutcome,
|
|
9
|
+
ExtractionResult,
|
|
10
|
+
PageChunk,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PdfExtractor(Protocol):
|
|
15
|
+
"""Library-neutral PDF text-layer extractor."""
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def name(self) -> str: ...
|
|
19
|
+
|
|
20
|
+
async def extract(
|
|
21
|
+
self,
|
|
22
|
+
path: Path,
|
|
23
|
+
limits: ExtractionLimits,
|
|
24
|
+
) -> ExtractionResult: ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class UnconfiguredPdfExtractor:
|
|
28
|
+
"""Default extractor until a licensed adapter is selected."""
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def name(self) -> str:
|
|
32
|
+
return "unconfigured"
|
|
33
|
+
|
|
34
|
+
async def extract(
|
|
35
|
+
self,
|
|
36
|
+
path: Path,
|
|
37
|
+
limits: ExtractionLimits,
|
|
38
|
+
) -> ExtractionResult:
|
|
39
|
+
del path, limits
|
|
40
|
+
return ExtractionResult(
|
|
41
|
+
outcome=ExtractionOutcome.FAILED,
|
|
42
|
+
reason="PDF extractor is not configured",
|
|
43
|
+
adapter_name=self.name,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class FakePdfExtractor:
|
|
48
|
+
"""Test double that returns a predetermined extraction result."""
|
|
49
|
+
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
*,
|
|
53
|
+
result: ExtractionResult | None = None,
|
|
54
|
+
name: str = "fake",
|
|
55
|
+
) -> None:
|
|
56
|
+
self._result = result or ExtractionResult(
|
|
57
|
+
outcome=ExtractionOutcome.EXTRACTED,
|
|
58
|
+
chunks=(PageChunk(page_number=1, text="# Fake"),),
|
|
59
|
+
total_page_count=1,
|
|
60
|
+
adapter_name=name,
|
|
61
|
+
)
|
|
62
|
+
self._name = name
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def name(self) -> str:
|
|
66
|
+
return self._name
|
|
67
|
+
|
|
68
|
+
async def extract(
|
|
69
|
+
self,
|
|
70
|
+
path: Path,
|
|
71
|
+
limits: ExtractionLimits,
|
|
72
|
+
) -> ExtractionResult:
|
|
73
|
+
del path, limits
|
|
74
|
+
return self._result
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
__all__ = [
|
|
78
|
+
"FakePdfExtractor",
|
|
79
|
+
"PdfExtractor",
|
|
80
|
+
"UnconfiguredPdfExtractor",
|
|
81
|
+
]
|