Skip to content

fix: add currentAgent to CallFrame #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gptscript/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions gptscript/gptscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
return bin_path if os.path.exists(bin_path) else "gptscript"
4 changes: 3 additions & 1 deletion gptscript/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 11 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}