Releases: amoffat/manifest
Releases · amoffat/manifest
Recursive types
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
OpenAI now supports jsonschema, which simplifies how we were guiding jsonschema-conformant output. This release uses that feature, which makes outputs more reliable.
Retrying
Better errors
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 🎉
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))