Skip to content

Commit

Permalink
Fix sequential agents unable to use skills and uploads. (#65)
Browse files Browse the repository at this point in the history
- Use `memberModel` instead of `member` when populating tools.
- Refactor `convert_sequential_team_to_dict` to take a list of members instead of team.
  • Loading branch information
StreetLamb authored Jul 2, 2024
1 parent 914af14 commit d3e596b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions backend/app/core/graph/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ def convert_hierarchical_team_to_dict(
return teams


def convert_sequential_team_to_dict(team: Team) -> Mapping[str, GraphMember]:
def convert_sequential_team_to_dict(members: list[Member]) -> Mapping[str, GraphMember]:
team_dict: dict[str, GraphMember] = {}

in_counts: defaultdict[int, int] = defaultdict(int)
out_counts: defaultdict[int, list[int]] = defaultdict(list[int])
members_lookup: dict[int, Member] = {}

for member in team.members:
for member in members:
assert member.id is not None, "member.id is unexpectedly None"
if member.source:
in_counts[member.id] += 1
Expand All @@ -171,7 +170,7 @@ def convert_sequential_team_to_dict(team: Team) -> Mapping[str, GraphMember]:
managed=skill.managed,
definition=skill.tool_definition,
)
for skill in member.skills
for skill in memberModel.skills
]
tools += [
GraphUpload(
Expand All @@ -180,7 +179,7 @@ def convert_sequential_team_to_dict(team: Team) -> Mapping[str, GraphMember]:
owner_id=upload.owner_id,
upload_id=cast(int, upload.id),
)
for upload in member.uploads
for upload in memberModel.uploads
if upload.owner_id is not None
]
graph_member = GraphMember(
Expand Down Expand Up @@ -453,7 +452,6 @@ async def generator(

try:
memory = await AsyncPostgresSaver.from_conn_string(settings.PG_DATABASE_URI)

if team.workflow == "hierarchical":
teams = convert_hierarchical_team_to_dict(team, members)
team_leader = list(teams.keys())[0]
Expand All @@ -466,7 +464,7 @@ async def generator(
"main_task": formatted_messages,
}
else:
member_dict = convert_sequential_team_to_dict(team)
member_dict = convert_sequential_team_to_dict(members)
root = create_sequential_graph(member_dict, memory)
first_member = list(member_dict.values())[0]
state = {
Expand Down

0 comments on commit d3e596b

Please sign in to comment.