From 2526785bdd2d4e53aa30eee4fe412930a7cd3cce Mon Sep 17 00:00:00 2001 From: Jan Wodnicki <25946310+janwodnicki@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:54:20 -0600 Subject: [PATCH] Fix / Incorrect cache path AzureChatOpenAI --- textgrad/engine/openai.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/textgrad/engine/openai.py b/textgrad/engine/openai.py index 723f04a..480f04c 100644 --- a/textgrad/engine/openai.py +++ b/textgrad/engine/openai.py @@ -12,7 +12,7 @@ stop_after_attempt, wait_random_exponential, ) -from typing import List, Union +from typing import List, Optional, Union from .base import EngineLM, CachedEngine from .engine_utils import get_image_type_from_bytes @@ -33,14 +33,16 @@ def __init__( system_prompt: str=DEFAULT_SYSTEM_PROMPT, is_multimodal: bool=False, base_url: str=None, + cache_path: Optional[str]=None, **kwargs): """ :param model_string: :param system_prompt: :param base_url: Used to support Ollama """ - root = platformdirs.user_cache_dir("textgrad") - cache_path = os.path.join(root, f"cache_openai_{model_string}.db") + if cache_path is None: + root = platformdirs.user_cache_dir("textgrad") + cache_path = os.path.join(root, f"cache_openai_{model_string}.db") super().__init__(cache_path=cache_path)