-
Notifications
You must be signed in to change notification settings - Fork 838
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
price #42
Conversation
ufo/config/config.yaml.template
Outdated
There was a problem hiding this comment.
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.
ufo/llm/openai.py
Outdated
@@ -3,6 +3,9 @@ | |||
import openai | |||
from openai import AzureOpenAI, OpenAI | |||
|
|||
from ..utils import get_cost_estimator |
There was a problem hiding this comment.
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
ufo/module/flow.py
Outdated
self.cost += total_cost | ||
|
||
if isinstance(total_cost, float) and isinstance(self.cost, float): | ||
self.cost += total_cost |
There was a problem hiding this comment.
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/llm/openai.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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 | |||
|
There was a problem hiding this comment.
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/module/flow.py
Outdated
|
||
self.cost += cost | ||
if isinstance(cost, float) and isinstance(self.cost, float): | ||
self.cost += cost |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
ufo/utils/__init__.py
Outdated
else: | ||
print(f"Model {model} not found in Azure prices") | ||
return None | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring comment, break args
ufo/llm/openai.py
Outdated
Returns: | ||
float: The estimated cost for using the model. | ||
""" | ||
if model in prices: |
There was a problem hiding this comment.
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
No description provided.