Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

price #42

Merged
merged 8 commits into from
Mar 28, 2024
Merged

price #42

merged 8 commits into from
Mar 28, 2024

Conversation

Mac0q
Copy link
Contributor

@Mac0q Mac0q commented Mar 26, 2024

No description provided.

@vyokky vyokky linked an issue Mar 26, 2024 that may be closed by this pull request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should in dev config, or in a new config file.

@@ -3,6 +3,9 @@
import openai
from openai import AzureOpenAI, OpenAI

from ..utils import get_cost_estimator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be in the same module of llm

self.cost += total_cost

if isinstance(total_cost, float) and isinstance(self.cost, float):
self.cost += total_cost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a add cost func in the llm module

@@ -61,7 +64,7 @@ def chat_completion(
prompt_tokens = usage.prompt_tokens
completion_tokens = usage.completion_tokens

cost = prompt_tokens / 1000 * 0.01 + completion_tokens / 1000 * 0.03
cost = get_cost_estimator(self.config, prompt_tokens, completion_tokens)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a classmethod, or static method. argument shoud be the price dict and api type, not the whole config

@@ -260,8 +262,11 @@ def process_action_selection(self):
self.status = "ERROR"
time.sleep(configs["SLEEP_TIME"])
return

self.cost += cost

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a add cost func in the llm module


self.cost += cost
if isinstance(cost, float) and isinstance(self.cost, float):
self.cost += cost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a add cost func in the llm module

ufo/ufo.py Outdated
@@ -83,8 +83,9 @@ def main():

# Print the total cost
total_cost = session.get_cost()
formatted_cost = '${:.2f}'.format(total_cost)
print_with_color(f"Request total cost is {formatted_cost}", "yellow")
if total_cost:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total_cost = 0 could be an exception

else:
print(f"Model {model} not found in Azure prices")
return None
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring comment, break args

Returns:
float: The estimated cost for using the model.
"""
if model in prices:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a @staticmethod or @classmethod

@vyokky vyokky merged commit 24097d5 into microsoft:pre-release Mar 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cost should be different for different models
2 participants