contextsage 1.0.2__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. contextsage-2.0.0/PKG-INFO +263 -0
  2. contextsage-2.0.0/README.md +221 -0
  3. {contextsage-1.0.2 → contextsage-2.0.0}/pyproject.toml +30 -47
  4. {contextsage-1.0.2 → contextsage-2.0.0}/pyproject.toml.orig +26 -33
  5. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/__init__.py +45 -5
  6. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/budget.py +6 -2
  7. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/decomposition.py +56 -22
  8. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/importance.py +13 -3
  9. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/lineage.py +15 -31
  10. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/models.py +1 -4
  11. contextsage-2.0.0/src/contextsage/_pipeline/pipeline.py +151 -0
  12. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/preservation.py +66 -46
  13. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/provenance.py +36 -29
  14. contextsage-2.0.0/src/contextsage/_pipeline/recovery.py +87 -0
  15. contextsage-2.0.0/src/contextsage/_pipeline/reduction.py +995 -0
  16. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/signals.py +6 -4
  17. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/summary.py +6 -22
  18. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/transformation.py +55 -18
  19. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/validation.py +2 -5
  20. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/window.py +1 -26
  21. contextsage-2.0.0/src/contextsage/config.py +247 -0
  22. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/contracts.py +10 -8
  23. contextsage-2.0.0/src/contextsage/engine.py +578 -0
  24. contextsage-2.0.0/src/contextsage/errors.py +26 -0
  25. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/events.py +17 -17
  26. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/integrations/langchain/__init__.py +150 -103
  27. contextsage-2.0.0/src/contextsage/messages.py +297 -0
  28. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/parsing.py +276 -267
  29. contextsage-2.0.0/src/contextsage/reduction.py +321 -0
  30. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/sinks.py +25 -2
  31. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/tokens.py +18 -3
  32. contextsage-1.0.2/PKG-INFO +0 -159
  33. contextsage-1.0.2/README.md +0 -117
  34. contextsage-1.0.2/src/contextsage/_pipeline/pipeline.py +0 -71
  35. contextsage-1.0.2/src/contextsage/_pipeline/recovery.py +0 -132
  36. contextsage-1.0.2/src/contextsage/engine.py +0 -598
  37. contextsage-1.0.2/src/contextsage/errors.py +0 -23
  38. contextsage-1.0.2/src/contextsage/messages.py +0 -184
  39. contextsage-1.0.2/src/contextsage/provenance.py +0 -104
  40. {contextsage-1.0.2 → contextsage-2.0.0}/LICENSE +0 -0
  41. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/__init__.py +0 -0
  42. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/reconstruction.py +0 -0
  43. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/_pipeline/relationships.py +0 -0
  44. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/integrations/__init__.py +0 -0
  45. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/policies.py +0 -0
  46. {contextsage-1.0.2 → contextsage-2.0.0}/src/contextsage/py.typed +0 -0
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: contextsage
3
+ Version: 2.0.0
4
+ Summary: Information-aware, framework-agnostic context summarization for AI agents.
5
+ Keywords: agents,llm,summarization,context-engineering,context-window,langchain,langgraph,agno,crewai,provenance
6
+ Author: S MUNI HARISH
7
+ Author-email: S MUNI HARISH <samamuniharish@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Framework :: AsyncIO
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Dist: agxai>=2.0.1,<3
24
+ Requires-Dist: opentelemetry-api>=1.45.3,<2
25
+ Requires-Dist: parsefabric>=2.0.0,<3
26
+ Requires-Dist: contextsage[langchain,otel] ; extra == 'all'
27
+ Requires-Dist: langchain>=1.5.2,<2 ; extra == 'langchain'
28
+ Requires-Dist: langchain-core>=1.8.5,<2 ; extra == 'langchain'
29
+ Requires-Dist: langgraph>=1.2.25,<2 ; extra == 'langchain'
30
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.45.3,<2 ; extra == 'otel'
31
+ Requires-Dist: opentelemetry-sdk>=1.45.3,<2 ; extra == 'otel'
32
+ Requires-Python: >=3.12
33
+ Project-URL: Homepage, https://github.com/smuniharish/contextsage
34
+ Project-URL: Documentation, https://contextsage.readthedocs.io/
35
+ Project-URL: Changelog, https://github.com/smuniharish/contextsage/blob/master/CHANGELOG.md
36
+ Project-URL: Issues, https://github.com/smuniharish/contextsage/issues
37
+ Project-URL: Repository, https://github.com/smuniharish/contextsage
38
+ Provides-Extra: all
39
+ Provides-Extra: langchain
40
+ Provides-Extra: otel
41
+ Description-Content-Type: text/markdown
42
+
43
+ <p align="center">
44
+ <img src="https://raw.githubusercontent.com/smuniharish/contextsage/master/docs/assets/logo.svg" alt="ContextSage logo" width="96">
45
+ </p>
46
+
47
+ <h1 align="center">ContextSage</h1>
48
+
49
+ <p align="center">
50
+ <a href="https://pypi.org/project/contextsage/"><img src="https://img.shields.io/pypi/v/contextsage" alt="PyPI"></a>
51
+ <a href="https://pypi.org/project/contextsage/"><img src="https://img.shields.io/pypi/pyversions/contextsage" alt="Python versions"></a>
52
+ <a href="https://github.com/smuniharish/contextsage/actions/workflows/ci.yml"><img src="https://github.com/smuniharish/contextsage/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
53
+ <a href="https://contextsage.readthedocs.io/"><img src="https://img.shields.io/readthedocs/contextsage" alt="Documentation"></a>
54
+ <a href="https://github.com/smuniharish/contextsage/blob/master/LICENSE"><img src="https://img.shields.io/pypi/l/contextsage" alt="License"></a>
55
+ </p>
56
+
57
+ **Information-aware context summarization for AI agents.** ContextSage is
58
+ summarization middleware that decides *when* a history must shrink, *what*
59
+ must survive verbatim, and *whether* a summary is safe to apply. It parses
60
+ heterogeneous context (conversation, tool calls and results, JSON, logs,
61
+ code, SQL, search results), compacts repetitive material, has your summary
62
+ model write the summary, validates that selected facts and tool relationships
63
+ survived, and records provenance. Its asynchronous core uses a neutral message
64
+ model and works with any agent framework.
65
+
66
+ Summarization must be information-preserving, not merely token-reducing:
67
+ when validation or reduction cannot be made safe, ContextSage keeps or
68
+ restores the original content instead of silently dropping it.
69
+
70
+ ## Install
71
+
72
+ ```bash
73
+ pip install contextsage
74
+ ```
75
+
76
+ Install optional integrations only when you use them:
77
+
78
+ ```bash
79
+ pip install "contextsage[langchain]" # LangChain and LangGraph
80
+ pip install "contextsage[otel]" # OpenTelemetry SDK and OTLP exporter
81
+ pip install "contextsage[all]" # both optional integrations
82
+ ```
83
+
84
+ The core requires Python 3.12 or newer and does not install an agent framework.
85
+
86
+ ## Framework-neutral quickstart
87
+
88
+ Implement `parsefabric.LanguageModel` with your summary provider, convert your
89
+ framework's history to `contextsage.Message`, then call the async engine before
90
+ the next model turn. Long-lived settings go in one `ContextSageConfig`; each
91
+ call takes one `SummarizationRequest` and returns one `SummarizationResult`:
92
+
93
+ ```python
94
+ from contextsage import (
95
+ BudgetConfig,
96
+ ContextSageConfig,
97
+ ContextSummarizer,
98
+ ModelBudget,
99
+ ReductionConfig,
100
+ SummarizationRequest,
101
+ TokenizerTokenCounter,
102
+ )
103
+
104
+
105
+ async def summarize_history(summary_model, messages):
106
+ counter = TokenizerTokenCounter()
107
+ config = ContextSageConfig(
108
+ model=summary_model,
109
+ budget=BudgetConfig(
110
+ target=ModelBudget(128_000, overhead_tokens=2_000, safety_margin=0.1),
111
+ summary=ModelBudget(64_000),
112
+ target_counter=counter,
113
+ summary_counter=counter,
114
+ ),
115
+ reduction=ReductionConfig(trigger=("tokens", 100_000), keep=("messages", 20)),
116
+ )
117
+ async with ContextSummarizer(config) as engine:
118
+ result = await engine.summarize(
119
+ SummarizationRequest(messages=messages, thread_id="conversation-42")
120
+ )
121
+ return list(result.messages) if result.changed else list(messages)
122
+ ```
123
+
124
+ The engine parses text and structured content, compacts repetitive material,
125
+ preserves facts such as identifiers and corrections, validates the result,
126
+ and records lineage. If the history does not meet the trigger,
127
+ `result.changed` is `False` and the history is returned unchanged. See the
128
+ runnable [quickstart](https://github.com/smuniharish/contextsage/blob/master/examples/quickstart.py) and the
129
+ [core concepts](https://contextsage.readthedocs.io/en/latest/guide/how-it-works/).
130
+
131
+ The budgets above are illustrative: configure the actual agent and summary
132
+ model limits, provider overhead, and model-specific token counters (the
133
+ default `TokenizerTokenCounter` is approximate). If compaction is not enough,
134
+ ContextSage can reduce oversized context using sequential, hierarchical, or
135
+ explicitly grouped passes. It raises `ReductionError` when the configured
136
+ constraints cannot be met safely. Validation is deterministic and checks
137
+ selected facts and tool pairing, not semantic equivalence; protect exact text
138
+ and choose a trusted provider when needed. See
139
+ [oversized-context reduction](https://contextsage.readthedocs.io/en/latest/guide/oversized-context/).
140
+
141
+ ## Integrations
142
+
143
+ The optional LangChain integration wraps the same core engine as an agent
144
+ middleware:
145
+
146
+ ```python
147
+ from contextsage import BudgetConfig, ContextSageConfig, ModelBudget, ReductionConfig
148
+ from contextsage.integrations.langchain import (
149
+ IntelligentSummarizationMiddleware,
150
+ LangChainMiddlewareConfig,
151
+ LangChainSummaryModel,
152
+ LangChainTokenCounter,
153
+ )
154
+
155
+
156
+ def make_middleware(summary_model):
157
+ counter = LangChainTokenCounter()
158
+ return IntelligentSummarizationMiddleware(
159
+ LangChainMiddlewareConfig(
160
+ context=ContextSageConfig(
161
+ model=LangChainSummaryModel(summary_model),
162
+ budget=BudgetConfig(
163
+ target=ModelBudget(128_000),
164
+ summary=ModelBudget(64_000),
165
+ target_counter=counter,
166
+ summary_counter=counter,
167
+ ),
168
+ reduction=ReductionConfig(
169
+ trigger=("tokens", 100_000),
170
+ keep=("messages", 20),
171
+ ),
172
+ )
173
+ )
174
+ )
175
+ ```
176
+
177
+ Or implement `FrameworkAdapter` for your framework's message type. The
178
+ adapter maps between native messages and the neutral `Message` model; no
179
+ framework dependency is needed by the core. See the [LangChain integration](https://contextsage.readthedocs.io/en/latest/guide/integrations/)
180
+ and [custom framework example](https://github.com/smuniharish/contextsage/blob/master/examples/custom_framework.py).
181
+
182
+ ## Downstream customization
183
+
184
+ ContextSage exposes the extension points of its dependencies rather than
185
+ restricting them to built-in choices:
186
+
187
+ | Package | Customizable components |
188
+ | --- | --- |
189
+ | [parsefabric](https://pypi.org/project/parsefabric/) | `LanguageModel`, tokenizers, line patterns, parsers and registries, fenced-code routes, code detection, JSON codec, lifecycle sink, and execution backend. |
190
+ | [agxai](https://pypi.org/project/agxai/) | `ProvenanceStore`, observability, attribution, explanation and policy providers, capture policy, runtime configuration, registry, plugins, and custom state capture. |
191
+ | OpenTelemetry | Use the built-in event sink and SDK/exporters, or supply an `EventSink` for your telemetry platform. |
192
+ | LangChain (optional) | Supply a chat model, token counter, and `LangChainAdapter` to the integration. |
193
+
194
+ Configure parsefabric through `AnalysisConfig(parsing=ParsingOptions(...))`
195
+ and agxai by passing your own `agxai.XAIRuntime` as
196
+ `ContextSageConfig(runtime=...)`. The
197
+ [downstream customization example](https://github.com/smuniharish/contextsage/blob/master/examples/downstream_customization.py)
198
+ demonstrates custom components from both packages.
199
+
200
+ ## Examples and documentation
201
+
202
+ The [examples](https://github.com/smuniharish/contextsage/blob/master/examples/README.md) include framework adapters, LangChain,
203
+ PostgreSQL provenance, OpenTelemetry, Prometheus, native reduction, custom
204
+ parsing, policies, and safe failure. Scripted examples run without API keys and their output is
205
+ verified in CI. The
206
+ [documentation site](https://contextsage.readthedocs.io/) includes
207
+ installation, configuration, integration guides, operations guidance and the
208
+ [API reference](https://contextsage.readthedocs.io/en/latest/reference/).
209
+
210
+ ContextSage also publishes [Agent Skills](https://github.com/smuniharish/contextsage/blob/master/contextsage-skills/README.md) for
211
+ coding agents that need to integrate or extend the package. The
212
+ [skills guide](https://contextsage.readthedocs.io/en/latest/agent-skills/) also lists independently maintained
213
+ dependency and integration skills.
214
+
215
+ ## Downloads
216
+
217
+ <p>
218
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=downloads&amp;color=blue&amp;cacheSeconds=3600" alt="Total downloads"></a>
219
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520date%2520%253E%253D%2520toStartOfWeek%2528toDate%2528now%2528%2527UTC%2527%2529%2529%252C%25201%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=this%20week&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads this week"></a>
220
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520date%2520%253E%253D%2520toStartOfMonth%2528toDate%2528now%2528%2527UTC%2527%2529%2529%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=this%20month&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads this month"></a>
221
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520date%2520%253E%253D%2520toStartOfYear%2528toDate%2528now%2528%2527UTC%2527%2529%2529%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=this%20year&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads this year"></a>
222
+ </p>
223
+ <p>
224
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528toString%2528x.1%2529%252C%2520%2527%253A%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528groupArray%2528%2528y%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520toYear%2528date%2529%2520y%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520GROUP%2520BY%2520y%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=by%20year&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by year"></a>
225
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BA%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20A&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country A"></a>
226
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BB%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20B&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country B"></a>
227
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BC%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20C&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country C"></a>
228
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BD%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20D&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country D"></a>
229
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BE%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20E&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country E"></a>
230
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BF%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20F&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country F"></a>
231
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BG%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20G&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country G"></a>
232
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BH%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20H&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country H"></a>
233
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BI%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20I&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country I"></a>
234
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BJ%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20J&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country J"></a>
235
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BK%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20K&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country K"></a>
236
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BL%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20L&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country L"></a>
237
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BM%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20M&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country M"></a>
238
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BNO%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20N-O&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country N-O"></a>
239
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BPQ%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20P-Q&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country P-Q"></a>
240
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BR%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20R&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country R"></a>
241
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BS%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20S&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country S"></a>
242
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BT%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20T&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country T"></a>
243
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BUVWXYZ%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20U-Z&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country U-Z"></a>
244
+ </p>
245
+
246
+ These badges use the public [ClickHouse PyPI dataset](https://clickpy.clickhouse.com/dashboard/contextsage),
247
+ which refreshes daily, so counts may be about a day behind. Shields fetches the
248
+ data when badges are requested and caches images for up to an hour; GitHub may
249
+ also cache them. Weeks start on Monday (UTC). Country badges exclude missing
250
+ or invalid country codes. Explore interactive charts on the
251
+ [ClickPy dashboard](https://clickpy.clickhouse.com/dashboard/contextsage).
252
+
253
+ ## Development
254
+
255
+ ```bash
256
+ uv sync --locked --all-extras --all-groups
257
+ uv run pytest
258
+ uv run ruff check .
259
+ uv run pyrefly check
260
+ ```
261
+
262
+ See [contributing](https://github.com/smuniharish/contextsage/blob/master/CONTRIBUTING.md) and [testing](https://contextsage.readthedocs.io/en/latest/development/testing/).
263
+ ContextSage is licensed under the [Apache License 2.0](https://github.com/smuniharish/contextsage/blob/master/LICENSE).
@@ -0,0 +1,221 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/smuniharish/contextsage/master/docs/assets/logo.svg" alt="ContextSage logo" width="96">
3
+ </p>
4
+
5
+ <h1 align="center">ContextSage</h1>
6
+
7
+ <p align="center">
8
+ <a href="https://pypi.org/project/contextsage/"><img src="https://img.shields.io/pypi/v/contextsage" alt="PyPI"></a>
9
+ <a href="https://pypi.org/project/contextsage/"><img src="https://img.shields.io/pypi/pyversions/contextsage" alt="Python versions"></a>
10
+ <a href="https://github.com/smuniharish/contextsage/actions/workflows/ci.yml"><img src="https://github.com/smuniharish/contextsage/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
11
+ <a href="https://contextsage.readthedocs.io/"><img src="https://img.shields.io/readthedocs/contextsage" alt="Documentation"></a>
12
+ <a href="https://github.com/smuniharish/contextsage/blob/master/LICENSE"><img src="https://img.shields.io/pypi/l/contextsage" alt="License"></a>
13
+ </p>
14
+
15
+ **Information-aware context summarization for AI agents.** ContextSage is
16
+ summarization middleware that decides *when* a history must shrink, *what*
17
+ must survive verbatim, and *whether* a summary is safe to apply. It parses
18
+ heterogeneous context (conversation, tool calls and results, JSON, logs,
19
+ code, SQL, search results), compacts repetitive material, has your summary
20
+ model write the summary, validates that selected facts and tool relationships
21
+ survived, and records provenance. Its asynchronous core uses a neutral message
22
+ model and works with any agent framework.
23
+
24
+ Summarization must be information-preserving, not merely token-reducing:
25
+ when validation or reduction cannot be made safe, ContextSage keeps or
26
+ restores the original content instead of silently dropping it.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install contextsage
32
+ ```
33
+
34
+ Install optional integrations only when you use them:
35
+
36
+ ```bash
37
+ pip install "contextsage[langchain]" # LangChain and LangGraph
38
+ pip install "contextsage[otel]" # OpenTelemetry SDK and OTLP exporter
39
+ pip install "contextsage[all]" # both optional integrations
40
+ ```
41
+
42
+ The core requires Python 3.12 or newer and does not install an agent framework.
43
+
44
+ ## Framework-neutral quickstart
45
+
46
+ Implement `parsefabric.LanguageModel` with your summary provider, convert your
47
+ framework's history to `contextsage.Message`, then call the async engine before
48
+ the next model turn. Long-lived settings go in one `ContextSageConfig`; each
49
+ call takes one `SummarizationRequest` and returns one `SummarizationResult`:
50
+
51
+ ```python
52
+ from contextsage import (
53
+ BudgetConfig,
54
+ ContextSageConfig,
55
+ ContextSummarizer,
56
+ ModelBudget,
57
+ ReductionConfig,
58
+ SummarizationRequest,
59
+ TokenizerTokenCounter,
60
+ )
61
+
62
+
63
+ async def summarize_history(summary_model, messages):
64
+ counter = TokenizerTokenCounter()
65
+ config = ContextSageConfig(
66
+ model=summary_model,
67
+ budget=BudgetConfig(
68
+ target=ModelBudget(128_000, overhead_tokens=2_000, safety_margin=0.1),
69
+ summary=ModelBudget(64_000),
70
+ target_counter=counter,
71
+ summary_counter=counter,
72
+ ),
73
+ reduction=ReductionConfig(trigger=("tokens", 100_000), keep=("messages", 20)),
74
+ )
75
+ async with ContextSummarizer(config) as engine:
76
+ result = await engine.summarize(
77
+ SummarizationRequest(messages=messages, thread_id="conversation-42")
78
+ )
79
+ return list(result.messages) if result.changed else list(messages)
80
+ ```
81
+
82
+ The engine parses text and structured content, compacts repetitive material,
83
+ preserves facts such as identifiers and corrections, validates the result,
84
+ and records lineage. If the history does not meet the trigger,
85
+ `result.changed` is `False` and the history is returned unchanged. See the
86
+ runnable [quickstart](https://github.com/smuniharish/contextsage/blob/master/examples/quickstart.py) and the
87
+ [core concepts](https://contextsage.readthedocs.io/en/latest/guide/how-it-works/).
88
+
89
+ The budgets above are illustrative: configure the actual agent and summary
90
+ model limits, provider overhead, and model-specific token counters (the
91
+ default `TokenizerTokenCounter` is approximate). If compaction is not enough,
92
+ ContextSage can reduce oversized context using sequential, hierarchical, or
93
+ explicitly grouped passes. It raises `ReductionError` when the configured
94
+ constraints cannot be met safely. Validation is deterministic and checks
95
+ selected facts and tool pairing, not semantic equivalence; protect exact text
96
+ and choose a trusted provider when needed. See
97
+ [oversized-context reduction](https://contextsage.readthedocs.io/en/latest/guide/oversized-context/).
98
+
99
+ ## Integrations
100
+
101
+ The optional LangChain integration wraps the same core engine as an agent
102
+ middleware:
103
+
104
+ ```python
105
+ from contextsage import BudgetConfig, ContextSageConfig, ModelBudget, ReductionConfig
106
+ from contextsage.integrations.langchain import (
107
+ IntelligentSummarizationMiddleware,
108
+ LangChainMiddlewareConfig,
109
+ LangChainSummaryModel,
110
+ LangChainTokenCounter,
111
+ )
112
+
113
+
114
+ def make_middleware(summary_model):
115
+ counter = LangChainTokenCounter()
116
+ return IntelligentSummarizationMiddleware(
117
+ LangChainMiddlewareConfig(
118
+ context=ContextSageConfig(
119
+ model=LangChainSummaryModel(summary_model),
120
+ budget=BudgetConfig(
121
+ target=ModelBudget(128_000),
122
+ summary=ModelBudget(64_000),
123
+ target_counter=counter,
124
+ summary_counter=counter,
125
+ ),
126
+ reduction=ReductionConfig(
127
+ trigger=("tokens", 100_000),
128
+ keep=("messages", 20),
129
+ ),
130
+ )
131
+ )
132
+ )
133
+ ```
134
+
135
+ Or implement `FrameworkAdapter` for your framework's message type. The
136
+ adapter maps between native messages and the neutral `Message` model; no
137
+ framework dependency is needed by the core. See the [LangChain integration](https://contextsage.readthedocs.io/en/latest/guide/integrations/)
138
+ and [custom framework example](https://github.com/smuniharish/contextsage/blob/master/examples/custom_framework.py).
139
+
140
+ ## Downstream customization
141
+
142
+ ContextSage exposes the extension points of its dependencies rather than
143
+ restricting them to built-in choices:
144
+
145
+ | Package | Customizable components |
146
+ | --- | --- |
147
+ | [parsefabric](https://pypi.org/project/parsefabric/) | `LanguageModel`, tokenizers, line patterns, parsers and registries, fenced-code routes, code detection, JSON codec, lifecycle sink, and execution backend. |
148
+ | [agxai](https://pypi.org/project/agxai/) | `ProvenanceStore`, observability, attribution, explanation and policy providers, capture policy, runtime configuration, registry, plugins, and custom state capture. |
149
+ | OpenTelemetry | Use the built-in event sink and SDK/exporters, or supply an `EventSink` for your telemetry platform. |
150
+ | LangChain (optional) | Supply a chat model, token counter, and `LangChainAdapter` to the integration. |
151
+
152
+ Configure parsefabric through `AnalysisConfig(parsing=ParsingOptions(...))`
153
+ and agxai by passing your own `agxai.XAIRuntime` as
154
+ `ContextSageConfig(runtime=...)`. The
155
+ [downstream customization example](https://github.com/smuniharish/contextsage/blob/master/examples/downstream_customization.py)
156
+ demonstrates custom components from both packages.
157
+
158
+ ## Examples and documentation
159
+
160
+ The [examples](https://github.com/smuniharish/contextsage/blob/master/examples/README.md) include framework adapters, LangChain,
161
+ PostgreSQL provenance, OpenTelemetry, Prometheus, native reduction, custom
162
+ parsing, policies, and safe failure. Scripted examples run without API keys and their output is
163
+ verified in CI. The
164
+ [documentation site](https://contextsage.readthedocs.io/) includes
165
+ installation, configuration, integration guides, operations guidance and the
166
+ [API reference](https://contextsage.readthedocs.io/en/latest/reference/).
167
+
168
+ ContextSage also publishes [Agent Skills](https://github.com/smuniharish/contextsage/blob/master/contextsage-skills/README.md) for
169
+ coding agents that need to integrate or extend the package. The
170
+ [skills guide](https://contextsage.readthedocs.io/en/latest/agent-skills/) also lists independently maintained
171
+ dependency and integration skills.
172
+
173
+ ## Downloads
174
+
175
+ <p>
176
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=downloads&amp;color=blue&amp;cacheSeconds=3600" alt="Total downloads"></a>
177
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520date%2520%253E%253D%2520toStartOfWeek%2528toDate%2528now%2528%2527UTC%2527%2529%2529%252C%25201%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=this%20week&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads this week"></a>
178
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520date%2520%253E%253D%2520toStartOfMonth%2528toDate%2528now%2528%2527UTC%2527%2529%2529%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=this%20month&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads this month"></a>
179
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520sum%2528count%2529%2520v%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520date%2520%253E%253D%2520toStartOfYear%2528toDate%2528now%2528%2527UTC%2527%2529%2529%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=this%20year&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads this year"></a>
180
+ </p>
181
+ <p>
182
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528toString%2528x.1%2529%252C%2520%2527%253A%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528groupArray%2528%2528y%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520toYear%2528date%2529%2520y%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day%2520WHERE%2520project%253D%2527contextsage%2527%2520GROUP%2520BY%2520y%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=by%20year&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by year"></a>
183
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BA%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20A&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country A"></a>
184
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BB%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20B&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country B"></a>
185
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BC%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20C&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country C"></a>
186
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BD%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20D&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country D"></a>
187
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BE%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20E&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country E"></a>
188
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BF%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20F&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country F"></a>
189
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BG%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20G&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country G"></a>
190
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BH%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20H&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country H"></a>
191
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BI%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20I&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country I"></a>
192
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BJ%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20J&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country J"></a>
193
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BK%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20K&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country K"></a>
194
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BL%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20L&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country L"></a>
195
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BM%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20M&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country M"></a>
196
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BNO%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20N-O&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country N-O"></a>
197
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BPQ%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20P-Q&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country P-Q"></a>
198
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BR%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20R&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country R"></a>
199
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BS%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20S&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country S"></a>
200
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BT%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20T&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country T"></a>
201
+ <a href="https://clickpy.clickhouse.com/dashboard/contextsage"><img class="off-glb" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsql-clickhouse.clickhouse.com%2F%3Fuser%3Ddemo%26query%3DSELECT%2520arrayStringConcat%2528arrayMap%2528x%2520-%253E%2520concat%2528x.1%252C%2520%2527%2520%2527%252C%2520toString%2528x.2%2529%2529%252C%2520arraySort%2528x%2520-%253E%2520%2528-toInt64%2528x.2%2529%252C%2520x.1%2529%252C%2520groupArray%2528%2528country%252C%2520c%2529%2529%2529%2529%252C%2520%2527%2520%257C%2520%2527%2529%2520v%2520FROM%2520%2528SELECT%2520ifNull%2528nullIf%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527unknown%2527%2529%2520country%252C%2520sum%2528count%2529%2520c%2520FROM%2520pypi.pypi_downloads_per_day_by_version_by_country%2520WHERE%2520project%253D%2527contextsage%2527%2520AND%2520match%2528ifNull%2528country_code%252C%2520%2527%2527%2529%252C%2520%2527%255E%255BUVWXYZ%255D%255BA-Z%255D%2524%2527%2529%2520GROUP%2520BY%2520country%2529%2520FORMAT%2520JSON&amp;query=%24.data%5B0%5D.v&amp;label=countries%20U-Z&amp;color=blue&amp;cacheSeconds=3600" alt="Downloads by country U-Z"></a>
202
+ </p>
203
+
204
+ These badges use the public [ClickHouse PyPI dataset](https://clickpy.clickhouse.com/dashboard/contextsage),
205
+ which refreshes daily, so counts may be about a day behind. Shields fetches the
206
+ data when badges are requested and caches images for up to an hour; GitHub may
207
+ also cache them. Weeks start on Monday (UTC). Country badges exclude missing
208
+ or invalid country codes. Explore interactive charts on the
209
+ [ClickPy dashboard](https://clickpy.clickhouse.com/dashboard/contextsage).
210
+
211
+ ## Development
212
+
213
+ ```bash
214
+ uv sync --locked --all-extras --all-groups
215
+ uv run pytest
216
+ uv run ruff check .
217
+ uv run pyrefly check
218
+ ```
219
+
220
+ See [contributing](https://github.com/smuniharish/contextsage/blob/master/CONTRIBUTING.md) and [testing](https://contextsage.readthedocs.io/en/latest/development/testing/).
221
+ ContextSage is licensed under the [Apache License 2.0](https://github.com/smuniharish/contextsage/blob/master/LICENSE).