Skip to content

Commit 2798bc1

Browse files
committed
Fix potential error in SummariserNode if team_responses exceed the context_length of the model
1 parent 5ec3468 commit 2798bc1

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

backend/app/core/graph/members.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,25 +395,19 @@ class SummariserNode(BaseNode):
395395
"Here is the team's task:"
396396
"\n\n{team_task}\n\n"
397397
"These are the responses from your team members:"
398-
"\n\n{team_responses}\n"
399-
"Your role is to interpret all the responses and give the final answer to the team's task.\n"
400398
),
401399
),
402-
("human", "?"),
400+
MessagesPlaceholder(variable_name="messages"),
401+
(
402+
"human",
403+
"Your role is to interpret all the responses and give the final answer to the team's task.\n",
404+
),
403405
]
404406
)
405407

406-
def get_team_responses(self, messages: list[AnyMessage]) -> str:
407-
"""Create a string containing the team's responses."""
408-
result = ""
409-
for message in messages:
410-
result += f"{message.name}: {message.content}\n"
411-
return result
412-
413408
async def summarise(self, state: TeamState) -> dict[str, list[AnyMessage]]:
414409
team = state["team"]
415410
team_members_name = self.get_team_members_name(team.members)
416-
team_responses = self.get_team_responses(state["messages"])
417411
# TODO: optimise looking for task
418412
team_task = state["main_task"][0].content
419413

@@ -422,7 +416,6 @@ async def summarise(self, state: TeamState) -> dict[str, list[AnyMessage]]:
422416
team_name=team.name,
423417
team_members_name=team_members_name,
424418
team_task=team_task,
425-
team_responses=team_responses,
426419
)
427420
| self.final_answer_model
428421
| RunnableLambda(self.tag_with_name).bind(name=f"{team.name}_answer") # type: ignore[arg-type]

0 commit comments

Comments
 (0)