Skip to content

Commit c3a714c

Browse files
committed
fix: add currentAgent to CallFrame
Signed-off-by: Donnie Adams <[email protected]>
1 parent 09dec27 commit c3a714c

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

gptscript/frame.py

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(self,
115115
id: str = "",
116116
tool: Tool = None,
117117
agentGroup: list[ToolReference] = None,
118+
currentAgent: ToolReference = None,
118119
displayText: str = "",
119120
inputContext: list[InputContext] = None,
120121
toolCategory: str = "",
@@ -137,6 +138,9 @@ def __init__(self,
137138
for i in range(len(self.agentGroup)):
138139
if isinstance(self.agentGroup[i], dict):
139140
self.agentGroup[i] = ToolReference(**self.agentGroup[i])
141+
self.currentAgent = currentAgent
142+
if self.currentAgent is not None and isinstance(self.currentAgent, dict):
143+
self.currentAgent = ToolReference(**self.currentAgent)
140144
self.displayText = displayText
141145
self.inputContext = inputContext
142146
if self.inputContext is not None:

gptscript/gptscript.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _wait_for_gptscript(self):
7070

7171
def close(self):
7272
GPTScript.__gptscript_count -= 1
73-
if GPTScript.__gptscript_count == 0:
73+
if GPTScript.__gptscript_count == 0 and GPTScript.__process is not None:
7474
GPTScript.__process.stdin.close()
7575
GPTScript.__process.wait()
7676
GPTScript.__server_ready = False
@@ -149,4 +149,4 @@ def _get_command():
149149
if platform.system() == "Windows":
150150
bin_path += ".exe"
151151

152-
return bin_path if os.path.exists(bin_path) else "gptscript"
152+
return bin_path if os.path.exists(bin_path) else "gptscript"

gptscript/run.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ async def text(self) -> str:
5151
try:
5252
if self._task is not None:
5353
await self._task
54-
except Exception:
54+
except Exception as e:
5555
self._state = RunState.Error
5656
if self._aborted:
5757
self._err = "Run was aborted"
58+
else:
59+
self._err = str(e)
5860
finally:
5961
self._task = None
6062

tox.ini

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
envlist = py3
33

44
[testenv]
5-
deps = httpx
6-
pytest-asyncio
5+
deps =
6+
httpx
7+
pytest
8+
pytest-asyncio
79

8-
passenv = OPENAI_API_KEY
9-
GPTSCRIPT_BIN
10-
GPTSCRIPT_URL
11-
GPTSCRIPT_DISABLE_SERVER
12-
GPTSCRIPT_CONFIG_FILE
10+
passenv =
11+
OPENAI_API_KEY
12+
GPTSCRIPT_BIN
13+
GPTSCRIPT_URL
14+
GPTSCRIPT_DISABLE_SERVER
15+
GPTSCRIPT_CONFIG_FILE
1316
commands =
1417
install_gptscript
15-
pytest -s tests/
18+
pytest -s tests/ {posargs}

0 commit comments

Comments
 (0)