Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
yangbobo2021 committed Dec 14, 2023
1 parent 584a461 commit 1bcc0d0
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions ask-code/ask-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,30 @@ def query(question, lsp_brige_port):
# Print the answer
prices = {
"gpt-4": (0.03, 0.06),
"gpt-4-32k": (0.06, 0.12),
"gpt-3.5-turbo": (0.0015, 0.002),
"gpt-3.5-turbo-16k": (0.003, 0.004),
"claude-2": (0.01102, 0.03268),
"starchat-alpha": (0.0004, 0.0004),
"CodeLlama-34b-Instruct": (0.0008, 0.0008),
"llama-2-70b-chat": (0.001, 0.001),
"gpt-3.5-turbo-1106": (0.001, 0.002),
"gpt-4-1106-preview": (0.01, 0.03),
"gpt-4-1106-vision-preview": (0.01, 0.03),
'others': (0.001, 0.002)
"gpt-4-32k": (0.06, 0.12),
"gpt-3.5-turbo": (0.0015, 0.002),
"gpt-3.5-turbo-16k": (0.003, 0.004),
"claude-2": (0.01102, 0.03268),
"starchat-alpha": (0.0004, 0.0004),
"CodeLlama-34b-Instruct": (0.0008, 0.0008),
"llama-2-70b-chat": (0.001, 0.001),
"gpt-3.5-turbo-1106": (0.001, 0.002),
"gpt-4-1106-preview": (0.01, 0.03),
"gpt-4-1106-vision-preview": (0.01, 0.03),
"others": (0.001, 0.002),
}
print(answer[0])
spent_money = 0.0
token_usages = answer[2].get("usages", [])
if len(token_usages) > 0:
for token_usage in token_usages:
price = prices.get(token_usage.model, prices['others'])
spent_money += (price[0] * token_usage.prompt_tokens)/1000 + (price[1] * token_usage.completion_tokens)/1000
price = prices.get(token_usage.model, prices["others"])
spent_money += (price[0] * token_usage.prompt_tokens) / 1000 + (
price[1] * token_usage.completion_tokens
) / 1000
print(f"***/ask-code has costed approximately ${spent_money/0.7} USD for this question.***")


def main():
try:
if len(sys.argv) < 3:
Expand Down

0 comments on commit 1bcc0d0

Please sign in to comment.