evolution-sdk 0.8.0__py3-none-any.whl
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.
- evolution/__init__.py +102 -0
- evolution/adapters/__init__.py +28 -0
- evolution/adapters/base.py +21 -0
- evolution/adapters/crewai.py +86 -0
- evolution/adapters/direct.py +120 -0
- evolution/adapters/langchain.py +112 -0
- evolution/adapters/llamaindex.py +96 -0
- evolution/capture/__init__.py +22 -0
- evolution/capture/introspect.py +164 -0
- evolution/capture/recorder.py +109 -0
- evolution/capture/tracker.py +194 -0
- evolution/evaluators.py +268 -0
- evolution/exceptions.py +52 -0
- evolution/models/__init__.py +40 -0
- evolution/models/artifacts.py +248 -0
- evolution/models/evaluation.py +77 -0
- evolution/models/execution.py +77 -0
- evolution/models/manifest.py +210 -0
- evolution/repository.py +360 -0
- evolution/validator.py +55 -0
- evolution_sdk-0.8.0.dist-info/METADATA +240 -0
- evolution_sdk-0.8.0.dist-info/RECORD +25 -0
- evolution_sdk-0.8.0.dist-info/WHEEL +5 -0
- evolution_sdk-0.8.0.dist-info/licenses/LICENSE +21 -0
- evolution_sdk-0.8.0.dist-info/top_level.txt +1 -0
evolution/validator.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manifest validator conforming to Intelligence Manifest Specification v1.0.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
from evolution.exceptions import ManifestValidationError
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from evolution.models.manifest import Manifest
|
|
14
|
+
|
|
15
|
+
SEMVER_PATTERN = re.compile(r"^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$")
|
|
16
|
+
VALID_ARTIFACT_TYPES = {"prompt", "memory", "retrieval", "tool", "model_config", "policy"}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def validate_manifest(manifest: Manifest) -> None:
|
|
20
|
+
"""Validates that a Manifest instance strictly adheres to Spec v1.0.
|
|
21
|
+
Raises ManifestValidationError if any violations are found.
|
|
22
|
+
"""
|
|
23
|
+
errors: list[str] = []
|
|
24
|
+
|
|
25
|
+
# 1. Version validation
|
|
26
|
+
if not manifest.version or not manifest.version.strip():
|
|
27
|
+
errors.append("manifest 'version' is required and cannot be empty")
|
|
28
|
+
elif not SEMVER_PATTERN.match(manifest.version):
|
|
29
|
+
errors.append(f"manifest 'version' '{manifest.version}' is not valid semantic versioning (e.g. 1.0.0)")
|
|
30
|
+
|
|
31
|
+
# 2. Name validation
|
|
32
|
+
if not manifest.name or not manifest.name.strip():
|
|
33
|
+
errors.append("manifest 'name' is required and cannot be empty")
|
|
34
|
+
|
|
35
|
+
# 3. Artifact validations
|
|
36
|
+
for art in manifest.artifacts.all():
|
|
37
|
+
if not art.type:
|
|
38
|
+
errors.append(f"artifact '{art.name}' has missing type")
|
|
39
|
+
elif art.type not in VALID_ARTIFACT_TYPES:
|
|
40
|
+
errors.append(f"artifact '{art.name}' has invalid type '{art.type}' (must be one of {sorted(VALID_ARTIFACT_TYPES)})")
|
|
41
|
+
|
|
42
|
+
if not art.name or not art.name.strip():
|
|
43
|
+
errors.append(f"found artifact of type '{art.type}' with empty name")
|
|
44
|
+
|
|
45
|
+
# 4. Model Config specific validation
|
|
46
|
+
if manifest.artifacts.model_config:
|
|
47
|
+
mc = manifest.artifacts.model_config
|
|
48
|
+
if not mc.model or not mc.model.strip():
|
|
49
|
+
errors.append("model_config artifact requires a non-empty 'model' field")
|
|
50
|
+
|
|
51
|
+
if errors:
|
|
52
|
+
raise ManifestValidationError(
|
|
53
|
+
f"Manifest validation failed with {len(errors)} error(s)",
|
|
54
|
+
errors=errors,
|
|
55
|
+
)
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: evolution-sdk
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: Python SDK for Evolution โ AI-Native Version Control Platform
|
|
5
|
+
Author-email: "Urvish.A.Prajapati" <prajapatiurvish712@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Urvish0/Evolution
|
|
8
|
+
Project-URL: Repository, https://github.com/Urvish0/Evolution
|
|
9
|
+
Project-URL: Specification, https://github.com/Urvish0/Evolution/blob/main/spec/intelligence-manifest-v1.0.md
|
|
10
|
+
Keywords: ai,version-control,llm,manifest,evaluation,langchain,llamaindex
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Classifier: Topic :: Software Development :: Version Control
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# Evolution Python SDK (`evolution-sdk`)
|
|
28
|
+
|
|
29
|
+
> **"Version Intelligence, Not Code."**
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/evolution-sdk/)
|
|
32
|
+
[](https://pypi.org/project/evolution-sdk/)
|
|
33
|
+
[](https://github.com/Urvish0/Evolution/blob/main/LICENSE)
|
|
34
|
+
[](#features)
|
|
35
|
+
|
|
36
|
+
The official Python SDK for **[Evolution](https://github.com/Urvish0/Evolution)** โ an open-source, AI-native version control platform.
|
|
37
|
+
|
|
38
|
+
While traditional version control systems (like Git) track line-by-line changes to text files, **Evolution tracks and versions Intelligence**: the complete operational state of an AI system (system prompts, sampling parameters, memory strategies, vector store retrieval configurations, tool schemas, and guardrails).
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## โก Key Features
|
|
43
|
+
|
|
44
|
+
- ๐ชถ **Zero Runtime Dependencies**: Pure Python implementation with zero third-party dependencies. Ultra-fast, lightweight, and won't conflict with your environment.
|
|
45
|
+
- ๐ฏ **Automatic Intelligence Capture**: Use the `@evolution.track` decorator to automatically extract docstring prompts, model hyperparameters, token consumption, and latency.
|
|
46
|
+
- โฑ๏ธ **Precision Execution Telemetry**: Record execution traces, inputs, outputs, and hardware latency using `@track` or the `evolution.record` context manager.
|
|
47
|
+
- ๐ **Universal Framework Adapters**: Seamlessly introspect and export standard Intelligence Manifests from **LangChain**, **LlamaIndex**, **CrewAI**, and direct OpenAI / Anthropic client calls.
|
|
48
|
+
- ๐ **Git-Compatible CAS Blobs**: Content-Addressable Storage with auto-computed SHA-256 Merkle hashes.
|
|
49
|
+
- ๐ **Intelligence Manifest Spec v1.0 Compliant**: Native support for creating, validating, and saving standard `evolution.manifest.json` schemas.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## ๐ฆ Installation
|
|
54
|
+
|
|
55
|
+
Install `evolution-sdk` via `pip` or `uv`:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install evolution-sdk
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or using `uv`:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uv add evolution-sdk
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ๐ Quickstart in 30 Seconds
|
|
70
|
+
|
|
71
|
+
### 1. Initialize or Open an Evolution Repository
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import evolution as evo
|
|
75
|
+
|
|
76
|
+
# Initialize a new Evolution repository in the current directory
|
|
77
|
+
repo = evo.Repository.init("./my_ai_agent")
|
|
78
|
+
|
|
79
|
+
# Or open an existing repository
|
|
80
|
+
# repo = evo.Repository.open("./my_ai_agent")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### 2. Automatic Intelligence Tracking with `@evo.track`
|
|
86
|
+
|
|
87
|
+
Decorate your AI agent functions. Evolution automatically extracts the docstring as the system prompt, registers model configs, measures latency, and logs execution tokens without modifying your business logic:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from openai import OpenAI
|
|
91
|
+
import evolution as evo
|
|
92
|
+
|
|
93
|
+
client = OpenAI()
|
|
94
|
+
repo = evo.Repository.init("./my_agent")
|
|
95
|
+
|
|
96
|
+
@evo.track(
|
|
97
|
+
repo=repo,
|
|
98
|
+
name="customer-support-agent",
|
|
99
|
+
model="gpt-4o",
|
|
100
|
+
temperature=0.2,
|
|
101
|
+
)
|
|
102
|
+
def handle_customer_inquiry(user_message: str):
|
|
103
|
+
"""Senior Customer Support Specialist. Always maintain professional tone and provide step-by-step guidance."""
|
|
104
|
+
response = client.chat.completions.create(
|
|
105
|
+
model="gpt-4o",
|
|
106
|
+
temperature=0.2,
|
|
107
|
+
messages=[
|
|
108
|
+
{"role": "system", "content": "You are a Senior Customer Support Specialist."},
|
|
109
|
+
{"role": "user", "content": user_message}
|
|
110
|
+
]
|
|
111
|
+
)
|
|
112
|
+
return response
|
|
113
|
+
|
|
114
|
+
# Run your agent
|
|
115
|
+
result = handle_customer_inquiry("How do I reset my API key?")
|
|
116
|
+
|
|
117
|
+
# Commit the captured intelligence snapshot
|
|
118
|
+
repo.commit("feat: initial customer support intelligence snapshot")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### 3. Precision Latency & Execution Recording with `record()`
|
|
124
|
+
|
|
125
|
+
For fine-grained telemetry or manual pipelines, use the `record` context manager:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
import evolution as evo
|
|
129
|
+
|
|
130
|
+
repo = evo.Repository.open(".")
|
|
131
|
+
|
|
132
|
+
with evo.record(repo, metadata={"phase": "testing"}) as ctx:
|
|
133
|
+
# Set inputs
|
|
134
|
+
ctx.set_inputs("User asked: Explain Merkle trees.")
|
|
135
|
+
|
|
136
|
+
# Execute your LLM call
|
|
137
|
+
response_text = "A Merkle tree is a cryptographic tree structure..."
|
|
138
|
+
|
|
139
|
+
# Record outputs and token metrics
|
|
140
|
+
ctx.set_outputs(response_text)
|
|
141
|
+
ctx.set_tokens(prompt_tokens=42, completion_tokens=128)
|
|
142
|
+
|
|
143
|
+
print(f"Recorded execution with duration: {ctx.execution.duration_ms} ms")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## ๐ Framework Adapters
|
|
149
|
+
|
|
150
|
+
Evolution provides plug-and-play adapters to export standard Intelligence Manifests directly from your existing AI framework abstractions:
|
|
151
|
+
|
|
152
|
+
### LangChain Adapter
|
|
153
|
+
```python
|
|
154
|
+
from langchain_openai import ChatOpenAI
|
|
155
|
+
from langchain_core.prompts import ChatPromptTemplate
|
|
156
|
+
from evolution.adapters import LangChainAdapter
|
|
157
|
+
|
|
158
|
+
prompt = ChatPromptTemplate.from_template("Summarize the following legal document: {doc}")
|
|
159
|
+
llm = ChatOpenAI(model="gpt-4o", temperature=0.1)
|
|
160
|
+
chain = prompt | llm
|
|
161
|
+
|
|
162
|
+
manifest = LangChainAdapter.from_langchain(chain, name="legal-summarizer")
|
|
163
|
+
print(manifest.to_dict())
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### LlamaIndex Adapter
|
|
167
|
+
```python
|
|
168
|
+
from llama_index.core import VectorStoreIndex
|
|
169
|
+
from evolution.adapters import LlamaIndexAdapter
|
|
170
|
+
|
|
171
|
+
manifest = LlamaIndexAdapter.from_llamaindex(
|
|
172
|
+
index=my_vector_index,
|
|
173
|
+
name="financial-rag-agent",
|
|
174
|
+
similarity_top_k=5,
|
|
175
|
+
)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### CrewAI Adapter
|
|
179
|
+
```python
|
|
180
|
+
from crewai import Agent, Crew, Task
|
|
181
|
+
from evolution.adapters import CrewAIAdapter
|
|
182
|
+
|
|
183
|
+
manifest = CrewAIAdapter.from_crewai(my_crew, name="research-crew")
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## ๐ The Intelligence Manifest Format (`evolution.manifest.json`)
|
|
189
|
+
|
|
190
|
+
Evolution stores your complete AI system state in a portable, framework-agnostic manifest following the **[Intelligence Manifest Specification v1.0](https://github.com/Urvish0/Evolution/blob/main/spec/intelligence-manifest-v1.0.md)**:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"version": "1.0.0",
|
|
195
|
+
"name": "legal-dispute-resolution-system",
|
|
196
|
+
"description": "AI system powered by Evolution version control",
|
|
197
|
+
"artifacts": {
|
|
198
|
+
"prompts": [
|
|
199
|
+
{
|
|
200
|
+
"type": "prompt",
|
|
201
|
+
"name": "strict-legal-analyst-prompt",
|
|
202
|
+
"description": "Extracted docstring prompt",
|
|
203
|
+
"role": "system",
|
|
204
|
+
"format": "text"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
"model_config": {
|
|
208
|
+
"type": "model_config",
|
|
209
|
+
"name": "analyst-model",
|
|
210
|
+
"model": "qwen/qwen3.8-27b",
|
|
211
|
+
"provider": "local",
|
|
212
|
+
"temperature": 0.1
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## ๐งช Running Tests
|
|
221
|
+
|
|
222
|
+
To run the SDK test suite:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
pytest sdk/python/tests/ -v
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## ๐ License
|
|
231
|
+
|
|
232
|
+
This project is licensed under the **MIT License** โ see the [LICENSE](LICENSE) file for details.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## ๐ Links
|
|
237
|
+
|
|
238
|
+
- **GitHub Repository:** [https://github.com/Urvish0/Evolution](https://github.com/Urvish0/Evolution)
|
|
239
|
+
- **Specification:** [Intelligence Manifest Spec v1.0](https://github.com/Urvish0/Evolution/blob/main/spec/intelligence-manifest-v1.0.md)
|
|
240
|
+
- **Documentation:** [Technical Manual](https://github.com/Urvish0/Evolution/blob/main/DOCUMENTATION.md)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
evolution/__init__.py,sha256=NoxLSVCVrVDVafpNzjth7AJpdIn9lzL-neYa4uX94C8,2331
|
|
2
|
+
evolution/evaluators.py,sha256=P7k886MdF1wF5EbAMOmaxHnTR-z3FV6aQySb2BSsBpw,9979
|
|
3
|
+
evolution/exceptions.py,sha256=nuF-P8uviuC-k7p35AfD5AfDB4ZGblp9GqjYyNYmjtQ,1559
|
|
4
|
+
evolution/repository.py,sha256=oVa2nt4s5TXP5N8gBDnKjgFbW0yA777PURpt_VwFBbI,13426
|
|
5
|
+
evolution/validator.py,sha256=HDVrf8MgKhwYgWG862jy_VmOu6qRmGsZJZesgOfdw7A,2083
|
|
6
|
+
evolution/adapters/__init__.py,sha256=d-MYNaa7Bj_nMqQDOPF3rZLTd6dvziibiCA_rAVXltU,685
|
|
7
|
+
evolution/adapters/base.py,sha256=cQ9fwdV66WDJiMZe8PfPbka3pN2wwKey1bgMThmFmpA,592
|
|
8
|
+
evolution/adapters/crewai.py,sha256=8Qrgr0YXc16RBrXKCax31G0Bwu9oW1xMM_rzL3-t93Q,3257
|
|
9
|
+
evolution/adapters/direct.py,sha256=gT-n0_UpMP4g7_IfkjZz-rq4CBd-Flrsid42nKsDkvE,4673
|
|
10
|
+
evolution/adapters/langchain.py,sha256=_UZBd2fFUiTWnzCqkGS4e9sgm_N4asaokJvo7KlURrQ,4296
|
|
11
|
+
evolution/adapters/llamaindex.py,sha256=uRk5FJtOjERMP0aS63CbkWuVw5n-kUhhE6yG7lqeX5Q,3812
|
|
12
|
+
evolution/capture/__init__.py,sha256=mgm5VJ4FSG-47266tnoBhIF4rI8giPE6d4ECgkKhpXU,556
|
|
13
|
+
evolution/capture/introspect.py,sha256=GaWgyH-3xmkV0rKl-rzyhehHP1cgjr_u4wJU395Pmnc,6083
|
|
14
|
+
evolution/capture/recorder.py,sha256=h5mr7XsaGtVERg2xRHfzKxpRdpDAvwyPWGqhaT_OpsM,3666
|
|
15
|
+
evolution/capture/tracker.py,sha256=oo_n5fgiiUpmOgQ1_wHNiQrO9Lubjo1YKVGTjsEjn6k,7349
|
|
16
|
+
evolution/models/__init__.py,sha256=_hrP5Hv3pr77PkKhtGYZhjLsZAnLH7d7QWVWtPIOBkg,913
|
|
17
|
+
evolution/models/artifacts.py,sha256=HJClVHkoSmnLlkw0I-38og7Vq9Rzq_Qp8cxDjlzssVw,8084
|
|
18
|
+
evolution/models/evaluation.py,sha256=Bnex4cqUKzjXPEBhFiUZQYF7itUAT6b7p8ifyJFIdRw,2417
|
|
19
|
+
evolution/models/execution.py,sha256=y7CLEJhYgXyMxUB7IA1tvvZPSZkzpnpq3AO4--5tf1I,2551
|
|
20
|
+
evolution/models/manifest.py,sha256=-laZ8S_0DIOX4cGgUSeunDm4pU9QtXkr3G0rbEi3aUQ,8804
|
|
21
|
+
evolution_sdk-0.8.0.dist-info/licenses/LICENSE,sha256=HD5ahlAJyKJl5UKCaolDIrkypthJLeW2Ubo2_SVAJUA,1107
|
|
22
|
+
evolution_sdk-0.8.0.dist-info/METADATA,sha256=qg0rvU3eyJYDdlM7s_L-0ozklJxb2YInrRp2B25OktY,8275
|
|
23
|
+
evolution_sdk-0.8.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
24
|
+
evolution_sdk-0.8.0.dist-info/top_level.txt,sha256=gW3pWW6BWlvnuBZ0UUaTfFXmsO2ln3T2GXAWfmlzr-s,10
|
|
25
|
+
evolution_sdk-0.8.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Urvish A. Prajapati (prajapatiurvish712@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
evolution
|