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

feat: add CacheDir option to GlobalOptions #50

Merged
merged 2 commits into from
Sep 3, 2024
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
8 changes: 6 additions & 2 deletions gptscript/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ def __init__(
baseURL: str = "",
defaultModelProvider: str = "",
defaultModel: str = "",
cacheDir: str = "",
env: Mapping[str, str] = None,
):
self.APIKey = apiKey
self.BaseURL = baseURL
self.DefaultModel = defaultModel
self.DefaultModelProvider = defaultModelProvider
self.CacheDir = cacheDir
if env is None:
env = os.environ
env_list = [f"{k}={v}" for k, v in env.items()]
Expand All @@ -28,6 +30,7 @@ def merge(self, other: Self) -> Self:
cp.BaseURL = other.BaseURL if other.BaseURL != "" else self.BaseURL
cp.DefaultModel = other.DefaultModel if other.DefaultModel != "" else self.DefaultModel
cp.DefaultModelProvider = other.DefaultModelProvider if other.DefaultModelProvider != "" else self.DefaultModelProvider
cp.CacheDir = other.CacheDir if other.CacheDir != "" else self.CacheDir
cp.Env = (other.Env or []).extend(self.Env or [])
return cp

Expand Down Expand Up @@ -61,9 +64,10 @@ def __init__(self,
apiKey: str = "",
baseURL: str = "",
defaultModelProvider: str = "",
defaultModel: str = ""
defaultModel: str = "",
cacheDir: str = "",
):
super().__init__(apiKey, baseURL, defaultModelProvider, defaultModel)
super().__init__(apiKey, baseURL, defaultModelProvider, defaultModel, cacheDir)
self.input = input
self.disableCache = disableCache
self.subTool = subTool
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gptscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ async def test_tool_chat(gptscript):
async def test_file_chat(gptscript):
inputs = [
"List the 3 largest of the Great Lakes by volume.",
"For the second one in the list, what is the volume in cubic miles?",
"For the third one in the list, what is the total area in square miles?",
"What is the second largest?",
"What is the third one in the list?",
]
expected_outputs = [
"Lake Superior",
Expand Down