Skip to content

Commit

Permalink
temp save
Browse files Browse the repository at this point in the history
  • Loading branch information
dcstrange committed Jan 23, 2024
1 parent c9a44e8 commit b55614a
Show file tree
Hide file tree
Showing 7 changed files with 507 additions and 26 deletions.
35 changes: 23 additions & 12 deletions agency_swarm/agency/agency.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,29 @@ def check_caller_agent_name(cls, value):
raise ValueError(f"Caller agent name must be {agent.name}.")
return value

def run(self):
session = outer_self.agents_and_sessions[self.caller_agent_name][self.recipient.value]
gen = session.get_completion(message=self.message, message_files=self.message_files)
try:
while True:
yield next(gen)
except StopIteration as e:
message = e.value

return message or ""

return SendMessage
def run(self, caller_thread):
session = caller_thread.sessions[self.recipient.value]

if session is None:
session = Session(caller_agent=self.caller_agent, # TODO: check this parameter if error.
recipient_agent=outer_self.get_agent_by_name(self.recipient.value),
caller_thread=caller_thread)
caller_thread.sessions[self.recipient.value] = session

if not isinstance(session, Session):
raise Exception("error")

#===================# python.thread.create()====================================
# TODO: 创建新的Python线程执行session
caller_thread.session_as_sender = session
response = session.get_completion(message=self.message, message_files=self.message_files)
#======================# python.thread.wait_to_join()=================================

return response or ""

# TODO: 每个Agent有自己的SendMessage对象。但是当前这个版本认为一个Agent在某一时刻只能有一个SendMessage函数被调用。
# 实际上,在Session模型中,一个Agent有多个Thread,因此可能会有多个SendMessage并行。所以需要注意全局变量的使用。
return SendMessage

def get_recipient_names(self):
"""
Expand Down
Loading

0 comments on commit b55614a

Please sign in to comment.