Skip to main content

Scalify AI - The AI engineering toolkit

PyPI version Twitter Follow

Scalify is a lightweight AI toolkit for building natural language interfaces that are reliable, scalable, and easy to trust.

Each of Scalify's tools is simple and self-documenting, using AI to solve common but complex challenges like entity extraction, classification, and generating synthetic data. Each tool is independent and incrementally adoptable, so you can use them on their own or in combination with any other library. Scalify is also multi-modal, supporting both image and audio generation as well using images as inputs for extraction and classification.

Scalify is for developers who care more about using AI than building AI, and we are focused on creating an exceptional developer experience. Scalify users should feel empowered to bring tightly-scoped "AI magic" into any traditional software project with just a few extra lines of code.

Scalify aims to merge the best practices for building dependable, observable software with the best practices for building with generative AI into a single, easy-to-use library. It's a serious tool, but we hope you have fun with it.

Scalify is open-source, free to use, and made with ❤️ by the team at KhulnaSoft, Ltd.

Installation

Install the latest version with pip:

pip install scalify -U

To verify your installation, run scalify version in your terminal.

Tools

Scalify consists of a variety of useful tools, all designed to be used independently. Each one represents a common LLM use case, and packages that power into a simple, self-documenting interface.

Quickstart

Here's a whirlwind tour of a few of Scalify's main features. For more information, check the docs!

🏷️ Classify text

Scalify can classify text using a set of labels:

import scalify

scalify.classify(
    "Scalify is so easy to use!",
    labels=["positive", "negative"],
)

#  "positive"

Learn more about classification here.

🔍 Extract structured entities

Scalify can extract structured entities from text:

import pydantic


class Location(pydantic.BaseModel):
    city: str
    state: str


scalify.extract("I moved from NY to CHI", target=Location)

# [
#     Location(city="Dhaka", state="Dhaka"),
#     Location(city="Khulna", state="Khulna")
# ]

Almost all Scalify functions can be given instructions for more control. Here we extract only monetary values:

scalify.extract(
    "I paid $10 for 3 tacos and got a dollar and 25 cents back.",
    target=float,
    instructions="Only extract money"
)

#  [10.0, 1.25]

Learn more about entity extraction here.

✨ Generate data

Scalify can generate synthetic data for you, following instructions and an optional schema:

class Location(pydantic.BaseModel):
    city: str
    state: str


scalify.generate(
    n=4,
    target=Location,
    instructions="cities in the United States named after presidents"
)

# [
#     Location(city='Washington', state='District of Columbia'),
#     Location(city='Jackson', state='Mississippi'),
#     Location(city='Cleveland', state='Ohio'),
#     Location(city='Lincoln', state='Nebraska'),
# ]

Learn more about data generation here.

🪄 Standardize text by casting to types

Scalify can cast arbitrary text to any Python type:

scalify.cast("one two three", list[int])

#  [1, 2, 3]

This is useful for standardizing text inputs or matching natural language to a schema:

class Location(pydantic.BaseModel):
    city: str
    state: str


scalify.cast("The Big Apple", Location)

# Location(city="New York", state="New York")

For a class-based approach, Scalify's @model decorator can be applied to any Pydantic model to let it be instantiated from text:

@scalify.model
class Location(pydantic.BaseModel):
    city: str
    state: str


Location("The Big Apple")

# Location(city="New York", state="New York")

Learn more about casting to types here.

🦾 Build AI-powered functions

Scalify functions let you combine any inputs, instructions, and output types to create custom AI-powered behaviors... without source code. These functions can can go well beyond the capabilities of extract or classify, and are ideal for complex natural language processing or mapping combinations of inputs to outputs.

@scalify.fn
def sentiment(text: str) -> float:
    """
    Returns a sentiment score for `text`
    between -1 (negative) and 1 (positive).
    """

sentiment("I love working with Scalify!") # 0.8
sentiment("These examples could use some work...") # -0.2

Scalify functions look exactly like regular Python functions, except that you don't have to write any source code. When these functions are called, an AI interprets their description and inputs and generates the output.

Note that Scalify does NOT work by generating or executing source code, which would be unsafe for most use cases. Instead, it uses the LLM itself as a "runtime" to predict function outputs. That's actually the source of its power: Scalify functions can handle complex use cases that would be difficult or impossible to express as code.

You can learn more about functions here.

🖼️ Generate images from text

Scalify can paint images from text:

scalify.paint("a simple cup of coffee, still warm")

Learn more about image generation here.

🔍 Converting images to data

In addition to text, Scalify has support for captioning, classifying, transforming, and extracting entities from images using the GPT-4 vision model:

scalify.classify(
    scalify.Image.from_path("docs/images/coffee.png"),
    labels=["drink", "food"],
)

# "drink"

Record the user, modify the content, and play it back

Scalify can transcribe speech and generate audio out-of-the-box, but the optional audio extra provides utilities for recording and playing audio.

import scalify
import scalify.audio

# record the user
user_audio = scalify.audio.record_phrase()

# transcribe the text
user_text = scalify.transcribe(user_audio)

# cast the language to a more formal style
ai_text = scalify.cast(user_text, instructions='Make the language ridiculously formal')

# generate AI speech
ai_audio = scalify.speak(ai_text)

# play the result
ai_audio.play()

Metadata

Release files for scalify 1.0.0

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

Source distribution (sdist)

Source distribution for scalify 1.0.0
File Size Uploaded Provenance
scalify-1.0.0.tar.gz 27.6 MB Without provenance Details

Built distribution (wheel)

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

Total release size: 27.7 MB

Release files / scalify-1.0.0.tar.gz

Download URL scalify-1.0.0.tar.gz
Size 27.6 MB
Tags Source
SHA-256 checksum
How to use checksums
6636ce3a03b7f4eedd3bea02550598cbfcf6adbda4889d973b43044a8a939621
BLAKE2b-256 checksum
How to use checksums
a71c021bba1e9e1b9fb2467c11d8afec91d03fb28111442669556d4bd1d7f206
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / scalify-1.0.0-py3-none-any.whl

Download URL scalify-1.0.0-py3-none-any.whl
Size 97.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee5ebeed0fbc70ba390cd5cb479fa4c2df84b4f1e804ba4215f42293c7424201
BLAKE2b-256 checksum
How to use checksums
94bd909ba619d850959b16858016dc649632f4507f276c3b5f56d8d0bd01359d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Security for scalify 1.0.0

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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