diff --git a/gptscript/frame.py b/gptscript/frame.py index c136611..9ba15da 100644 --- a/gptscript/frame.py +++ b/gptscript/frame.py @@ -115,6 +115,7 @@ def __init__(self, id: str = "", tool: Tool = None, agentGroup: list[ToolReference] = None, + currentAgent: ToolReference = None, displayText: str = "", inputContext: list[InputContext] = None, toolCategory: str = "", @@ -137,6 +138,9 @@ def __init__(self, for i in range(len(self.agentGroup)): if isinstance(self.agentGroup[i], dict): self.agentGroup[i] = ToolReference(**self.agentGroup[i]) + self.currentAgent = currentAgent + if self.currentAgent is not None and isinstance(self.currentAgent, dict): + self.currentAgent = ToolReference(**self.currentAgent) self.displayText = displayText self.inputContext = inputContext if self.inputContext is not None: diff --git a/gptscript/gptscript.py b/gptscript/gptscript.py index 614aed0..8d5bfcc 100644 --- a/gptscript/gptscript.py +++ b/gptscript/gptscript.py @@ -70,7 +70,7 @@ def _wait_for_gptscript(self): def close(self): GPTScript.__gptscript_count -= 1 - if GPTScript.__gptscript_count == 0: + if GPTScript.__gptscript_count == 0 and GPTScript.__process is not None: GPTScript.__process.stdin.close() GPTScript.__process.wait() GPTScript.__server_ready = False @@ -149,4 +149,4 @@ def _get_command(): if platform.system() == "Windows": bin_path += ".exe" - return bin_path if os.path.exists(bin_path) else "gptscript" \ No newline at end of file + return bin_path if os.path.exists(bin_path) else "gptscript" diff --git a/gptscript/run.py b/gptscript/run.py index 9dbf726..2897808 100644 --- a/gptscript/run.py +++ b/gptscript/run.py @@ -51,10 +51,12 @@ async def text(self) -> str: try: if self._task is not None: await self._task - except Exception: + except Exception as e: self._state = RunState.Error if self._aborted: self._err = "Run was aborted" + else: + self._err = str(e) finally: self._task = None diff --git a/tox.ini b/tox.ini index d7abfd3..e99afad 100644 --- a/tox.ini +++ b/tox.ini @@ -2,14 +2,17 @@ envlist = py3 [testenv] -deps = httpx - pytest-asyncio +deps = + httpx + pytest + pytest-asyncio -passenv = OPENAI_API_KEY - GPTSCRIPT_BIN - GPTSCRIPT_URL - GPTSCRIPT_DISABLE_SERVER - GPTSCRIPT_CONFIG_FILE +passenv = + OPENAI_API_KEY + GPTSCRIPT_BIN + GPTSCRIPT_URL + GPTSCRIPT_DISABLE_SERVER + GPTSCRIPT_CONFIG_FILE commands = install_gptscript - pytest -s tests/ + pytest -s tests/ {posargs}