Skip to content

Commit

Permalink
add logging to identify tokens used
Browse files Browse the repository at this point in the history
  • Loading branch information
gferioli0418 committed Sep 20, 2024
1 parent 4058e42 commit 3c07881
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Server/modules/open_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ def make_request(
):
for run in range(retries):
try:
response = self.client.chat.completions.create(
model=self.model,
messages=messages,
max_tokens=self.max_tokens,
stream=self.stream,
response_model=response_model,
response, completion = (
self.client.chat.completions.create_with_completion(
model=self.model,
messages=messages,
max_tokens=self.max_tokens,
stream=self.stream,
response_model=response_model,
)
)

print("Tokens used:", completion.usage)
return response
except Exception as e:
error = str(e)
Expand Down

0 comments on commit 3c07881

Please sign in to comment.