MCPcopy Create free account
hub / github.com/BillHuang2001/evogit / llm_diff_compare

Function llm_diff_compare

python-impl/evogit/api.py:596–629  ·  view source on GitHub ↗

Return True if the change from prev_commit to new_commit is good, and False otherwise. If the prev_commit and new_commit are the same commit, return True.

(
    config: EvoGitConfig,
    llm_backend: Any,
    seeds: list[int],
    prev_commits: list[str],
    new_commits: list[str],
)

Source from the content-addressed store, hash-verified

594
595
596def llm_diff_compare(
597 config: EvoGitConfig,
598 llm_backend: Any,
599 seeds: list[int],
600 prev_commits: list[str],
601 new_commits: list[str],
602) -> list[bool]:
603 """Return True if the change from prev_commit to new_commit is good, and False otherwise.
604 If the prev_commit and new_commit are the same commit, return True.
605 """
606 assert len(prev_commits) == len(new_commits)
607 prompts = []
608 need_compare_idx = []
609 for i, (prev_commit, new_commit) in enumerate(zip(prev_commits, new_commits)):
610 if prev_commit != new_commit:
611 # only compare them if the commits are different
612 prompt = _construct_diff_comp_prompt(config, prev_commit, new_commit)
613 prompts.append(prompt)
614 need_compare_idx.append(i)
615
616 responses = llm_backend.query(seeds, prompts)
617 result = [True] * len(prev_commits) # default to True for same commits
618 for idx, response in zip(need_compare_idx, responses):
619 if "good" in response.lower():
620 result[idx] = True
621 elif "bad" in response.lower():
622 result[idx] = False
623 else:
624 logger.warning(
625 f"Unknown response from LLM: {response}. Assuming the change is bad."
626 )
627 result[idx] = False
628
629 return result
630
631
632def lint_code_base(

Callers

nothing calls this directly

Calls 2

queryMethod · 0.80

Tested by

no test coverage detected