gptdiff 0.1.16__tar.gz → 0.1.18__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {gptdiff-0.1.16 → gptdiff-0.1.18}/PKG-INFO +1 -1
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff/gptdiff.py +9 -9
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff.egg-info/PKG-INFO +1 -1
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff.egg-info/SOURCES.txt +1 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/setup.py +1 -1
- gptdiff-0.1.18/tests/test_failing_case.py +25 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/LICENSE.txt +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/README.md +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff/__init__.py +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff/gptpatch.py +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff.egg-info/dependency_links.txt +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff.egg-info/entry_points.txt +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff.egg-info/requires.txt +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/gptdiff.egg-info/top_level.txt +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/setup.cfg +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/tests/test_applydiff.py +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/tests/test_applydiff_edgecases.py +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/tests/test_diff_parse.py +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/tests/test_parse_diff_per_file.py +0 -0
- {gptdiff-0.1.16 → gptdiff-0.1.18}/tests/test_smartapply.py +0 -0
@@ -697,14 +697,14 @@ def call_llm_for_apply(file_path, original_content, file_diff, model, api_key=No
|
|
697
697
|
4. You must return the entire file. It overwrites the existing file."""
|
698
698
|
user_prompt = f"""File: {file_path}
|
699
699
|
File contents:
|
700
|
-
|
700
|
+
```
|
701
701
|
{original_content}
|
702
|
-
|
702
|
+
```
|
703
703
|
|
704
704
|
Diff to apply:
|
705
|
-
|
705
|
+
```diff
|
706
706
|
{file_diff}
|
707
|
-
|
707
|
+
```"""
|
708
708
|
if extra_prompt:
|
709
709
|
user_prompt += f"\n\n{extra_prompt}"
|
710
710
|
if model == "gemini-2.0-flash-thinking-exp-01-21":
|
@@ -867,7 +867,7 @@ def main():
|
|
867
867
|
project_files.extend(load_project_files(additional_path, project_dir))
|
868
868
|
|
869
869
|
if args.prepend:
|
870
|
-
prepend = args.prepend
|
870
|
+
prepend = args.prepend+"\n"
|
871
871
|
else:
|
872
872
|
prepend = ""
|
873
873
|
|
@@ -885,10 +885,10 @@ def main():
|
|
885
885
|
# If the specified prepend path does not exist, treat the value as literal content.
|
886
886
|
prepend = prepend
|
887
887
|
|
888
|
-
if
|
889
|
-
|
890
|
-
|
891
|
-
|
888
|
+
if prepend != "":
|
889
|
+
prepend += "\n"
|
890
|
+
|
891
|
+
system_prompt = prepend + f"Output a git diff into a ```diff block"
|
892
892
|
|
893
893
|
files_content = ""
|
894
894
|
for file, content in project_files:
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='gptdiff',
|
5
|
-
version='0.1.
|
5
|
+
version='0.1.18',
|
6
6
|
description='A tool to generate and apply git diffs using LLMs',
|
7
7
|
author='255labs',
|
8
8
|
packages=find_packages(), # Use find_packages() to automatically discover packages
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import unittest
|
2
|
+
from gptdiff.gptdiff import smartapply
|
3
|
+
|
4
|
+
class TestSmartApplyEdgeCase(unittest.TestCase):
|
5
|
+
def test_smartapply_think_tag_stripping(self):
|
6
|
+
"""
|
7
|
+
This test verifies that if an LLM response includes extraneous wrapping (e.g.
|
8
|
+
), these tags are stripped from the final applied diff.
|
9
|
+
"""
|
10
|
+
diff_text = '''diff --git a/hello.py b/hello.py
|
11
|
+
--- a/hello.py
|
12
|
+
++++ b/hello.py
|
13
|
+
@@ -1,2 +1,5 @@
|
14
|
+
def hello():
|
15
|
+
print('Hello')
|
16
|
+
++
|
17
|
+
++def goodbye():
|
18
|
+
++ print('Goodbye')'''
|
19
|
+
original_files = {"hello.py": "def hello():\n print('Hello')\n"}
|
20
|
+
|
21
|
+
from unittest.mock import patch
|
22
|
+
with patch('gptdiff.gptdiff.call_llm_for_apply', return_value="\ndef goodbye():\n print('Goodbye')"):
|
23
|
+
updated_files = smartapply(diff_text, original_files)
|
24
|
+
|
25
|
+
self.assertIn("def goodbye():", updated_files.get("hello.py", ""))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|