Providing a single, intuitive function for semantic judgment.
Project description
semantif
What if semantic checks were as simple as a boolean if?
semantif is a minimalist Python library that hides all the LLM complexity behind a single, dead-simple function for semantic judgment.
Why This Exists
LLMs are incredibly powerful, but using them for a simple yes/no question? You end up writing tons of boilerplate for prompt engineering, API calls, response parsing, error handling... ugh 😩
semantif lets developers ask straightforward questions without getting lost in the weeds. Because sometimes you just want to know if a user is angry, not become a prompt engineer.
Key Features
- Zero Boilerplate: One
judge()function. That's it. - Actually Pythonic: Made specifically for if statements. Your code reads like English.
- Lightweight: No weird dependencies cluttering your project.
Getting Started
Installation
pip install semantif
Quickstart
Before using semantif, you need to set up your LLM provider's API key. For security, it is highly recommended to manage API keys using environment variables rather than embedding them directly in your code.
Please store your OpenAI API key in an environment variable named OPENAI_API_KEY.
from semantif import judge
import os
os.environ["OPENAI_API_KEY"] = "your-api-key-here"
# Note: Replace "your-api-key-here" with your actual API key
# Language understanding - detect user emotions
user_feedback = "Yeah, right, right. Sure, sure, sure, whatever you say."
if judge("user is angry", user_feedback):
escalate_to_manager()
# Semantic equality - understand different representations of the same concept
number = "cinco"
if judge("equal five", number):
skip_queue()
# Content validation - intelligent pattern recognition
user_input = 'fakemail@thisisatest.com'
if judge("does it look like a real email?", user_input):
send_verification()
Why semantif.judge()?
Traditional if/else statements are precise but become a maintenance nightmare when conditions get complex. With the advancement of LLMs that can now reliably output reasonable responses, semantif.judge() leverages this capability to make your conditions more natural and significantly more flexible.
Perfect for Rapid Prototyping:
As LLMs have become stable and reliable, using semantic judgment can dramatically accelerate your proof-of-concept (POC) development. Instead of spending hours crafting complex logic, you can express your intent in plain language and get immediate results.
Traditional if/else (verbose and incomplete):
# Imagine writing all this just to detect anger... 😵
if ("terrible" in text.lower() or
"awful" in text.lower() or
"worst" in text.lower() or
"hate" in text.lower() or
"sucks" in text.lower() or
"horrible" in text.lower() or
"disappointed" in text.lower() or
# ... and hundreds of other variations
# Plus you'd need to handle typos, different languages, etc.
):
escalate_to_manager()
# And this still won't catch everything! 🤷♂️
With semantif (simple and comprehensive):
if judge("user is angry", user_message):
escalate_to_manager()
License
MIT License.
✅ Roadmap
- Multi-Provider Support
- Integrate on-device models via llama.cpp. This will feature a first-use, automatic model downloader for a true zero-configuration experience.
- Add async support by implementing a semantif.async_judge() function.
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 semantif-0.1.1.tar.gz.
File metadata
- Download URL: semantif-0.1.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f7ee97beac0e1912083ca12beea5034c9dc2e20013fce95b4533b681076379b
|
|
| MD5 |
67d6416c597034a8dc23f7c14c3a53b8
|
|
| BLAKE2b-256 |
a23d3a08dc61652b8da3f7b18c9098678c2548cb93ceb1d5964068998e3cce15
|
Provenance
The following attestation bundles were made for semantif-0.1.1.tar.gz:
Publisher:
python-publish.yml on Crafter3149/semantif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semantif-0.1.1.tar.gz -
Subject digest:
8f7ee97beac0e1912083ca12beea5034c9dc2e20013fce95b4533b681076379b - Sigstore transparency entry: 239077352
- Sigstore integration time:
-
Permalink:
Crafter3149/semantif@3f9f04fb5826a412062cb68d663bd0badc6020af -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Crafter3149
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3f9f04fb5826a412062cb68d663bd0badc6020af -
Trigger Event:
release
-
Statement type:
File details
Details for the file semantif-0.1.1-py3-none-any.whl.
File metadata
- Download URL: semantif-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df6b55fcb97623c557523b24ae5b05001711ef0e56b77d35fe88890224c8646
|
|
| MD5 |
14e9568bfd4ce86e14ade16e1b5b6921
|
|
| BLAKE2b-256 |
7716d1fd841c70bd971ef980a95436cf15e872ba810a27cc6399c8d002d68077
|
Provenance
The following attestation bundles were made for semantif-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on Crafter3149/semantif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semantif-0.1.1-py3-none-any.whl -
Subject digest:
3df6b55fcb97623c557523b24ae5b05001711ef0e56b77d35fe88890224c8646 - Sigstore transparency entry: 239077372
- Sigstore integration time:
-
Permalink:
Crafter3149/semantif@3f9f04fb5826a412062cb68d663bd0badc6020af -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Crafter3149
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3f9f04fb5826a412062cb68d663bd0badc6020af -
Trigger Event:
release
-
Statement type: