Skip to content

Commit

Permalink
refactor set_combination_instructions and more unit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-ashkinaze committed Oct 15, 2024
1 parent 9c2f328 commit fffa906
Show file tree
Hide file tree
Showing 2 changed files with 348 additions and 12 deletions.
21 changes: 9 additions & 12 deletions plurals/deliberation.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,15 @@ def __init__(

def _set_combination_instructions(self) -> None:
"""
Set the combination instructions for agents based on the provided value or the default. If agents have their own
combination instructions, use those instead.
Set the combination instructions for agents based on the provided value or the default.
If agents have their own combination instructions, use those instead.
"""
self.combination_instructions = SmartString(
self.defaults["combination_instructions"].get(
self.combination_instructions, self.combination_instructions
)
self.combination_instructions = self.defaults["combination_instructions"].get(
self.combination_instructions, self.combination_instructions
)

for agent in self.agents:
if agent.combination_instructions:
pass
else:
if not agent.combination_instructions:
agent.combination_instructions = self.combination_instructions

def _set_agent_task_description(self) -> None:
Expand Down Expand Up @@ -646,11 +641,12 @@ def __init__(
agents=agents,
task=task,
shuffle=shuffle,
combination_instructions=combination_instructions,
cycles=cycles,
last_n=last_n,
moderator=moderator,
)
self.combination_instructions = combination_instructions
self._set_combination_instructions()

@staticmethod
def _format_previous_responses(responses: List[str]) -> str:
Expand Down Expand Up @@ -830,9 +826,10 @@ def __init__(
self.edges = edges

super().__init__(
agents=self.agents, task=task, last_n=last_n, moderator=moderator
agents=self.agents, task=task, last_n=last_n, moderator=moderator, combination_instructions=combination_instructions
)
self._build_graph()
self._set_combination_instructions()

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

0 comments on commit fffa906

Please sign in to comment.