Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix / Incorrect cache path AzureChatOpenAI #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions textgrad/engine/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down