Skip to content

Commit 97d60a8

Browse files
committed
Add LRU cache to get_model_map
1 parent 79b9810 commit 97d60a8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

backend/onyx/llm/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from collections.abc import Callable
55
from collections.abc import Iterator
6+
from functools import lru_cache
67
from typing import Any
78
from typing import cast
89
from typing import TYPE_CHECKING
@@ -384,6 +385,7 @@ def test_llm(llm: LLM) -> str | None:
384385
return error_msg
385386

386387

388+
@lru_cache(maxsize=1) # the copy.deepcopy is expensive, so we cache the result
387389
def get_model_map() -> dict:
388390
starting_map = copy.deepcopy(cast(dict, litellm.model_cost))
389391

0 commit comments

Comments
 (0)