Skip to main content

A custom Step for LLM API cost calculation for the distilabel library.

Project description

Description

A custom Step for LLM API cost calculation for the distilabel library.

Installation

pip install distilabel-cost-calculator

Example

from distilabel_cost_calculator import GenerationCostCalculator

with Pipeline("data_generation_with_cost_calculator") as pipeline:
        model = OpenAILLM(model="gpt-4o-mini", api_key=OPENAI_API_KEY)

        data = LoadDataFromDicts(data=[{"instruction": "Generate me a quote."}])
        task = TextGeneration(name="text-generation", llm=model, num_generations=2)
        cost_step = GenerationCostCalculator(api_model_name="gpt-4o-mini")
        data >> task >> cost_step
    pipeline.run(use_cache=False)

    """
    API cost details will be found in the 'api_cost' column in the Distiset.
    'api_cost': {'inputs': 7.5e-07, 'outputs': 1.0199999999999999e-05, 'total_cost_str': '0.000011$'}
    """

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

distilabel_cost_calculator-0.1.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

distilabel_cost_calculator-0.1.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file distilabel_cost_calculator-0.1.1.tar.gz.

File metadata

  • Download URL: distilabel_cost_calculator-0.1.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/23.6.0

File hashes

Hashes for distilabel_cost_calculator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b70e5988523d930093a97b1ad9fe302ac48bf3937236b5c16ed1fd3061ea5fb
MD5 dcbd7cd84b38d5bb7bf761d4bb3f8f0d
BLAKE2b-256 6ec6dc75a1f18c18c32c24d61613982db71aed9169857f3a87294a4892f45e98

See more details on using hashes here.

File details

Details for the file distilabel_cost_calculator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for distilabel_cost_calculator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27ff99017ca1b5ba3d47301d6acc198cc98587bb90209d0619760fd9dea21554
MD5 337fc7e2b3a2179411faf4214b0c3081
BLAKE2b-256 f3c4857d539493ab340a9782db687358a79038d2168a86c64ebadf34a195429e

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