Self-learning LLM call library. Every call learns. Every call improves.
Project description
netanel-core
The self-learning LLM call. Every call learns. Every call improves.
A Python library that wraps any LLM with file-based memory and automatic quality improvement. No database required.
from netanel_core import LearningLLM
llm = LearningLLM(namespace="my-app")
result = llm.call("Write a function to validate emails")
print(result.response) # The LLM's output
print(result.score) # Quality score (0.0-1.0)
print(result.usage) # Token usage for cost tracking
✨ Features
- 🧠 Self-Learning - Extracts patterns from every call, builds better context over time
- 📊 Quality-First - Auto-evaluation + retry loop, only stores high-quality outputs
- 💾 File-Based Memory - No database, human-readable
.mdfiles, git-trackable - 🔄 Prompt Evolution - Auto-rewrites prompts based on learnings
- 🎯 Bounded Safety - Max retries, tokens, iterations (NASA-grade)
- 🤖 DeepAgent Support - Complex reasoning with LangGraph agents
- 💰 Cost Tracking - Token usage for all calls
🚀 Quick Start
pip install netanel-core
from netanel_core import LearningLLM
llm = LearningLLM(namespace="my-app")
result = llm.call("Explain quantum computing simply")
if result.passed:
print(result.response)
print(f"Quality: {result.score:.2f}, Tokens: {result.usage['total_tokens']}")
📖 How It Works
Every llm.call() executes:
- RETRIEVE - Load memories from namespace
- BUILD - Create context (role + memories + task)
- CALL - Invoke LLM
- EVALUATE - Score quality (gpt-4o-mini + main model)
- RETRY - If score < threshold, retry with feedback
- EXTRACT - Extract patterns from successful responses
- STORE - Save to
memories/{namespace}/patterns/ - EVOLVE - Trigger prompt improvements
- RETURN - Result with response + metadata
💡 Usage Examples
Custom Model
from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-4", temperature=0.7)
llm = LearningLLM(namespace="gpt4-app", model=model)
DeepAgent Mode
result = llm.call(
"Research AI papers and summarize trends",
use_agent=True # Multi-step reasoning
)
print(f"Steps: {result.agent_steps}")
Cost Tracking
total = sum(llm.call(task).usage['total_tokens'] for task in tasks)
cost = (total / 1_000_000) * 0.375 # gpt-4o-mini avg
print(f"Cost: ${cost:.4f}")
🎯 Configuration
from netanel_core import Config
config = Config(
namespace="my-app",
quality_threshold=0.8,
max_retries=3,
memories_dir="./memories",
)
llm = LearningLLM(config=config)
Or YAML:
namespace: my-app
quality_threshold: 0.8
max_retries: 3
config = Config.from_yaml("config.yaml")
📂 Memory Structure
memories/
└── {namespace}/
├── patterns/
│ ├── 001-function-structure.md
│ └── 002-error-handling.md
└── prompts/
└── current.md
Human-readable Markdown - inspect or version control.
🧪 Development
pip install -e .[dev]
pytest --cov
📚 Documentation
- Architecture - System design
- API Reference - Complete API
- Examples - Usage patterns
📝 License
MIT - see LICENSE
Built by Netanel Systems with LangGraph + Deep Agents
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netanel_core-0.2.0.tar.gz.
File metadata
- Download URL: netanel_core-0.2.0.tar.gz
- Upload date:
- Size: 148.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff8e8183dbef937ceafa7384d9d3d07389759a7ee8cb842f00852468fa9f1b0a
|
|
| MD5 |
63cd0d8cebf1dae9fe47578f58c3240f
|
|
| BLAKE2b-256 |
ccfce6bd4e5572deb6445d85d12215d7c079be37c64504c5190b40e1e249a9e7
|
Provenance
The following attestation bundles were made for netanel_core-0.2.0.tar.gz:
Publisher:
publish.yml on netanel-systems/netanel-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
netanel_core-0.2.0.tar.gz -
Subject digest:
ff8e8183dbef937ceafa7384d9d3d07389759a7ee8cb842f00852468fa9f1b0a - Sigstore transparency entry: 969289834
- Sigstore integration time:
-
Permalink:
netanel-systems/netanel-core@dd6ac433a3940c22aac357ff1d8a4e0c78473046 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/netanel-systems
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd6ac433a3940c22aac357ff1d8a4e0c78473046 -
Trigger Event:
release
-
Statement type:
File details
Details for the file netanel_core-0.2.0-py3-none-any.whl.
File metadata
- Download URL: netanel_core-0.2.0-py3-none-any.whl
- Upload date:
- Size: 67.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72b8a062313fda2bcc8cf778564b14240f8cceb23019f26ac44993789fa39151
|
|
| MD5 |
ef0039adca99ba8a3153ff57faa50f7e
|
|
| BLAKE2b-256 |
5bf694f3716470b102feb28242260be0da022a3a5384b497c1654ecee1a6c6db
|
Provenance
The following attestation bundles were made for netanel_core-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on netanel-systems/netanel-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
netanel_core-0.2.0-py3-none-any.whl -
Subject digest:
72b8a062313fda2bcc8cf778564b14240f8cceb23019f26ac44993789fa39151 - Sigstore transparency entry: 969289836
- Sigstore integration time:
-
Permalink:
netanel-systems/netanel-core@dd6ac433a3940c22aac357ff1d8a4e0c78473046 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/netanel-systems
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd6ac433a3940c22aac357ff1d8a4e0c78473046 -
Trigger Event:
release
-
Statement type: