CostManager

class essence_extractor.src.CostManager(model_name)

This class is used to calculate the cost of a text.

model_name

The name of the model to use.

Type:

str

calculate_cost_text(text, is_input=True)

Calculate the cost of a text.

Parameters:
  • text (str) – The text to calculate the cost of.

  • is_input (bool, optional) – Whether the text is an input or an output. Defaults to True.

Returns:

The cost of the text.

Return type:

float

calculate_cost_token(token_count, is_input=True)

Calculate the cost of a text.

Parameters:
  • token_count (int) – The number of tokens in the text.

  • is_input (bool, optional) – Whether text is input or output. Defaults to True.

Returns:

The cost of the text.

Return type:

float

get_total_cost()

Get the total cost of the text.

Returns:

The total cost of the text.

Return type:

float