pw-core 0.27.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.
- pw_core-0.27.0/LICENSE +202 -0
- pw_core-0.27.0/MANIFEST.in +3 -0
- pw_core-0.27.0/NOTICE +4 -0
- pw_core-0.27.0/PKG-INFO +269 -0
- pw_core-0.27.0/README.md +162 -0
- pw_core-0.27.0/pyproject.toml +312 -0
- pw_core-0.27.0/setup.cfg +4 -0
- pw_core-0.27.0/src/pw_core/__init__.py +27 -0
- pw_core-0.27.0/src/pw_core/_env_compat.py +27 -0
- pw_core-0.27.0/src/pw_core/_extras.py +120 -0
- pw_core-0.27.0/src/pw_core/alembic.py +72 -0
- pw_core-0.27.0/src/pw_core/budget/__init__.py +154 -0
- pw_core-0.27.0/src/pw_core/budget/_aggregate.py +160 -0
- pw_core-0.27.0/src/pw_core/budget/_schema.py +114 -0
- pw_core-0.27.0/src/pw_core/budget/audit.py +81 -0
- pw_core-0.27.0/src/pw_core/budget/check.py +488 -0
- pw_core-0.27.0/src/pw_core/budget/config.py +237 -0
- pw_core-0.27.0/src/pw_core/budget/repo.py +362 -0
- pw_core-0.27.0/src/pw_core/budget/scheduler.py +72 -0
- pw_core-0.27.0/src/pw_core/budget/snapshot_job.py +73 -0
- pw_core-0.27.0/src/pw_core/cache/__init__.py +0 -0
- pw_core-0.27.0/src/pw_core/cache/redis.py +298 -0
- pw_core-0.27.0/src/pw_core/cli/__init__.py +198 -0
- pw_core-0.27.0/src/pw_core/cli/export.py +86 -0
- pw_core-0.27.0/src/pw_core/cli/jobs.py +261 -0
- pw_core-0.27.0/src/pw_core/cli/subcommands/__init__.py +31 -0
- pw_core-0.27.0/src/pw_core/cli/subcommands/_render.py +169 -0
- pw_core-0.27.0/src/pw_core/cli/subcommands/baseline.py +155 -0
- pw_core-0.27.0/src/pw_core/cli/subcommands/invalidate.py +88 -0
- pw_core-0.27.0/src/pw_core/clients/__init__.py +38 -0
- pw_core-0.27.0/src/pw_core/clients/_claude_code_wire.py +214 -0
- pw_core-0.27.0/src/pw_core/clients/anthropic.py +489 -0
- pw_core-0.27.0/src/pw_core/clients/brave.py +297 -0
- pw_core-0.27.0/src/pw_core/clients/claude_code.py +453 -0
- pw_core-0.27.0/src/pw_core/clients/openrouter.py +440 -0
- pw_core-0.27.0/src/pw_core/clients/routing.py +167 -0
- pw_core-0.27.0/src/pw_core/config.py +32 -0
- pw_core-0.27.0/src/pw_core/db/__init__.py +89 -0
- pw_core-0.27.0/src/pw_core/db/connection.py +239 -0
- pw_core-0.27.0/src/pw_core/db/dialect.py +133 -0
- pw_core-0.27.0/src/pw_core/db/helpers.py +68 -0
- pw_core-0.27.0/src/pw_core/db/ids.py +85 -0
- pw_core-0.27.0/src/pw_core/db/json_compat.py +216 -0
- pw_core-0.27.0/src/pw_core/db/models.py +79 -0
- pw_core-0.27.0/src/pw_core/db/repository.py +66 -0
- pw_core-0.27.0/src/pw_core/db/soft_delete.py +122 -0
- pw_core-0.27.0/src/pw_core/db/types.py +102 -0
- pw_core-0.27.0/src/pw_core/db/upsert.py +176 -0
- pw_core-0.27.0/src/pw_core/db/versioned_config.py +189 -0
- pw_core-0.27.0/src/pw_core/docs/INSTALLATION.md +238 -0
- pw_core-0.27.0/src/pw_core/docs/alembic.md +71 -0
- pw_core-0.27.0/src/pw_core/docs/anthropic.md +223 -0
- pw_core-0.27.0/src/pw_core/docs/article-fetch.md +211 -0
- pw_core-0.27.0/src/pw_core/docs/brave.md +156 -0
- pw_core-0.27.0/src/pw_core/docs/cache.md +213 -0
- pw_core-0.27.0/src/pw_core/docs/claude-code.md +292 -0
- pw_core-0.27.0/src/pw_core/docs/cli-subcommands.md +115 -0
- pw_core-0.27.0/src/pw_core/docs/cli.md +107 -0
- pw_core-0.27.0/src/pw_core/docs/config.md +71 -0
- pw_core-0.27.0/src/pw_core/docs/cost-budget.md +309 -0
- pw_core-0.27.0/src/pw_core/docs/database.md +357 -0
- pw_core-0.27.0/src/pw_core/docs/db-dialect.md +133 -0
- pw_core-0.27.0/src/pw_core/docs/db-ids.md +27 -0
- pw_core-0.27.0/src/pw_core/docs/db-upsert.md +46 -0
- pw_core-0.27.0/src/pw_core/docs/doctor.md +24 -0
- pw_core-0.27.0/src/pw_core/docs/eval-harness.md +633 -0
- pw_core-0.27.0/src/pw_core/docs/export.md +116 -0
- pw_core-0.27.0/src/pw_core/docs/fetch-images.md +71 -0
- pw_core-0.27.0/src/pw_core/docs/fetch.md +127 -0
- pw_core-0.27.0/src/pw_core/docs/jobs-admin.md +60 -0
- pw_core-0.27.0/src/pw_core/docs/jobs-runtime.md +77 -0
- pw_core-0.27.0/src/pw_core/docs/jobs.md +395 -0
- pw_core-0.27.0/src/pw_core/docs/json-recovery.md +149 -0
- pw_core-0.27.0/src/pw_core/docs/llm-admin.md +178 -0
- pw_core-0.27.0/src/pw_core/docs/llm-cache.md +315 -0
- pw_core-0.27.0/src/pw_core/docs/llm-parse.md +146 -0
- pw_core-0.27.0/src/pw_core/docs/llm-recording.md +97 -0
- pw_core-0.27.0/src/pw_core/docs/llm-safe-apply.md +109 -0
- pw_core-0.27.0/src/pw_core/docs/llm-schema-validation.md +546 -0
- pw_core-0.27.0/src/pw_core/docs/llm-step.md +85 -0
- pw_core-0.27.0/src/pw_core/docs/llm-tracked.md +135 -0
- pw_core-0.27.0/src/pw_core/docs/llm-tracking.md +461 -0
- pw_core-0.27.0/src/pw_core/docs/llm-validation.md +101 -0
- pw_core-0.27.0/src/pw_core/docs/markdown.md +113 -0
- pw_core-0.27.0/src/pw_core/docs/model-router.md +471 -0
- pw_core-0.27.0/src/pw_core/docs/modules.md +195 -0
- pw_core-0.27.0/src/pw_core/docs/openrouter.md +255 -0
- pw_core-0.27.0/src/pw_core/docs/orchestrators.md +100 -0
- pw_core-0.27.0/src/pw_core/docs/otel.md +167 -0
- pw_core-0.27.0/src/pw_core/docs/pagination.md +140 -0
- pw_core-0.27.0/src/pw_core/docs/parsers.md +88 -0
- pw_core-0.27.0/src/pw_core/docs/phash.md +77 -0
- pw_core-0.27.0/src/pw_core/docs/pipeline.md +299 -0
- pw_core-0.27.0/src/pw_core/docs/pricing.md +46 -0
- pw_core-0.27.0/src/pw_core/docs/project-portability.md +122 -0
- pw_core-0.27.0/src/pw_core/docs/prompts.md +298 -0
- pw_core-0.27.0/src/pw_core/docs/recipes/batch-llm-service.md +101 -0
- pw_core-0.27.0/src/pw_core/docs/recipes/critic.md +90 -0
- pw_core-0.27.0/src/pw_core/docs/recipes/job-refs-bridge.md +128 -0
- pw_core-0.27.0/src/pw_core/docs/recipes/self-consistency.md +114 -0
- pw_core-0.27.0/src/pw_core/docs/relative-dates.md +129 -0
- pw_core-0.27.0/src/pw_core/docs/scaffold.md +44 -0
- pw_core-0.27.0/src/pw_core/docs/similarity.md +103 -0
- pw_core-0.27.0/src/pw_core/docs/soft-delete.md +106 -0
- pw_core-0.27.0/src/pw_core/docs/test-migration.md +105 -0
- pw_core-0.27.0/src/pw_core/docs/testing.md +219 -0
- pw_core-0.27.0/src/pw_core/docs/urls.md +347 -0
- pw_core-0.27.0/src/pw_core/docs/versioned-config.md +107 -0
- pw_core-0.27.0/src/pw_core/docs/vocab.md +142 -0
- pw_core-0.27.0/src/pw_core/docs/web.md +284 -0
- pw_core-0.27.0/src/pw_core/doctor.py +237 -0
- pw_core-0.27.0/src/pw_core/eval/__init__.py +105 -0
- pw_core-0.27.0/src/pw_core/eval/_compare.py +214 -0
- pw_core-0.27.0/src/pw_core/eval/_config.py +232 -0
- pw_core-0.27.0/src/pw_core/eval/_experiments.py +147 -0
- pw_core-0.27.0/src/pw_core/eval/_golden.py +245 -0
- pw_core-0.27.0/src/pw_core/eval/_judge.py +171 -0
- pw_core-0.27.0/src/pw_core/eval/_report.py +220 -0
- pw_core-0.27.0/src/pw_core/eval/_runner.py +486 -0
- pw_core-0.27.0/src/pw_core/eval/cli.py +273 -0
- pw_core-0.27.0/src/pw_core/export/__init__.py +16 -0
- pw_core-0.27.0/src/pw_core/export/markdown.py +298 -0
- pw_core-0.27.0/src/pw_core/fetch/__init__.py +422 -0
- pw_core-0.27.0/src/pw_core/fetch/_connect.py +174 -0
- pw_core-0.27.0/src/pw_core/fetch/_decode.py +74 -0
- pw_core-0.27.0/src/pw_core/fetch/images.py +384 -0
- pw_core-0.27.0/src/pw_core/guards_rules.py +22 -0
- pw_core-0.27.0/src/pw_core/jobs/__init__.py +69 -0
- pw_core-0.27.0/src/pw_core/jobs/_repo_steps.py +214 -0
- pw_core-0.27.0/src/pw_core/jobs/_repo_util.py +109 -0
- pw_core-0.27.0/src/pw_core/jobs/_repo_worker.py +190 -0
- pw_core-0.27.0/src/pw_core/jobs/_schema.py +143 -0
- pw_core-0.27.0/src/pw_core/jobs/registry.py +256 -0
- pw_core-0.27.0/src/pw_core/jobs/repo.py +361 -0
- pw_core-0.27.0/src/pw_core/jobs/runtime.py +314 -0
- pw_core-0.27.0/src/pw_core/jobs/submit.py +181 -0
- pw_core-0.27.0/src/pw_core/jobs/workers.py +281 -0
- pw_core-0.27.0/src/pw_core/llm/__init__.py +110 -0
- pw_core-0.27.0/src/pw_core/llm/_json.py +35 -0
- pw_core-0.27.0/src/pw_core/llm/_router_config.py +153 -0
- pw_core-0.27.0/src/pw_core/llm/_router_loader.py +75 -0
- pw_core-0.27.0/src/pw_core/llm/_router_schema.py +142 -0
- pw_core-0.27.0/src/pw_core/llm/cache/__init__.py +246 -0
- pw_core-0.27.0/src/pw_core/llm/cache/_recorder.py +121 -0
- pw_core-0.27.0/src/pw_core/llm/cache/_schema.py +82 -0
- pw_core-0.27.0/src/pw_core/llm/cache/config.py +201 -0
- pw_core-0.27.0/src/pw_core/llm/cache/exact.py +247 -0
- pw_core-0.27.0/src/pw_core/llm/cache/invalidate.py +118 -0
- pw_core-0.27.0/src/pw_core/llm/parse.py +237 -0
- pw_core-0.27.0/src/pw_core/llm/prompts.py +286 -0
- pw_core-0.27.0/src/pw_core/llm/recording.py +82 -0
- pw_core-0.27.0/src/pw_core/llm/router.py +332 -0
- pw_core-0.27.0/src/pw_core/llm/safe_apply.py +186 -0
- pw_core-0.27.0/src/pw_core/llm/step.py +260 -0
- pw_core-0.27.0/src/pw_core/llm/tracked.py +468 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/__init__.py +122 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/_metadata.py +33 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/_otel_reader.py +90 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/_resolvers.py +259 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/decorator.py +198 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/otel.py +307 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/purge.py +71 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/repo.py +453 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/schema.py +400 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/stats.py +188 -0
- pw_core-0.27.0/src/pw_core/llm/tracking/subrepos.py +274 -0
- pw_core-0.27.0/src/pw_core/llm/url_check.py +74 -0
- pw_core-0.27.0/src/pw_core/llm/validate/__init__.py +83 -0
- pw_core-0.27.0/src/pw_core/llm/validate/_cross_field.py +59 -0
- pw_core-0.27.0/src/pw_core/llm/validate/_jsonschema.py +67 -0
- pw_core-0.27.0/src/pw_core/llm/validate/_pipeline.py +431 -0
- pw_core-0.27.0/src/pw_core/llm/validate/_pydantic.py +65 -0
- pw_core-0.27.0/src/pw_core/llm/validate/_registry.py +141 -0
- pw_core-0.27.0/src/pw_core/llm/validate/_semantic.py +375 -0
- pw_core-0.27.0/src/pw_core/orchestrators/__init__.py +5 -0
- pw_core-0.27.0/src/pw_core/orchestrators/base.py +90 -0
- pw_core-0.27.0/src/pw_core/parsers/__init__.py +47 -0
- pw_core-0.27.0/src/pw_core/parsers/exceptions.py +33 -0
- pw_core-0.27.0/src/pw_core/parsers/html.py +211 -0
- pw_core-0.27.0/src/pw_core/parsers/types.py +31 -0
- pw_core-0.27.0/src/pw_core/pipeline/__init__.py +13 -0
- pw_core-0.27.0/src/pw_core/pipeline/baseline.py +244 -0
- pw_core-0.27.0/src/pw_core/pipeline/baseline_diff.py +296 -0
- pw_core-0.27.0/src/pw_core/pipeline/cache.py +156 -0
- pw_core-0.27.0/src/pw_core/pipeline/resume.py +128 -0
- pw_core-0.27.0/src/pw_core/pipeline/run_record.py +126 -0
- pw_core-0.27.0/src/pw_core/pipeline/sequencer.py +159 -0
- pw_core-0.27.0/src/pw_core/pricing/__init__.py +30 -0
- pw_core-0.27.0/src/pw_core/pricing/_data.py +50 -0
- pw_core-0.27.0/src/pw_core/pricing/_resolver.py +148 -0
- pw_core-0.27.0/src/pw_core/pricing/_types.py +29 -0
- pw_core-0.27.0/src/pw_core/py.typed +0 -0
- pw_core-0.27.0/src/pw_core/rules/anti-patterns.md +112 -0
- pw_core-0.27.0/src/pw_core/rules/layering.md +107 -0
- pw_core-0.27.0/src/pw_core/rules/project-structure.md +127 -0
- pw_core-0.27.0/src/pw_core/testing/__init__.py +20 -0
- pw_core-0.27.0/src/pw_core/testing/_ddl.py +69 -0
- pw_core-0.27.0/src/pw_core/testing/_server_db.py +129 -0
- pw_core-0.27.0/src/pw_core/testing/db_fixtures.py +287 -0
- pw_core-0.27.0/src/pw_core/testing/env.py +84 -0
- pw_core-0.27.0/src/pw_core/testing/fixtures.py +69 -0
- pw_core-0.27.0/src/pw_core/utils/__init__.py +63 -0
- pw_core-0.27.0/src/pw_core/utils/_article_extract.py +307 -0
- pw_core-0.27.0/src/pw_core/utils/article_fetch.py +331 -0
- pw_core-0.27.0/src/pw_core/utils/http_tls.py +27 -0
- pw_core-0.27.0/src/pw_core/utils/json_recovery.py +245 -0
- pw_core-0.27.0/src/pw_core/utils/phash.py +168 -0
- pw_core-0.27.0/src/pw_core/utils/relative_dates.py +258 -0
- pw_core-0.27.0/src/pw_core/utils/similarity.py +71 -0
- pw_core-0.27.0/src/pw_core/utils/url_html.py +119 -0
- pw_core-0.27.0/src/pw_core/utils/url_liveness.py +226 -0
- pw_core-0.27.0/src/pw_core/utils/url_parse.py +174 -0
- pw_core-0.27.0/src/pw_core/utils/url_safety.py +155 -0
- pw_core-0.27.0/src/pw_core/utils/urls.py +249 -0
- pw_core-0.27.0/src/pw_core/utils/vocab.py +131 -0
- pw_core-0.27.0/src/pw_core/web/__init__.py +15 -0
- pw_core-0.27.0/src/pw_core/web/_error_handlers.py +154 -0
- pw_core-0.27.0/src/pw_core/web/_error_page.py +131 -0
- pw_core-0.27.0/src/pw_core/web/_validation_errors.py +82 -0
- pw_core-0.27.0/src/pw_core/web/app_factory.py +169 -0
- pw_core-0.27.0/src/pw_core/web/health.py +116 -0
- pw_core-0.27.0/src/pw_core/web/helpers.py +30 -0
- pw_core-0.27.0/src/pw_core/web/jobs_admin/__init__.py +194 -0
- pw_core-0.27.0/src/pw_core/web/jobs_admin/templates/job_detail.html +122 -0
- pw_core-0.27.0/src/pw_core/web/jobs_admin/templates/jobs_list.html +60 -0
- pw_core-0.27.0/src/pw_core/web/json.py +55 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/__init__.py +103 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/_queries_jobs.py +78 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/_queries_runs.py +229 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/_queries_spend.py +170 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/_queries_util.py +37 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/api.py +179 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/pages.py +185 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/queries.py +62 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/base.html +60 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/budgets.html +62 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/cache.html +65 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/cost_by_agent.html +22 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/cost_by_model.html +24 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/dashboard.html +41 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/job_detail.html +60 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/jobs_list.html +47 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/macros.html +23 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/run_detail.html +114 -0
- pw_core-0.27.0/src/pw_core/web/llm_admin/templates/runs_list.html +49 -0
- pw_core-0.27.0/src/pw_core/web/markdown.py +245 -0
- pw_core-0.27.0/src/pw_core/web/pagination.py +125 -0
- pw_core-0.27.0/src/pw_core/web/rate_limit.py +115 -0
- pw_core-0.27.0/src/pw_core/web/templates.py +59 -0
- pw_core-0.27.0/src/pw_core.egg-info/PKG-INFO +269 -0
- pw_core-0.27.0/src/pw_core.egg-info/SOURCES.txt +253 -0
- pw_core-0.27.0/src/pw_core.egg-info/dependency_links.txt +1 -0
- pw_core-0.27.0/src/pw_core.egg-info/entry_points.txt +7 -0
- pw_core-0.27.0/src/pw_core.egg-info/requires.txt +107 -0
- pw_core-0.27.0/src/pw_core.egg-info/top_level.txt +1 -0
pw_core-0.27.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
pw_core-0.27.0/NOTICE
ADDED
pw_core-0.27.0/PKG-INFO
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pw-core
|
|
3
|
+
Version: 0.27.0
|
|
4
|
+
Summary: Python foundation for LLM apps whose prompts and spend you can actually see — versioned prompts, every call recorded and replayable, budgets, evals, and resumable jobs on one schema; opt-in LLM, database, and FastAPI layers
|
|
5
|
+
Author: Mike Farr
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/modules.md
|
|
8
|
+
Project-URL: Repository, https://github.com/phierceweb/pw-core
|
|
9
|
+
Project-URL: Changelog, https://github.com/phierceweb/pw-core/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/phierceweb/pw-core/issues
|
|
11
|
+
Keywords: llm,openrouter,anthropic,fastapi,sqlalchemy,framework,cost-tracking,eval,structured-logging,prompt-versioning,llm-observability,background-jobs
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Requires-Dist: pw-foundation~=1.0
|
|
23
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
24
|
+
Provides-Extra: http
|
|
25
|
+
Requires-Dist: httpx>=0.28; extra == "http"
|
|
26
|
+
Provides-Extra: cli
|
|
27
|
+
Requires-Dist: typer>=0.27; extra == "cli"
|
|
28
|
+
Requires-Dist: click>=8.4; extra == "cli"
|
|
29
|
+
Provides-Extra: validate
|
|
30
|
+
Requires-Dist: json-repair>=0.63; extra == "validate"
|
|
31
|
+
Requires-Dist: pydantic>=2.13; extra == "validate"
|
|
32
|
+
Provides-Extra: llm
|
|
33
|
+
Requires-Dist: pw-core[http,validate]; extra == "llm"
|
|
34
|
+
Requires-Dist: tenacity>=9.1; extra == "llm"
|
|
35
|
+
Provides-Extra: db
|
|
36
|
+
Requires-Dist: sqlalchemy>=2.0.52; extra == "db"
|
|
37
|
+
Requires-Dist: alembic>=1.19; extra == "db"
|
|
38
|
+
Provides-Extra: web
|
|
39
|
+
Requires-Dist: fastapi>=0.141; extra == "web"
|
|
40
|
+
Requires-Dist: jinja2>=3.1.6; extra == "web"
|
|
41
|
+
Requires-Dist: uvicorn[standard]>=0.52; extra == "web"
|
|
42
|
+
Provides-Extra: jobs
|
|
43
|
+
Requires-Dist: pw-core[cli,db,tracking]; extra == "jobs"
|
|
44
|
+
Requires-Dist: pydantic>=2.13; extra == "jobs"
|
|
45
|
+
Provides-Extra: tracking
|
|
46
|
+
Requires-Dist: pw-core[db,llm]; extra == "tracking"
|
|
47
|
+
Provides-Extra: admin
|
|
48
|
+
Requires-Dist: pw-core[tracking,web]; extra == "admin"
|
|
49
|
+
Provides-Extra: eval
|
|
50
|
+
Requires-Dist: pw-core[jobs,tracking]; extra == "eval"
|
|
51
|
+
Requires-Dist: jinja2>=3.1.6; extra == "eval"
|
|
52
|
+
Provides-Extra: otel
|
|
53
|
+
Requires-Dist: pw-core[cli,tracking]; extra == "otel"
|
|
54
|
+
Requires-Dist: opentelemetry-api>=1.45; extra == "otel"
|
|
55
|
+
Requires-Dist: opentelemetry-sdk>=1.45; extra == "otel"
|
|
56
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.45; extra == "otel"
|
|
57
|
+
Provides-Extra: mysql
|
|
58
|
+
Requires-Dist: pymysql>=1.2; extra == "mysql"
|
|
59
|
+
Provides-Extra: postgres
|
|
60
|
+
Requires-Dist: psycopg[binary]>=3.3; extra == "postgres"
|
|
61
|
+
Provides-Extra: redis
|
|
62
|
+
Requires-Dist: dogpile.cache>=1.5; extra == "redis"
|
|
63
|
+
Requires-Dist: redis>=8.1; extra == "redis"
|
|
64
|
+
Provides-Extra: ratelimit
|
|
65
|
+
Requires-Dist: pw-core[web]; extra == "ratelimit"
|
|
66
|
+
Requires-Dist: slowapi>=0.1.10; extra == "ratelimit"
|
|
67
|
+
Provides-Extra: jsonschema
|
|
68
|
+
Requires-Dist: jsonschema>=4.26; extra == "jsonschema"
|
|
69
|
+
Provides-Extra: articles
|
|
70
|
+
Requires-Dist: trafilatura>=2.2; extra == "articles"
|
|
71
|
+
Requires-Dist: htmldate>=1.10; extra == "articles"
|
|
72
|
+
Requires-Dist: tenacity>=9.1; extra == "articles"
|
|
73
|
+
Provides-Extra: crawl
|
|
74
|
+
Requires-Dist: pw-core[articles,http]; extra == "crawl"
|
|
75
|
+
Provides-Extra: anthropic
|
|
76
|
+
Requires-Dist: anthropic<1.0,>=0.105; extra == "anthropic"
|
|
77
|
+
Provides-Extra: image-phash
|
|
78
|
+
Requires-Dist: ImageHash>=4.3.2; extra == "image-phash"
|
|
79
|
+
Requires-Dist: Pillow>=12.3; extra == "image-phash"
|
|
80
|
+
Provides-Extra: full
|
|
81
|
+
Requires-Dist: pw-core[db]; extra == "full"
|
|
82
|
+
Requires-Dist: pw-core[web]; extra == "full"
|
|
83
|
+
Requires-Dist: pw-core[llm]; extra == "full"
|
|
84
|
+
Requires-Dist: pw-core[cli]; extra == "full"
|
|
85
|
+
Requires-Dist: pw-core[jobs]; extra == "full"
|
|
86
|
+
Requires-Dist: pw-core[tracking]; extra == "full"
|
|
87
|
+
Requires-Dist: pw-core[admin]; extra == "full"
|
|
88
|
+
Requires-Dist: pw-core[eval]; extra == "full"
|
|
89
|
+
Requires-Dist: pw-core[redis]; extra == "full"
|
|
90
|
+
Requires-Dist: pw-core[ratelimit]; extra == "full"
|
|
91
|
+
Requires-Dist: pw-core[jsonschema]; extra == "full"
|
|
92
|
+
Provides-Extra: dev
|
|
93
|
+
Requires-Dist: pytest>=9.1; extra == "dev"
|
|
94
|
+
Requires-Dist: httpx>=0.28; extra == "dev"
|
|
95
|
+
Requires-Dist: factory-boy>=3.3.3; extra == "dev"
|
|
96
|
+
Requires-Dist: ruff~=0.16.0; extra == "dev"
|
|
97
|
+
Requires-Dist: mypy~=2.3.0; extra == "dev"
|
|
98
|
+
Requires-Dist: types-PyYAML; extra == "dev"
|
|
99
|
+
Requires-Dist: types-PyMySQL; extra == "dev"
|
|
100
|
+
Requires-Dist: types-jsonschema; extra == "dev"
|
|
101
|
+
Requires-Dist: types-nanoid; extra == "dev"
|
|
102
|
+
Requires-Dist: pre-commit>=4.6; extra == "dev"
|
|
103
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
104
|
+
Provides-Extra: test-containers
|
|
105
|
+
Requires-Dist: testcontainers[mysql]>=4.15; extra == "test-containers"
|
|
106
|
+
Dynamic: license-file
|
|
107
|
+
|
|
108
|
+
# pw-core
|
|
109
|
+
|
|
110
|
+
[](https://pypi.org/project/pw-core/)
|
|
111
|
+
|
|
112
|
+
Formerly published as pf-core (0.2.3–0.26.0); renamed at 0.27.0. The old PyPI releases remain but receive no updates.
|
|
113
|
+
|
|
114
|
+
A Python foundation for building LLM applications whose prompts and spend you can actually see: every prompt lives in versioned configuration, and every call is recorded — prompt version, model, provider, response, tokens, cost — and replayable, in your choice of SQLite, MySQL, or Postgres. The base install is dependency-light (structured logging, an exception hierarchy, config-from-env, a service/repo architecture); opt-in extras add the LLM clients, output validation, cost tracking and budgets, an eval harness, and a FastAPI + SQLAlchemy app framework. Capabilities compose orthogonally — the foundation alone, the LLM layer without a database, or the web layer without LLMs.
|
|
115
|
+
|
|
116
|
+
## Why pw-core
|
|
117
|
+
|
|
118
|
+
The LLM tooling landscape solves each concern separately: one product routes calls across providers, another traces and meters them, another versions prompts, another runs evals, another repairs malformed JSON, another lints repo structure. Stitch several together and the seams show — every tool brings its own config, its own storage, its own id space, and no shared key joins a prompt version to the tokens it burned or the validation it failed. pw-core is those concerns designed as one system; the integration is the feature.
|
|
119
|
+
|
|
120
|
+
It started as the shared core of several AI-assisted projects that fanned multithreaded LLM calls out to external providers. Each was built differently, with the important details — config, prompts, clients, methodology — buried in whichever file the AI found closest: working software, unreadable data, mounting tech debt. pw-core solves the five problems those projects kept hitting:
|
|
121
|
+
|
|
122
|
+
1. **Prompts buried in code.** Every prompt lives in versioned YAML configuration — seen, diffed, and tuned. Change one materially and you bump its version; old and new both stay in the registry.
|
|
123
|
+
2. **Calls unrecorded.** Every call lands as one database row: prompt version, model, provider, sampling, response, tokens, cost. Each run links to the exact prompt version it used.
|
|
124
|
+
3. **Spend ungoverned.** Budgets are checked before the call — daily/monthly caps scoped by agent, job, or tag, with a kill-switch and projection — and a cache refuses to pay twice for identical work.
|
|
125
|
+
4. **Upgrades are guesses.** Approved runs promote into a golden set; a new model or prompt replays against it and shows its deltas before it ships — in CI, if you want a failing eval to block the merge.
|
|
126
|
+
5. **Long batch work dies and forgets.** Jobs resume after a crash by skipping already-succeeded steps, and every LLM call inside a job is attributed to it automatically — no job id threaded through function signatures.
|
|
127
|
+
|
|
128
|
+
Deep dives on each: [prompts](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/prompts.md), [llm-tracking](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-tracking.md), [cost-budget](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/cost-budget.md), [llm-cache](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-cache.md), [eval-harness](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/eval-harness.md), [jobs](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/jobs.md).
|
|
129
|
+
|
|
130
|
+
All five land in the same place: one `llm_runs` row per call, plus sidecar tables for payloads, validations, tags, metrics, and run-to-run links. The dashboard, the cache, the budget checks, and the eval harness all read those same tables — which is what makes prompt-and-model combinations tunable in aggregate: in a dozen-step pipeline, each step with its own prompt and model, every combination is queryable side by side.
|
|
131
|
+
|
|
132
|
+
In a complex data pipeline the stakes are higher, because prompts feed prompts: step 3 consumes what steps 1 and 2 produced, so an upstream prompt or model change ripples through everything downstream. The same tables answer that too. Every call in a pipeline run shares a job id, and every run records the exact prompt version and model it used — so whole pipeline runs can be grouped by their upstream configuration and compared on their downstream results. Concretely: run the pipeline with steps 1 and 2 on prompt v2 and one model, run it again with the same prompts on a different model, leave every later step unchanged, and compare the later steps' validations and metrics between the two groups. The question being answered is not "which prompt is better in isolation" but "which upstream choice produced better results three steps later" — and it's answerable with a query, because everything landed in one schema.
|
|
133
|
+
|
|
134
|
+
Dialect portability is structural rather than incidental: queries are SQLAlchemy constructs where one exists, the hand-written SQL that remains is parameterized, and the places where the databases genuinely differ are handled in a few modules (`pw_core.db.dialect`, `types`, `json_compat`, `upsert`, and the session setup in `connection`) — code built on pw-core need not branch on dialect. MySQL and Postgres sessions are pinned to UTC with cutoffs computed server-side. CI runs the full suite on SQLite across Python 3.12–3.13, then again against real PostgreSQL and MySQL servers with each test in its own schema or database, plus a bare-install job that proves the foundation imports with none of the extras present; provider clients are tested against mocked transports, not live APIs. Misconfiguration fails at deploy time: an unresolvable eval judge or an invalid router entry raises `ConfigurationError` rather than silently picking a default.
|
|
135
|
+
|
|
136
|
+
## One interface over multiple LLM backends — including Claude Code
|
|
137
|
+
|
|
138
|
+
OpenRouter (paid API), the Anthropic SDK, and Claude Code (a local Claude Max session, $0 per call) sit behind the same `chat(messages, model) -> (content, usage)` interface. A YAML model router assigns a backend per agent and falls back to the next available one; a registry accepts custom backends (Ollama, direct OpenAI, …). Because the clients are interchangeable and `pw_foundation.parallel` fans work across a thread pool, a batch of LLM calls can run concurrently and route anywhere — a large batch pushed onto a Claude Max subscription instead of spending API credits, or spread across providers — while every call is still tracked and budget-checked the same way.
|
|
139
|
+
|
|
140
|
+
## Output guards
|
|
141
|
+
|
|
142
|
+
LLMs return fenced, truncated, or not-quite-JSON output; pw-core recovers it (`pw_core.llm.parse`) and validates the result against a schema with optional semantic and cross-field checks (`pw_core.llm.validate`) — available without the client stack, so output from any transport can be guarded, and validation results are recorded on the run they judged.
|
|
143
|
+
|
|
144
|
+
## The database layer
|
|
145
|
+
|
|
146
|
+
One API over SQLite, MySQL, and PostgreSQL — develop on SQLite, deploy on a server database without query changes; a shared Alembic runner handles migrations. The tracking tables are written by parallel workers, and the write paths are shaped for that: reference-table lookups resolve in their own short transactions before the main write opens, sidecar writes are idempotent upserts rather than delete-then-insert, and worker claims use a portable SELECT-then-UPDATE that also runs on SQLite. MySQL and Postgres connections are pinned to UTC and time cutoffs are computed server-side, so timestamps agree across dialects. Details: **[docs/llm-tracking.md](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-tracking.md)** and **[docs/database.md](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/database.md)**.
|
|
147
|
+
|
|
148
|
+
## The application framework
|
|
149
|
+
|
|
150
|
+
pw-core is a framework, not just a client library. Consumer apps follow a layered architecture — entry points → orchestrators → services → repositories, no layer importing from above — with a `Service` base class carrying config injection, logging, and repo access. Around that: a FastAPI app factory with self-contained error pages and content negotiation; a job tracker with a state machine, idempotent step history, and worker leases so multi-step work survives restarts; a mountable admin dashboard for runs, costs, and budgets; and pipeline helpers for run-records, baselines, and stage-cascade cache invalidation. See **[docs/modules.md](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/modules.md)** for the full index.
|
|
151
|
+
|
|
152
|
+
## Built for AI coding agents
|
|
153
|
+
|
|
154
|
+
pw-core is built to be worked on by AI coding agents as much as by people — and that part pays off even when a project has no LLM calls of its own. The conventions that keep a codebase legible to an agent are enforced, not suggested: a build gate fails CI when a file grows past its line budget (small files stay within a model's working context and edit cleanly), a companion checker flags imports that cross the layered architecture the wrong way, and logging, errors, config, and data access each have one obvious way to do them — so generated code lands in the same shapes as hand-written code instead of drifting. The testing bootstrap ships in the framework itself as an auto-registered pytest plugin (fixtures, framework-table DDL, hermetic test env), and the consumer scaffold stamps a runnable smoke test into every new project.
|
|
155
|
+
|
|
156
|
+
## Install
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pip install pw-foundation # the foundation alone: logging, exceptions, config, utils, pw-guards
|
|
160
|
+
pip install pw-core # + pw-core's base (pulls pw-foundation) — no LLM, no DB, no web
|
|
161
|
+
pip install pw-core[validate] # + output guards (no clients/HTTP)
|
|
162
|
+
pip install pw-core[llm] # + LLM clients (includes [validate])
|
|
163
|
+
pip install pw-core[full,postgres] # the whole app framework
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Pin a **compatible release** for stability — e.g. `pip install "pw-core[llm]~=0.27.0"` (picks up `0.27.x` fixes, holds below the next minor; substitute the current release from the [changelog](https://github.com/phierceweb/pw-core/blob/main/CHANGELOG.md)). To track unreleased work, install from git instead — `main` is the development line and may contain work between releases:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pip install "pw-core[llm] @ git+https://github.com/phierceweb/pw-core.git@main"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Extras compose orthogonally (`[db]` without LLM, `[web]` without `[db]`, `[llm]` standalone); importing a gated module without its extra raises an `ImportError` naming the extra and the pip command. Full matrix and release/update flow: **[docs/INSTALLATION.md](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/INSTALLATION.md)**.
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
|
|
176
|
+
- **[docs/INSTALLATION.md](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/INSTALLATION.md)** — extras matrix, install/release/update flows, verification
|
|
177
|
+
- **[docs/modules.md](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/modules.md)** — one-line-per-module index, grouped by concern
|
|
178
|
+
- **[docs/](https://github.com/phierceweb/pw-core/tree/main/src/pw_core/docs)** — per-module reference with usage and parameter detail
|
|
179
|
+
- **[CHANGELOG.md](https://github.com/phierceweb/pw-core/blob/main/CHANGELOG.md)** — release history
|
|
180
|
+
|
|
181
|
+
The docs are written to be read by AI assistants and ship inside the package (`pw_core/docs/` under site-packages), so an installed copy always matches its version — the links above render `main`. One command puts them where an in-repo assistant looks: `pw-setup`, installed with pw-foundation, links `docs/pw-core` to the bundled docs from any consumer's repo root — idempotent, and it refuses to touch a real file — while `pw-doctor` reports the link read-only (the `wiring.docs_link` row). New projects get the link from their first `bin/setup` after scaffolding (`bin/new-consumer <name> --layout {lib|app}` from a pw-core checkout). To just locate the installed docs:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
python -c "import pw_core, pathlib; print(pathlib.Path(pw_core.__file__).parent / 'docs')"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
<details>
|
|
188
|
+
<summary><b>All docs</b> — every file in <code>src/pw_core/docs/</code>, one link each</summary>
|
|
189
|
+
|
|
190
|
+
- [INSTALLATION](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/INSTALLATION.md)
|
|
191
|
+
- [alembic](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/alembic.md)
|
|
192
|
+
- [anthropic](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/anthropic.md)
|
|
193
|
+
- [article-fetch](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/article-fetch.md)
|
|
194
|
+
- [brave](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/brave.md)
|
|
195
|
+
- [cache](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/cache.md)
|
|
196
|
+
- [claude-code](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/claude-code.md)
|
|
197
|
+
- [cli-subcommands](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/cli-subcommands.md)
|
|
198
|
+
- [cli](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/cli.md)
|
|
199
|
+
- [config](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/config.md)
|
|
200
|
+
- [cost-budget](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/cost-budget.md)
|
|
201
|
+
- [database](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/database.md)
|
|
202
|
+
- [db-dialect](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/db-dialect.md)
|
|
203
|
+
- [db-ids](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/db-ids.md)
|
|
204
|
+
- [db-upsert](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/db-upsert.md)
|
|
205
|
+
- [doctor](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/doctor.md)
|
|
206
|
+
- [eval-harness](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/eval-harness.md)
|
|
207
|
+
- [export](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/export.md)
|
|
208
|
+
- [fetch](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/fetch.md)
|
|
209
|
+
- [fetch-images](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/fetch-images.md)
|
|
210
|
+
- [jobs](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/jobs.md)
|
|
211
|
+
- [jobs-admin](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/jobs-admin.md)
|
|
212
|
+
- [jobs-runtime](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/jobs-runtime.md)
|
|
213
|
+
- [json-recovery](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/json-recovery.md)
|
|
214
|
+
- [llm-admin](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-admin.md)
|
|
215
|
+
- [llm-cache](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-cache.md)
|
|
216
|
+
- [llm-parse](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-parse.md)
|
|
217
|
+
- [llm-recording](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-recording.md)
|
|
218
|
+
- [llm-safe-apply](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-safe-apply.md)
|
|
219
|
+
- [llm-schema-validation](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-schema-validation.md)
|
|
220
|
+
- [llm-step](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-step.md)
|
|
221
|
+
- [llm-tracked](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-tracked.md)
|
|
222
|
+
- [llm-tracking](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-tracking.md)
|
|
223
|
+
- [llm-validation](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/llm-validation.md)
|
|
224
|
+
- [markdown](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/markdown.md)
|
|
225
|
+
- [model-router](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/model-router.md)
|
|
226
|
+
- [modules](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/modules.md)
|
|
227
|
+
- [openrouter](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/openrouter.md)
|
|
228
|
+
- [orchestrators](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/orchestrators.md)
|
|
229
|
+
- [otel](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/otel.md)
|
|
230
|
+
- [pagination](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/pagination.md)
|
|
231
|
+
- [parsers](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/parsers.md)
|
|
232
|
+
- [phash](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/phash.md)
|
|
233
|
+
- [pipeline](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/pipeline.md)
|
|
234
|
+
- [pricing](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/pricing.md)
|
|
235
|
+
- [project-portability](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/project-portability.md)
|
|
236
|
+
- [prompts](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/prompts.md)
|
|
237
|
+
- [relative-dates](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/relative-dates.md)
|
|
238
|
+
- [scaffold](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/scaffold.md)
|
|
239
|
+
- [similarity](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/similarity.md)
|
|
240
|
+
- [soft-delete](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/soft-delete.md)
|
|
241
|
+
- [test-migration](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/test-migration.md)
|
|
242
|
+
- [testing](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/testing.md)
|
|
243
|
+
- [urls](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/urls.md)
|
|
244
|
+
- [versioned-config](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/versioned-config.md)
|
|
245
|
+
- [vocab](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/vocab.md)
|
|
246
|
+
- [web](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/web.md)
|
|
247
|
+
- Recipes: [batch-llm-service](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/recipes/batch-llm-service.md) · [critic](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/recipes/critic.md) · [job-refs-bridge](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/recipes/job-refs-bridge.md) · [self-consistency](https://github.com/phierceweb/pw-core/blob/main/src/pw_core/docs/recipes/self-consistency.md)
|
|
248
|
+
|
|
249
|
+
</details>
|
|
250
|
+
|
|
251
|
+
## Development
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
python -m venv .venv && source .venv/bin/activate
|
|
255
|
+
pip install -e ".[full,otel,articles,anthropic,image-phash,dev]" # everything, so the full suite runs
|
|
256
|
+
pre-commit install
|
|
257
|
+
pytest
|
|
258
|
+
python bin/verify-bare-install # confirm the base install stays dependency-light
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Pytest fixtures auto-register as a plugin via the `pw_core` entry point — no `conftest.py` import needed in consumers. Contribution guidelines: **[CONTRIBUTING.md](https://github.com/phierceweb/pw-core/blob/main/CONTRIBUTING.md)**.
|
|
262
|
+
|
|
263
|
+
## Project history
|
|
264
|
+
|
|
265
|
+
pw-core was developed privately from early April 2026 and first published on June 14, 2026, with the pre-publication history squashed. Public releases are tagged (`v*`) and published to PyPI by CI via OIDC trusted publishing ([publish.yml](https://github.com/phierceweb/pw-core/blob/main/.github/workflows/publish.yml)); `main` is the development line and is pushed with each release.
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
Apache-2.0 — see [LICENSE](https://github.com/phierceweb/pw-core/blob/main/LICENSE). Releases through v0.22.0 were published under the MIT license and stay MIT.
|