zyx

A fun "anti-framework" for doing useful things with agents and LLMs.
What is ZYX?
ZYX is a simplicity-first library wrapped on top of Pydantic AI and heavily inspired by Marvin. It aims to provide a simple, stdlib-like interface for working with language models, without loss of control as well as flexibility that more complex frameworks provide.
Introduction
ZYX stands on the shoulders of Pydantic AI to provide a set of functions and components that aim to complete the following goals:
- Simplicity-First: Above all else,
ZYXaims to be as simple as possible to use. The library is designed in a very semantically literal sense, with the hope that a 12 year old could pick up and run with it immediately. - Fast & Flexible:
ZYXis designed to be as fast as possible in two senses, (1) performance wise, and (2) development time wise, providing a very flexible interface that allows rapid prototyping and iteration. - Type-Focused:
ZYXprovides a very type-focused interface, leveraging Pydantic's powerful validation capabilities to ensure that your data is always in the expected format. - Model Agnostic: Through Pydantic AI,
ZYXis completely model agnostic and supports virtually any LLM provider.
Getting Started
The following guide is a quick way to get started on how to
install ZYX and get up and running with a few of the core concepts.
Installation
You can install ZYX using your favorite Python package manager.
Adding Model Providers
The core package for ZYX installs the minimum required dependencies from Pydantic AI using their pydantic-ai-slim package, along with the openai library for out of the box OpenAI support.
To add support for additional LLM providers, you can use one of the following methods to install the relevant dependencies:
To install all of pydantic-ai's supported providers, simply install the full package along with ZYX:
Or use the ai extra:
Quickstart
Once you've installed ZYX, try running some of the following code examples to get a feel for the library!
Generating Content
The easiest way to use LLMs within ZYX is through the zyx.make semantic operation. Semantic operations are specialized functions that allow you to use LLMs to generate/edit content, parse data, and more!
import zyx
result = zyx.make(
target=int, # (1)!
context="What is 45+45?",
)
print(result.output)
"""
90
"""
Targetsare how to define the output of a semantic operation. In this case, we want to generate an integer.
Parsing a Website
Through the source, context and attachments parameters, ZYX provides a bunch of options on how you want to pass content to a model.
import zyx
from pydantic import BaseModel
class Information(BaseModel): # (1)!
library_name : str
library_description : str
def log_website_url(url : str) -> None:
print(f"Website URL: {url}")
result = zyx.parse( # (2)!
source=zyx.paste("https://zyx.hammad.app"), # (3)!
target=Information,
instructions="log the website URL before you parse.", # (4)!
model="openai:gpt-4o-mini", # (5)!
tools=[log_website_url] # (6)!
)
print(result.output.library_name)
print(result.output.library_description)
"""
Website URL: https://zyx.hammad.app
ZYX
A fun "anti-framework" for doing useful things with agents and LLMs.
"""
-
First-class support for structured outputs in nearly every semantic operation within
ZYX. -
zyx.parseis a semantic operation that allows you to parse asourceobject or content into atarget. -
zyx.pasteis a convenience function for creating aSnippetfrom a source object.
ASnippetis a piece of content that can be used to represent multimodal or textual content easily. -
The
contextparameter is how prompts and messages are provided to the model.ZYXprovides many options on how context can be provided! -
All models and providers supported by Pydantic AI are supported within
ZYX. -
Thanks to Pydantic AI, all semantic operations inherently support tool usage.