Skip to main content
Semantix: Infusing Meaning into Code with Large Language Models

PyPI version Open in Colab License

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://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.

Metadata

Release files for semantix 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semantix 0.1.7
File Size Uploaded Provenance
semantix-0.1.7.tar.gz 21.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for semantix 0.1.7
File Interpreter ABI Platform
semantix-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 50.3 kB

Release files / semantix-0.1.7.tar.gz

Download URL semantix-0.1.7.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
493cf299518578d36a57c95a3f80dbab3b127f34b43ee0fe1dd9e3c7dde403cc
BLAKE2b-256 checksum
How to use checksums
f8a706cea91c571627417c8a70e090fe249554e5d873f13133177fca5d395d41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.8.18 Linux/6.5.0-1025-azure

Release files / semantix-0.1.7-py3-none-any.whl

Download URL semantix-0.1.7-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d33e5e91d68e7d21f3a0b99be236c06c1db86a358bf36f743f11c554ff93b73
BLAKE2b-256 checksum
How to use checksums
49b453777d5ab744c0a87fadb1cff77334b3e177d29aa43f942d9eb053321a26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.8.18 Linux/6.5.0-1025-azure

Security for semantix 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page