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.2.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.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: distilabel_cost_calculator-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a8502fdbfa531dc9a43214aaa8a6361cc9bdd70a4dba1977c0176e064c4f4001
MD5 400716f58f9445cca50373385026b4b1
BLAKE2b-256 f3cfd3d3287bb492ea17baaacd94c152749ede3b02564f4bfae3670139838423

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for distilabel_cost_calculator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df1d96d5fdc3df49a6d177f15d2a962392afd8efe3dcf68f64fc03d2616c3c0c
MD5 c41e410ee6dd0cdc958a8e1f96bac83f
BLAKE2b-256 d2ab5d0c98809d53d62ef14727e230db6ce803308db37b193e80c0c51506a7d0

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