Skip to content

Mirascope/lilypad

Repository files navigation

Tests Coverage Docs Stars


Caution

Lilypad is now deprecated after the GA release of Mirascope v2 and Mirascope Cloud + Router.

The new mirascope.ops module supports a significantly improved OTEL compliant Python SDK for instrumentation, and Mirascope Cloud offers a backend solution for that OTEL data. If you're looking for such tooling, we recommend checking out what we've build over in Mirascope/mirascope. You can find the full documentation here: https://mirascope.com/docs

Lilypad will remain open-source and available for use, but we will no longer be spending cycles maintaining it as our core focus will be on all things Mirascope.

If you have any questions, reach out in our discord!

An open-source LLM engineering platform built on these principles:

  • Building with LLMs introduces non-determinisim to your code, which requires...
  • Tracking all input/output pairs and the exact version of the code that produced them so you can...
  • Continuously evaluate and optimize your code.

Important

Lilypad is still in beta

If you're interested in participating in the closed beta of Lilypad Pro+, join our community and DM William Bakst :)

We also welcome contributions with open arms! If you're interested in contributing, just do it! We're here to help.

Quickstart

To get started with Lilypad:

  1. Create an account at https://lilypad.mirascope.com. You can also run Lilypad locally if you'd prefer.
  2. Navigate to your organization settings
  3. Create a project, and then create an API key for that project. a. Save your LILYPAD_PROJECT_ID and LILYPAD_API_KEY (e.g. in a .env file).
  4. Install Lilypad: uv add "lilypad-sdk[openai]" # specify your provider of choice
  5. Run and trace your first versioned function:
import os

import lilypad
from openai import OpenAI  # use your provider of choice

lilypad.configure(
    project_id=os.environ["LILYPAD_PROJECT_ID"],
    api_key=os.environ["LILYPAD_API_KEY"],
    auto_llm=True,
)
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])


@lilypad.trace(versioning="automatic")  # Automatically version (non-deterministic) functions
def answer_question(question: str) -> str | None:
    completion = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": f"Answer this question: {question}"},
        ],
    )
    return completion.choices[0].message.content


answer = answer_question("What is the capital of France?")
print(answer)
# > The capital of France is Paris.

And that's it! Now you've versioned and traced your first non-deterministic function with Lilypad.

Usage

We are actively working on this library and it's documentation, which you can find here

Versioning

Lilypad uses Semantic Versioning

License

This project uses a dual-license model:

Open-Source License (MIT)

Except for the contents and code contained in any ee directory or sub-directory of this repository, which is covered by a commercial license (see below), all code in this repository is licensed under the terms of the MIT License.

Enterprise Edition (EE) License

The contents and code of any ee directory or sub-directory of this repository are licensed under the Enterprise Edition (EE) License. This content and code is only available to users using Lilypad Cloud or those with a valid Enterprise Edition (EE) License. See ee/LICENSE for the full terms.

Self-Hosting:

For those looking to self-host the Enterprise Edition (EE) of Lilypad, please reach out to sales@mirascope.com.

You can find more information about self-hosting here.