Skip to content

Commit

Permalink
rounding big floating point values
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurbrenno committed Jan 27, 2025
1 parent 75f654b commit 1c6363b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/intellibricks/llms/integrations/cerebras/cerebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ async def chat_async(
)

completion = ChatCompletion(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
id=cerebras_completion.id,
object="chat.completion",
created=cerebras_completion.created,
Expand Down Expand Up @@ -412,7 +412,7 @@ async def chat_async(
# )

# completion = ChatCompletion(
# elapsed_time=timeit.default_timer() - now,
# elapsed_time=round(timeit.default_timer() - now, 2),
# id=cerebras_completion.id,
# object="chat.completion",
# created=cerebras_completion.created,
Expand Down
2 changes: 1 addition & 1 deletion src/intellibricks/llms/integrations/deepinfra/deepinfra.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ async def chat_async(
total_cost = input_cost + output_cost

chat_completion = ChatCompletion(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
id=openai_completion.id,
object=openai_completion.object,
created=openai_completion.created,
Expand Down
2 changes: 1 addition & 1 deletion src/intellibricks/llms/integrations/google/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ async def chat_async(
)

completion = ChatCompletion(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
choices=choices,
usage=usage,
model=cast(
Expand Down
6 changes: 3 additions & 3 deletions src/intellibricks/llms/integrations/groq/groq.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ async def chat_async(
# Calculate total cost
total_cost = input_cost + output_cost
chat_completion = ChatCompletion(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
id=groq_completion.id,
object=groq_completion.object,
created=groq_completion.created,
Expand Down Expand Up @@ -343,7 +343,7 @@ async def transcribe_async(
len(chunk) / 1000
) # Convert milliseconds to seconds
chunk_transcription = AudioTranscription(
elapsed_time=chunk_elapsed_time,
elapsed_time=round(chunk_elapsed_time, 2),
text=transcription.text,
segments=segments,
cost=0.0,
Expand Down Expand Up @@ -382,7 +382,7 @@ async def transcribe_async(
)

return AudioTranscription(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
text=transcription.text,
segments=segments,
cost=0.0,
Expand Down
6 changes: 3 additions & 3 deletions src/intellibricks/llms/integrations/openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ async def chat_async(
completion_tokens_details = usage.completion_tokens_details if usage else None

chat_completion = ChatCompletion(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
id=openai_completion.id,
object=openai_completion.object,
created=openai_completion.created,
Expand Down Expand Up @@ -393,7 +393,7 @@ async def transcribe_async(
len(chunk) / 1000
) # Convert milliseconds to seconds
chunk_transcription = AudioTranscription(
elapsed_time=chunk_elapsed_time,
elapsed_time=round(chunk_elapsed_time, 2),
text=transcription.text,
segments=segments,
cost=0.0,
Expand Down Expand Up @@ -431,7 +431,7 @@ async def transcribe_async(
)

return AudioTranscription(
elapsed_time=timeit.default_timer() - now,
elapsed_time=round(timeit.default_timer() - now, 2),
text=transcription.text,
segments=segments,
cost=0.0,
Expand Down
4 changes: 2 additions & 2 deletions src/intellibricks/llms/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3043,7 +3043,7 @@ def get_parsed(self, choice: int = 0) -> T:

def __add__(self, other: ChatCompletion[T]) -> ChatCompletion[T]:
return ChatCompletion(
elapsed_time=self.elapsed_time + other.elapsed_time,
elapsed_time=round(self.elapsed_time + other.elapsed_time, 2),
id=uuid.uuid4().__str__(),
model=self.model,
system_fingerprint=self.system_fingerprint,
Expand Down Expand Up @@ -3780,7 +3780,7 @@ def merge(self, *audio_transcriptions: AudioTranscription) -> AudioTranscription
merged_segments.append(new_segment)

return AudioTranscription(
elapsed_time=merged_elapsed_time,
elapsed_time=round(merged_elapsed_time, 2),
text=merged_text,
segments=merged_segments,
cost=merged_cost,
Expand Down

0 comments on commit 1c6363b

Please sign in to comment.