From fdf4e841996760742baf504558942adbfc72f44e Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Tue, 3 Sep 2024 13:58:02 -0400 Subject: [PATCH 1/2] feat: add CacheDir option to GlobalOptions Signed-off-by: Donnie Adams --- gptscript/opts.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gptscript/opts.py b/gptscript/opts.py index 634ed51..ef1537a 100644 --- a/gptscript/opts.py +++ b/gptscript/opts.py @@ -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()] @@ -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 @@ -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 From 3d325fccc2033085027424163afe62fe52e18f17 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Tue, 3 Sep 2024 14:00:47 -0400 Subject: [PATCH 2/2] fix: try to address flake in chat test Signed-off-by: Donnie Adams --- tests/test_gptscript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_gptscript.py b/tests/test_gptscript.py index 3820b29..74c486a 100644 --- a/tests/test_gptscript.py +++ b/tests/test_gptscript.py @@ -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",