diff --git a/backend/src/agent.py b/backend/src/agent.py index 03d2db2..fcab85f 100644 --- a/backend/src/agent.py +++ b/backend/src/agent.py @@ -66,6 +66,7 @@ class Agent: agent_run.close() raise NotImplementedError("Subclasses must implement run()") + # Deprecate this. This is just run with extra baggage. async def prompt(self, instruction, input=None, **kwargs): run = AgentRun.create( self.app, diff --git a/backend/src/agents/expert.py b/backend/src/agents/expert.py index 1b5f53e..72d7e30 100644 --- a/backend/src/agents/expert.py +++ b/backend/src/agents/expert.py @@ -40,6 +40,9 @@ async def chat_completion_loop(app, run, messages, model_id=None, tools=None): run.emit_event('inference', msg) + # Broken generator with no output + else: break + for tc in tool_calls: tool = next((t for t in tools if t.name == tc.tool_name), None) if tool is None: @@ -50,8 +53,9 @@ async def chat_completion_loop(app, run, messages, model_id=None, tools=None): else: tc.tool = tool - # By default, end if there's no calls - else: break + # If not calling must output something useful + else: + if turn_response: break run.close() diff --git a/backend/src/tool.py b/backend/src/tool.py index c6e503d..a501322 100644 --- a/backend/src/tool.py +++ b/backend/src/tool.py @@ -149,7 +149,7 @@ class Tool: @classmethod def tool_name(cls): - return ''.join(['_'+c.lower() if c.isupper() else c for c in cls.__name__]).lstrip('_') + return ''.join(['-'+c.lower() if c.isupper() else c for c in cls.__name__]).lstrip('_') def _generate_spec(self): diff --git a/backend/src/utils.py b/backend/src/utils.py index 894d90d..144718d 100644 --- a/backend/src/utils.py +++ b/backend/src/utils.py @@ -20,7 +20,10 @@ def encode_value(value): json['result'] = encode_value(value.result), return json elif isinstance(value, Stream): - return {'streamId': value.id} + if value.open: + return {'streamId': value.id} + else: + return value.content else: return value