mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(chatgpt): normalize chatgpt_auth_file before caching the authenticator
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
003352ff07
commit
1a788a96a5
2 changed files with 16 additions and 1 deletions
|
|
@ -54,7 +54,9 @@ def get_chatgpt_auth_file(
|
|||
if isinstance(litellm_params, Mapping)
|
||||
else litellm_params.chatgpt_auth_file
|
||||
)
|
||||
return value if isinstance(value, str) and value else None
|
||||
if not isinstance(value, str) or not value:
|
||||
return None
|
||||
return os.path.abspath(os.path.expanduser(value))
|
||||
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
|
|
|
|||
|
|
@ -147,6 +147,19 @@ class TestChatGPTMultiAccountAuthenticator:
|
|||
assert get_chatgpt_auth_file(GenericLiteLLMParams()) is None
|
||||
assert get_chatgpt_auth_file(GenericLiteLLMParams(chatgpt_auth_file="/b/auth.json")) == "/b/auth.json"
|
||||
|
||||
def test_relative_and_absolute_auth_file_share_cached_authenticator(self, tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
get_cached_authenticator.cache_clear()
|
||||
auth_file = tmp_path / "x" / "auth.json"
|
||||
auth_file.parent.mkdir(parents=True)
|
||||
auth_file.write_text("{}")
|
||||
|
||||
relative_key = get_chatgpt_auth_file({"chatgpt_auth_file": "x/auth.json"})
|
||||
absolute_key = get_chatgpt_auth_file({"chatgpt_auth_file": str(auth_file)})
|
||||
assert relative_key is not None and absolute_key is not None
|
||||
|
||||
assert get_cached_authenticator(relative_key) is get_cached_authenticator(absolute_key)
|
||||
|
||||
|
||||
class TestChatGPTAuthFileEarlyProviderDetection:
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue