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.3.tar.gz (3.8 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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagster_notdiamond-0.1.3.tar.gz
Algorithm Hash digest
SHA256 91a9bf0e04c146c924d8021fe5665a1fca5b0e6fdbfa41813e92e2fcd7be1727
MD5 9f21149fa564a2ec90cf9aa9d1a9bae3
BLAKE2b-256 bb2ba16c401739eda3ccd01ed91ec0831a6362bd36ae5ffc5a8424f585ba52e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagster_notdiamond-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 257460d2c70f2e54c466db6ad9625740655aa969bc37fb28c79eae4bb474b598
MD5 6c40dfa6327fcf8f7eb95547e66e3543
BLAKE2b-256 affee0130098af7dfba41d6e266d84a162fb06c9f1b2490831bb0d2544500591

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