wip: thread revamp
This commit is contained in:
1 parent
5b3f8b0f09
commit
9277b5a770
11 files changed
+401
-205
No files matched your search
+12
-9
@@ -82,21 +82,24 @@ class Agent:
|
||||
return out_stream
|
||||
|
||||
async def received_message(self, message):
|
||||
chat_view = await self.app.get_chat_view(message.chat_id)
|
||||
thread = chat_view.get_thread(message.thread_id)
|
||||
chat = await self.app.get_chat(message.chat_id)
|
||||
thread = chat.get_thread(message.thread_id)
|
||||
thread.skip_list += ['log', 'resource']
|
||||
await thread.load_page()
|
||||
|
||||
remotes = []
|
||||
messages = []
|
||||
for msg in thread.messages:
|
||||
role = self._role_for_message(msg)
|
||||
messages.append({"role": role, "content": msg.content})
|
||||
|
||||
for msg in thread.resources:
|
||||
# Remote declarations: content is the remote name
|
||||
if msg.subkind == 'remote':
|
||||
name = msg.content
|
||||
if (self.user_id, name) in self.app.remotes and name not in remotes:
|
||||
remotes.append(name)
|
||||
remotes = []
|
||||
def add_remote(name):
|
||||
if name not in remotes and (self.user_id, name) in self.app.remotes:
|
||||
remotes.append(name)
|
||||
|
||||
remote_messages = await thread.fetch_kind_page('resource', 'remote')
|
||||
for msg in remote_messages:
|
||||
add_remote(msg)
|
||||
|
||||
run = AgentRun.create(
|
||||
self.app,
|
||||
|
||||
Reference in new issue
Block a user