Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions litellm/router_strategy/lowest_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def log_success_event( # noqa: PLR0915
else:
request_count_dict[id]["latency"] = request_count_dict[id][
"latency"
][: self.routing_args.max_latency_list_size - 1] + [final_value]
][1:] + [final_value]

## Time to first token
if time_to_first_token is not None:
Expand All @@ -155,13 +155,10 @@ def log_success_event( # noqa: PLR0915
"time_to_first_token", []
).append(time_to_first_token)
else:
request_count_dict[id][
"time_to_first_token"
] = request_count_dict[id]["time_to_first_token"][
: self.routing_args.max_latency_list_size - 1
] + [
time_to_first_token
]
request_count_dict[id]["time_to_first_token"] = (
request_count_dict[id]["time_to_first_token"][1:]
+ [time_to_first_token]
)

if precise_minute not in request_count_dict[id]:
request_count_dict[id][precise_minute] = {}
Expand Down Expand Up @@ -244,7 +241,7 @@ async def async_log_failure_event(self, kwargs, response_obj, start_time, end_ti
else:
request_count_dict[id]["latency"] = request_count_dict[id][
"latency"
][: self.routing_args.max_latency_list_size - 1] + [1000.0]
][1:] + [1000.0]

await self.router_cache.async_set_cache(
key=latency_key,
Expand Down Expand Up @@ -371,7 +368,7 @@ async def async_log_success_event( # noqa: PLR0915
else:
request_count_dict[id]["latency"] = request_count_dict[id][
"latency"
][: self.routing_args.max_latency_list_size - 1] + [final_value]
][1:] + [final_value]

## Time to first token
if time_to_first_token is not None:
Expand All @@ -383,13 +380,10 @@ async def async_log_success_event( # noqa: PLR0915
"time_to_first_token", []
).append(time_to_first_token)
else:
request_count_dict[id][
"time_to_first_token"
] = request_count_dict[id]["time_to_first_token"][
: self.routing_args.max_latency_list_size - 1
] + [
time_to_first_token
]
request_count_dict[id]["time_to_first_token"] = (
request_count_dict[id]["time_to_first_token"][1:]
+ [time_to_first_token]
)

if precise_minute not in request_count_dict[id]:
request_count_dict[id][precise_minute] = {}
Expand Down
Loading
Loading