Skip to content

Releases: amoffat/manifest

Recursive types

11 Sep 03:29
6c1a4e2
Compare
Choose a tag to compare

0.6.0 Adds support for recursive types, meaning types can refer to themselves, or other types, in a recursive nature, and it all just works:

from dataclasses import dataclass
from rich.pretty import pprint
from manifest import ai

@dataclass
class Character:
    name: str
    occupation: str
    social_graph: "SocialGraph"

@dataclass
class SocialGraph:
    friends: list[Character]
    enemies: list[Character]

@ai
def get_character_social_graph(character_name: str) -> SocialGraph:
    """For a given fictional character, return their social graph, resolving
    each friend and enemy's social graph recursively."""

graph = get_character_social_graph("Walter White")
pprint(graph)
SocialGraph(
    friends=[
        Character(
            name='Jesse Pinkman',
            occupation='Meth Manufacturer',
            social_graph=SocialGraph(
                friends=[Character(name='Walter White', occupation='Chemistry Teacher', social_graph=SocialGraph(friends=[], enemies=[]))],
                enemies=[Character(name='Hank Schrader', occupation='DEA Agent', social_graph=SocialGraph(friends=[], enemies=[]))]
            )
        ),
        Character(
            name='Saul Goodman',
            occupation='Lawyer',
            social_graph=SocialGraph(friends=[Character(name='Walter White', occupation='Chemistry Teacher', social_graph=SocialGraph(friends=[], enemies=[]))], enemies=[])
        )
    ],
    enemies=[
        Character(
            name='Hank Schrader',
            occupation='DEA Agent',
            social_graph=SocialGraph(
                friends=[Character(name='Marie Schrader', occupation='Radiologic Technologist', social_graph=SocialGraph(friends=[], enemies=[]))],
                enemies=[Character(name='Walter White', occupation='Meth Manufacturer', social_graph=SocialGraph(friends=[], enemies=[]))]
            )
        ),
        Character(
            name='Gus Fring',
            occupation='Businessman',
            social_graph=SocialGraph(
                friends=[Character(name='Mike Ehrmantraut', occupation='Fixer', social_graph=SocialGraph(friends=[], enemies=[]))],
                enemies=[Character(name='Walter White', occupation='Meth Manufacturer', social_graph=SocialGraph(friends=[], enemies=[]))]
            )
        )
    ]
)

OpenAI jsonschema support

08 Aug 08:09
Compare
Choose a tag to compare

OpenAI now supports jsonschema, which simplifies how we were guiding jsonschema-conformant output. This release uses that feature, which makes outputs more reliable.

Retrying

05 Aug 14:35
Compare
Choose a tag to compare

We introduce a retry argument on the @ai decorator to make LLM execution a little more robust. We also fix a few type checking errors.

Better errors

04 Aug 07:32
Compare
Choose a tag to compare

Now you'll receive much better errors if manifest runs without required environment variables. For example:

manifest.py error:

No LLM api keys found, try defining one of the following environment variables
in a .env file or in your environment, then re-running the program:

  - OPENAI_API_KEY

For advanced users, you may manually initialize the LLM client in your code by
calling `manifest.init(client_maker)`, where `client_maker` is a function that
returns an LLM client.

Exiting.

Initial release 🎉

03 Aug 08:06
Compare
Choose a tag to compare

Function execution

Handles the execution of an arbitrary function on an LLM

from manifest import ai

@ai
def translate(english_text: str, target_lang: str) -> str:
    """ Translates text from english into a target language """

assert translate("Hello", "fr") == "Bonjour"

Multimodal images

Allows seamless image uploads

from pathlib import Path
from manifest import ai

@ai
def breed_of_dog(image: Path) -> str:
    """Determines the breed of dog from a photo"""

image = Path("path/to/dog.jpg")
print(breed_of_dog(image))