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.1.2.tar.gz (3.7 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.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagster_notdiamond-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0dbdcdc7e6757e6ebad6cafddb3a2671e4d4fd85386f838263cad607157c96e2
MD5 f2f1e672397e90ece8670e6f15a94b8b
BLAKE2b-256 a85ad486aa1522c9961a16ca714c5e9a0069416646df980bcc1b414964dc497b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagster_notdiamond-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37c6297248439272f3df131ad8d4cfa185613db412c3bf3b4c501ddf8fba1fa6
MD5 5c1f2ec80a05857d93f875f0b7ae6053
BLAKE2b-256 89310b2c84758cb96e8006e3eda0f3c3b141722363397e8d883d0d33698c06bd

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