Skip to content

Commit eb094a6

Browse files
authored
Merge pull request #50 from thedadams/add-cache-dir-opt
feat: add CacheDir option to GlobalOptions
2 parents e644c85 + 3d325fc commit eb094a6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

gptscript/opts.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ def __init__(
99
baseURL: str = "",
1010
defaultModelProvider: str = "",
1111
defaultModel: str = "",
12+
cacheDir: str = "",
1213
env: Mapping[str, str] = None,
1314
):
1415
self.APIKey = apiKey
1516
self.BaseURL = baseURL
1617
self.DefaultModel = defaultModel
1718
self.DefaultModelProvider = defaultModelProvider
19+
self.CacheDir = cacheDir
1820
if env is None:
1921
env = os.environ
2022
env_list = [f"{k}={v}" for k, v in env.items()]
@@ -28,6 +30,7 @@ def merge(self, other: Self) -> Self:
2830
cp.BaseURL = other.BaseURL if other.BaseURL != "" else self.BaseURL
2931
cp.DefaultModel = other.DefaultModel if other.DefaultModel != "" else self.DefaultModel
3032
cp.DefaultModelProvider = other.DefaultModelProvider if other.DefaultModelProvider != "" else self.DefaultModelProvider
33+
cp.CacheDir = other.CacheDir if other.CacheDir != "" else self.CacheDir
3134
cp.Env = (other.Env or []).extend(self.Env or [])
3235
return cp
3336

@@ -61,9 +64,10 @@ def __init__(self,
6164
apiKey: str = "",
6265
baseURL: str = "",
6366
defaultModelProvider: str = "",
64-
defaultModel: str = ""
67+
defaultModel: str = "",
68+
cacheDir: str = "",
6569
):
66-
super().__init__(apiKey, baseURL, defaultModelProvider, defaultModel)
70+
super().__init__(apiKey, baseURL, defaultModelProvider, defaultModel, cacheDir)
6771
self.input = input
6872
self.disableCache = disableCache
6973
self.subTool = subTool

tests/test_gptscript.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ async def test_tool_chat(gptscript):
455455
async def test_file_chat(gptscript):
456456
inputs = [
457457
"List the 3 largest of the Great Lakes by volume.",
458-
"For the second one in the list, what is the volume in cubic miles?",
459-
"For the third one in the list, what is the total area in square miles?",
458+
"What is the second largest?",
459+
"What is the third one in the list?",
460460
]
461461
expected_outputs = [
462462
"Lake Superior",

0 commit comments

Comments
 (0)