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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gptdiff
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: A tool to generate and apply git diffs using LLMs
5
5
  Author: 255labs
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -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
- <filecontents>
700
+ ```
701
701
  {original_content}
702
- </filecontents>
702
+ ```
703
703
 
704
704
  Diff to apply:
705
- <diff>
705
+ ```diff
706
706
  {file_diff}
707
- </diff>"""
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 not args.call and not args.apply:
889
- system_prompt = prepend + f"Output a git diff into a ```diff block"
890
- else:
891
- system_prompt = prepend + f"Output a git diff into a <diff> block."
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gptdiff
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: A tool to generate and apply git diffs using LLMs
5
5
  Author: 255labs
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -13,5 +13,6 @@ gptdiff.egg-info/top_level.txt
13
13
  tests/test_applydiff.py
14
14
  tests/test_applydiff_edgecases.py
15
15
  tests/test_diff_parse.py
16
+ tests/test_failing_case.py
16
17
  tests/test_parse_diff_per_file.py
17
18
  tests/test_smartapply.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='gptdiff',
5
- version='0.1.16',
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