Update majority_voting.py

pull/766/merge^2
nathanogaga118 3 months ago committed by GitHub
parent 393988cebd
commit 3c9391405b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -45,6 +45,11 @@ def parse_code_completion(agent_response, question):
Returns: Returns:
tuple: A tuple containing the parsed Python code and a boolean indicating success. tuple: A tuple containing the parsed Python code and a boolean indicating success.
""" """
# Input validation
if not isinstance(agent_response, str) or not isinstance(question, str):
logger.error("Invalid inputs provided to parse_code_completion.")
return "", False
python_code = extract_last_python_code_block(agent_response) python_code = extract_last_python_code_block(agent_response)
if python_code is None: if python_code is None:
if agent_response.count("impl]") == 0: if agent_response.count("impl]") == 0:
@ -181,6 +186,11 @@ class MajorityVoting:
List[Any]: The majority vote. List[Any]: The majority vote.
""" """
# Input validation
if not isinstance(task, str) or not task.strip():
logger.error("Invalid task provided to run.")
return []
# Route to each agent # Route to each agent
with concurrent.futures.ThreadPoolExecutor() as executor: with concurrent.futures.ThreadPoolExecutor() as executor:
logger.info("Running agents concurrently") logger.info("Running agents concurrently")

Loading…
Cancel
Save