A lightweight AI engineering toolkit for building natural language interfaces that are reliable, scalable, and easy to trust.
Project description
Scalify AI - The AI engineering toolkit
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()
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
File details
Details for the file scalify-1.0.0.tar.gz
.
File metadata
- Download URL: scalify-1.0.0.tar.gz
- Upload date:
- Size: 27.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6636ce3a03b7f4eedd3bea02550598cbfcf6adbda4889d973b43044a8a939621 |
|
MD5 | e2f01b39b1ad6bc1e0995b6e6865aa30 |
|
BLAKE2b-256 | a71c021bba1e9e1b9fb2467c11d8afec91d03fb28111442669556d4bd1d7f206 |
File details
Details for the file scalify-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: scalify-1.0.0-py3-none-any.whl
- Upload date:
- Size: 97.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee5ebeed0fbc70ba390cd5cb479fa4c2df84b4f1e804ba4215f42293c7424201 |
|
MD5 | 2b9ea3aed453b961d15c21c9d4de8180 |
|
BLAKE2b-256 | 94bd909ba619d850959b16858016dc649632f4507f276c3b5f56d8d0bd01359d |