mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
feat: display matching entries side-by-side with diff highlighting
This commit is contained in:
parent
be44b65095
commit
82b26daf37
1 changed files with 35 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import difflib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import json5
|
import json5
|
||||||
|
@ -43,12 +44,42 @@ def main():
|
||||||
litellm_keys = set(litellm_data.keys())
|
litellm_keys = set(litellm_data.keys())
|
||||||
aider_keys = set(aider_data.keys())
|
aider_keys = set(aider_data.keys())
|
||||||
|
|
||||||
common_keys = litellm_keys.intersection(aider_keys)
|
common_keys = sorted(list(litellm_keys.intersection(aider_keys)))
|
||||||
|
|
||||||
if common_keys:
|
if common_keys:
|
||||||
print("Common models found in both files:")
|
print("Comparing common models found in both files:\n")
|
||||||
for key in sorted(list(common_keys)):
|
for key in common_keys:
|
||||||
print(f"- {key}")
|
print(f"--- {key} (litellm) ---")
|
||||||
|
print(f"+++ {key} (aider) +++")
|
||||||
|
|
||||||
|
litellm_entry = litellm_data.get(key, {})
|
||||||
|
aider_entry = aider_data.get(key, {})
|
||||||
|
|
||||||
|
# Convert dicts to formatted JSON strings for comparison
|
||||||
|
litellm_json = json.dumps(litellm_entry, indent=4, sort_keys=True).splitlines()
|
||||||
|
aider_json = json.dumps(aider_entry, indent=4, sort_keys=True).splitlines()
|
||||||
|
|
||||||
|
# Generate unified diff
|
||||||
|
diff = difflib.unified_diff(
|
||||||
|
litellm_json,
|
||||||
|
aider_json,
|
||||||
|
fromfile=f"{key} (litellm)",
|
||||||
|
tofile=f"{key} (aider)",
|
||||||
|
lineterm="",
|
||||||
|
n=max(len(litellm_json), len(aider_json)), # Show all lines
|
||||||
|
)
|
||||||
|
|
||||||
|
# Print the diff, skipping the header lines generated by unified_diff
|
||||||
|
diff_lines = list(diff)[2:]
|
||||||
|
if not diff_lines:
|
||||||
|
print("(No differences found)")
|
||||||
|
else:
|
||||||
|
for line in diff_lines:
|
||||||
|
# Add color for better readability (optional, requires a library like 'termcolor' or manual ANSI codes)
|
||||||
|
# Simple +/- indication is standard for diffs
|
||||||
|
print(line)
|
||||||
|
print("\n" + "=" * 40 + "\n")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("No common models found between the two files.")
|
print("No common models found between the two files.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue