Give Superpowers to your python function. GenAI Application development made easy.
Project description
Semantix provides a simple but powerful way to infuse meaning into functions, variables and classes to leverage the power of Large Language models to generate structured typed outputs without the need of JSON Schema or any other abstractions.
Key Features:
- Semantic Type: Add meaning to your variables. No need of additional abstractions like
InputField
,OutputField
etc. - AutoPrompting: Semantix Generate prompts using the
Meaning Typed Prompting
Technique. - Supercharged Functions: Automatically augment functions enhance-powered capabilities. No Function body is needed.
- Minimal Overhead: Seamlessly integrate into existing Python codebases with minimal overhead.
Minimal Example
from enum import Enum
from dataclasses import dataclass
from semantix import Semantic, enhance
from semantix.llms import OpenAI
from semantix.types import Image
llm = OpenAI()
class Personality(Enum):
"""Personality of the Person"""
INTROVERT = "Introvert"
EXTROVERT = "Extrovert"
@dataclass
class Person:
full_name: str
yod: Semantic[int, "Year of Death"]
personality: Semantic[Personality, "Personality of the Person"]
@enhance("Get Person Informations use common knowledge", llm)
def get_person(name: Semantic[str, "Name of the Person"]) -> Person:
...
person_obj = get_person(name="Albert Einstein")
print(f"{person_obj.full_name} is an {person_obj.personality.value} who died in {person_obj.yod}")
# Albert Einstein is an Introvert who died in 1955
Supports Vision
from semantix.types import Image
@enhance("Get Person Informations use common knowledge", llm)
def get_person(img: Semantic[Image, "Image of the Person"]) -> Person:
...
person_obj = get_person(img=Image("mandela.jpg"))
print(f"{person_obj.full_name} is an {person_obj.personality.value} who died in {person_obj.yod}")
# Nelson Mandela is an Extrovert who died in 2013
Installation
All you need is:
pip install semantix
To install the very latest from main
:
pip install git+https://github.com/chandralegend/semantix.git
Or open our intro notebook in Google Colab:
By default, Semantix doesn't install any llm packages. You can install them separately:
pip install semantix[openai]
pip install semantix[anthropic]
pip install semantix[openai, anthropic] # Install both
If you want to use MultiModal capabilities, you can install the following:
pip install semantix[image]
pip install semantix[video]
Citation
If you find Semantix helpful, give it a ⭐️ on GitHub! and If you have used Semantix in your project, add the badge to your README.md file.
[![https://github/chandralegend/semantix](https://img.shields.io/badge/Powered%20by-Semantix-8A2BE2)](https://github/chandralegend/semantix)
If you used Semantix in your research, please cite it as follows:
@misc{semantix,
author = {Chandra Irugalbandara},
title = {Semantix: Infusing Meaning into Code with Large Language Models},
year = {2024},
publisher = {GitHub},
journal = {GitHub Repository},
howpublished = {\url{https://github/chandralegend/semantix}}
}
Contributing
Please read CONTRIBUTING.md for a quick guide on how to contribute to Semantix.
Project details
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
File details
Details for the file semantix-0.1.7.tar.gz
.
File metadata
- Download URL: semantix-0.1.7.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.8.18 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 493cf299518578d36a57c95a3f80dbab3b127f34b43ee0fe1dd9e3c7dde403cc |
|
MD5 | f98e0c91eda50fabc56c161d1317d8ba |
|
BLAKE2b-256 | f8a706cea91c571627417c8a70e090fe249554e5d873f13133177fca5d395d41 |
File details
Details for the file semantix-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: semantix-0.1.7-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.8.18 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d33e5e91d68e7d21f3a0b99be236c06c1db86a358bf36f743f11c554ff93b73 |
|
MD5 | 0a749f982ccc52a2ad1d9fbf657bd0a4 |
|
BLAKE2b-256 | 49b453777d5ab744c0a87fadb1cff77334b3e177d29aa43f942d9eb053321a26 |