LLM powered Python
Project description
Nerif
Program with both Python and Natural Language.
LLMs can be tricky to work with. They sometimes give overly formal responses or get confused when they're unsure, making them challenging to use in real applications.
That's why we built Nerif - a simple tool that connects LLMs with Python code. We want to make it better than existing tools like Langchain and Dify.
Nerif helps you:
- Control exactly how LLMs work in your code
- Convert LLM responses into usable data formats
- Track performance with metrics like cost and success rate
Our goal is to make LLMs easier to use for developers, turning complex AI capabilities into practical programming tools.
How to install
Pre-requisite
- Python >= 3.10
- Environment variable
OPENAI_API_KEYor other LLM API keys, for more details, see here - Set default model and embedding model with
NERIF_DEFAULT_LLM_MODELandNERIF_DEFAULT_EMBEDDING_MODEL, for more details, see here
Example:
export OPENAI_API_KEY=`your_api_key`
export NERIF_DEFAULT_LLM_MODEL=gpt-4o
export NERIF_DEFAULT_EMBEDDING_MODEL=text-embedding-3-small
Install
pip install nerif
Optional feature groups:
pip install "nerif[rag]" # NumPy vector store for RAG
pip install "nerif[img-gen]" # Image generation (Pillow)
QuickStart
from nerif.core import nerif
from nerif.model import SimpleChatModel
model = SimpleChatModel()
# Default model is `gpt-4o`
# Use nerif judge "natural language statement"
if nerif("the sky is blue"):
print("True")
else:
# Call a simple model
print("No", end=", ")
print(model.chat("what is the color of the sky?"))
Changelog
v1.3.0
- Async agent:
NerifAgent.arun()with concurrent tool execution - Model fallback chain: automatic failover on transient errors
- Callback/hook system: 7 event types for observability
PromptTemplate: variable substitution, defaults, conditional sections- Rate limiting: per-model/provider request throttling
- Enhanced ASR:
Transcriberwith language/format/translate support - Enhanced TTS:
Synthesizerwith voice/speed/format/file output - Streaming now supports token counting and retry
v1.2.0
ConversationMemory: sliding window with auto-summarizationNerifTokenCounter: latency, cost, success rate tracking- Lightweight RAG with
NumpyVectorStore - Custom exception hierarchy (
NerifError,ProviderError, etc.) - CLI tools:
nerif check,nerif test-model,nerif models
v1.1.0
- Streaming and async support (
stream_chat,achat) - Pydantic structured output (
response_model=) - Retry with exponential backoff (
RetryConfig) - Optional embedding model
- Multi-provider routing (OpenAI, Anthropic, Gemini, Ollama, etc.)
Documentation
More detailed documentation is on the official website.
License
Nerif is licensed under the GNU General Public License v3.0.
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 nerif-1.3.1.tar.gz.
File metadata
- Download URL: nerif-1.3.1.tar.gz
- Upload date:
- Size: 7.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3f23f5857bce6a6a4476cc1aced9998c6b454249c02c8b73ce5df0c78e6604c
|
|
| MD5 |
213a932591cb0ddc36f508c01a7feae0
|
|
| BLAKE2b-256 |
c63db4c119e091c90817b878e25efd3ea35fa2091be6d8068360576a40ac7370
|
Provenance
The following attestation bundles were made for nerif-1.3.1.tar.gz:
Publisher:
release.yml on Nerif-AI/Nerif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nerif-1.3.1.tar.gz -
Subject digest:
b3f23f5857bce6a6a4476cc1aced9998c6b454249c02c8b73ce5df0c78e6604c - Sigstore transparency entry: 1131397422
- Sigstore integration time:
-
Permalink:
Nerif-AI/Nerif@14ff90c2efe4bae239714ed329699c73f3792d4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nerif-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14ff90c2efe4bae239714ed329699c73f3792d4b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nerif-1.3.1-py3-none-any.whl.
File metadata
- Download URL: nerif-1.3.1-py3-none-any.whl
- Upload date:
- Size: 101.0 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 |
557ee5140927280d42952bda7ee97420a71c57b8456dca9e087984584800ffa0
|
|
| MD5 |
c4cc143e15d8c6bd152d5afccddb1763
|
|
| BLAKE2b-256 |
98045464425331ae1271cd29038f3f2693012bf175e377cc568bee63de9d98fc
|
Provenance
The following attestation bundles were made for nerif-1.3.1-py3-none-any.whl:
Publisher:
release.yml on Nerif-AI/Nerif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nerif-1.3.1-py3-none-any.whl -
Subject digest:
557ee5140927280d42952bda7ee97420a71c57b8456dca9e087984584800ffa0 - Sigstore transparency entry: 1131397478
- Sigstore integration time:
-
Permalink:
Nerif-AI/Nerif@14ff90c2efe4bae239714ed329699c73f3792d4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nerif-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14ff90c2efe4bae239714ed329699c73f3792d4b -
Trigger Event:
push
-
Statement type: