Files
FusionAGI/fusionagi/multi_agent/consensus.py
defiQUG c052b07662
Some checks failed
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / docker (push) Has been cancelled
Initial commit: add .gitignore and README
2026-02-09 21:51:42 -08:00

16 lines
539 B
Python

from typing import Any
from collections import Counter
from fusionagi._logger import logger
def consensus_vote(answers: list, key=None):
if not answers:
return None
values = [a.get(key, a) if isinstance(a, dict) else a for a in answers] if key else list(answers)
return Counter(values).most_common(1)[0][0]
def arbitrate(proposals: list, arbitrator="coordinator"):
if not proposals:
return {}
logger.info("Arbitrate", extra={"arbitrator": arbitrator, "count": len(proposals)})
return proposals[0]