Skip to content

Commit

Permalink
Merge pull request #50 from thedadams/add-cache-dir-opt
Browse files Browse the repository at this point in the history
feat: add CacheDir option to GlobalOptions
  • Loading branch information
thedadams authored Sep 3, 2024
2 parents e644c85 + 3d325fc commit eb094a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit eb094a6

Please sign in to comment.