Fix agent tool support, fix many other bugs
This commit is contained in:
1 parent
2b44dcebf4
commit
6c5140fb92
5 files changed
+79
-56
No files matched your search
@@ -34,6 +34,7 @@ class Agent:
|
||||
self.config = {field.name: data.get(field.name, field.default) for field in getattr(agent_class, 'schema_fields', [])}
|
||||
self.resources = resources
|
||||
|
||||
# should be in expert init?
|
||||
self.tools = []
|
||||
for resource in self.resources:
|
||||
if resource.kind != 'tool': continue
|
||||
@@ -66,7 +67,6 @@ class Agent:
|
||||
**kwargs,
|
||||
},
|
||||
)
|
||||
await self.run(run)
|
||||
out_stream = Stream(self.app)
|
||||
|
||||
def on_output_event(stream):
|
||||
@@ -77,6 +77,7 @@ class Agent:
|
||||
out_stream.close()
|
||||
run.on('output', on_output_event)
|
||||
run.on('done', on_done)
|
||||
await self.run(run)
|
||||
|
||||
return out_stream
|
||||
|
||||
@@ -95,14 +96,11 @@ class Agent:
|
||||
user_id=self.user_id,
|
||||
input={
|
||||
"messages": messages,
|
||||
"tools": getattr(self, "tools", []),
|
||||
"chat_id": message.chat_id,
|
||||
"thread_id": message.thread_id,
|
||||
},
|
||||
)
|
||||
|
||||
await self.run(run)
|
||||
|
||||
async def on_output_event(stream):
|
||||
print("[agent] run output " + repr(stream))
|
||||
new_message = await self.app.send_chat_message(
|
||||
@@ -118,6 +116,8 @@ class Agent:
|
||||
})
|
||||
|
||||
await run.on_async('output', on_output_event)
|
||||
|
||||
await self.run(run)
|
||||
return run
|
||||
|
||||
def _role_for_message(self, message):
|
||||
|
||||
Reference in new issue
Block a user