Skip to main content

Dagster integration with Not Diamond

Project description

Dagster resource for Not Diamond ¬◇

Not Diamond is an AI model router that automatically determines which LLM is best-suited to respond to any query, improving LLM output quality by combining multiple LLMs into a meta-model that learns when to call each LLM.

Installation

pip install dagster-notdiamond

Configuration

Make sure you have followed the steps in the Quickstart docs, and added a Not Diamond API key to your environment.

Usage

Define a resource for Not Diamond, then create the asset:

from dagster import (
    Definitions,
    EnvVar,
    ScheduleDefinition,
    AssetSelection,
    AssetExecutionContext,
    MaterializeResult,
    asset,
)
from dagster_notdiamond import NotDiamondResource


@asset
def notdiamond_asset(context: AssetExecutionContext, notdiamond: NotDiamondResource) -> MaterializeResult:
    with notdiamond.get_client(context) as client:
        session_id, best_llm = client.model_select(
            model=["openai/gpt-4o", "openai/gpt-4o-mini"],
            messages=[{"role": "user", "content": "Say this is a test"}]
        )
    return MaterializeResult(metadata={"session_id": session_id, "best_llm": str(best_llm)})

notdiamond_schedule = ScheduleDefinition(
    name="notdiamond_schedule",
    target=AssetSelection.all(),
    cron_schedule="17 * * * *",
)

defs = Definitions(
    assets=[notdiamond_asset],
    resources={
        "notdiamond": NotDiamondResource(api_key=EnvVar("NOTDIAMOND_API_KEY")),
    },
    schedules=[notdiamond_schedule],
)

Please refer to examples/example_notdiamond.py for an example script which you can test by updating your pyproject.toml as follows (replacing $PROJECT_HOME with the path to this project):

[tool.dagster]
module_name = "examples.example_notdiamond"
working_directory = "$PROJECT_HOME/libraries/dagster-notdiamond/"

Support

Visit the documentation for Not Diamond or send a message to support@notdiamond.ai

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dagster_notdiamond-0.0.4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dagster_notdiamond-0.0.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file dagster_notdiamond-0.0.4.tar.gz.

File metadata

  • Download URL: dagster_notdiamond-0.0.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for dagster_notdiamond-0.0.4.tar.gz
Algorithm Hash digest
SHA256 63ed5c1e4e52638eb659e23290730140281a072b8d96f47b97bb4353556e1de7
MD5 968c529657f96caeccfd49ef69870581
BLAKE2b-256 8d2d4d165aa4474f9d8a7afdd15e6f0f98bfcfa4be69aa30cd9e73ae2afe0b77

See more details on using hashes here.

File details

Details for the file dagster_notdiamond-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dagster_notdiamond-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c997c31c60a50f7710c20ecaeb96cd7c807ff56ddf37d182b7216ac5cac6ecfa
MD5 cc19cf00bd8a30e3f021659876234c79
BLAKE2b-256 d1bc1cb1c560990229ab091e689bfa82e85b58b8a9ee17b1476f71f46084a3b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page