Skip to content

Commit

Permalink
reset token count
Browse files Browse the repository at this point in the history
  • Loading branch information
saum7800 committed Apr 15, 2024
1 parent 0951e37 commit 40255a1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions prompt2model/utils/api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ def generate_one_completion(
An OpenAI-like response object if there were no errors in generation.
In case of API-specific error, Exception object is captured and returned.
"""
# num_prompt_tokens = count_tokens_from_string(prompt)
# if self.max_tokens:
# max_tokens = self.max_tokens - num_prompt_tokens - token_buffer
# else:
# max_tokens = 3 * num_prompt_tokens
max_tokens = self.max_tokens
num_prompt_tokens = count_tokens_from_string(prompt)
if self.max_tokens:
max_tokens = self.max_tokens - num_prompt_tokens - token_buffer
else:
max_tokens = 3 * num_prompt_tokens

response = completion( # completion gets the key from os.getenv
model=self.model_name,
Expand Down

0 comments on commit 40255a1

Please sign in to comment.