gptdiff 0.1.18__py3-none-any.whl → 0.1.20__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- gptdiff/gptdiff.py +32 -2
- {gptdiff-0.1.18.dist-info → gptdiff-0.1.20.dist-info}/METADATA +1 -1
- gptdiff-0.1.20.dist-info/RECORD +9 -0
- gptdiff-0.1.18.dist-info/RECORD +0 -9
- {gptdiff-0.1.18.dist-info → gptdiff-0.1.20.dist-info}/LICENSE.txt +0 -0
- {gptdiff-0.1.18.dist-info → gptdiff-0.1.20.dist-info}/WHEEL +0 -0
- {gptdiff-0.1.18.dist-info → gptdiff-0.1.20.dist-info}/entry_points.txt +0 -0
- {gptdiff-0.1.18.dist-info → gptdiff-0.1.20.dist-info}/top_level.txt +0 -0
gptdiff/gptdiff.py
CHANGED
@@ -202,7 +202,7 @@ def call_llm_for_diff(system_prompt, user_prompt, files_content, model, temperat
|
|
202
202
|
tool_prompt = formatter.usage_prompt(toolbox)
|
203
203
|
system_prompt += "\n"+tool_prompt
|
204
204
|
|
205
|
-
if
|
205
|
+
if 'gemini' in model:
|
206
206
|
user_prompt = system_prompt+"\n"+user_prompt
|
207
207
|
|
208
208
|
messages = [
|
@@ -241,6 +241,9 @@ def call_llm_for_diff(system_prompt, user_prompt, files_content, model, temperat
|
|
241
241
|
cost = (prompt_tokens / 1_000_000 * cost_per_million_prompt_tokens) + (completion_tokens / 1_000_000 * cost_per_million_completion_tokens)
|
242
242
|
|
243
243
|
full_response = response.choices[0].message.content.strip()
|
244
|
+
full_response, reasoning = swallow_reasoning(full_response)
|
245
|
+
if reasoning and len(reasoning) > 0:
|
246
|
+
print("Swallowed reasoning", reasoning)
|
244
247
|
|
245
248
|
events = parser.parse(full_response)
|
246
249
|
for event in events:
|
@@ -643,6 +646,9 @@ def call_llm_for_apply_with_think_tool_available(file_path, original_content, fi
|
|
643
646
|
formatter = FlatXMLPromptFormatter(tag="think")
|
644
647
|
toolbox = create_think_toolbox()
|
645
648
|
full_response = call_llm_for_apply(file_path, original_content, file_diff, model, api_key=api_key, base_url=base_url, extra_prompt=extra_prompt, max_tokens=max_tokens)
|
649
|
+
full_response, reasoning = swallow_reasoning(full_response)
|
650
|
+
if reasoning and len(reasoning) > 0:
|
651
|
+
print("Swallowed reasoning", reasoning)
|
646
652
|
notool_response = ""
|
647
653
|
events = parser.parse(full_response)
|
648
654
|
is_in_tool = False
|
@@ -707,7 +713,7 @@ Diff to apply:
|
|
707
713
|
```"""
|
708
714
|
if extra_prompt:
|
709
715
|
user_prompt += f"\n\n{extra_prompt}"
|
710
|
-
if
|
716
|
+
if 'gemini' in model:
|
711
717
|
user_prompt = system_prompt+"\n"+user_prompt
|
712
718
|
messages = [
|
713
719
|
{"role": "system", "content": system_prompt},
|
@@ -967,5 +973,29 @@ def main():
|
|
967
973
|
print(f"Total tokens: {total_tokens}")
|
968
974
|
#print(f"Total cost: ${cost:.4f}")
|
969
975
|
|
976
|
+
def swallow_reasoning(full_response: str) -> (str, str):
|
977
|
+
"""
|
978
|
+
Extracts and swallows the chain-of-thought reasoning section from the full LLM response.
|
979
|
+
Assumes the reasoning block starts with a line beginning with "> Reasoning"
|
980
|
+
and ends with a line matching 'Reasoned for <number> seconds'.
|
981
|
+
|
982
|
+
Returns:
|
983
|
+
A tuple (final_content, reasoning) where:
|
984
|
+
- final_content: The response with the reasoning block removed.
|
985
|
+
- reasoning: The extracted reasoning block, or an empty string if not found.
|
986
|
+
"""
|
987
|
+
pattern = re.compile(
|
988
|
+
r"(?P<reasoning>>\s*Reasoning.*?Reasoned for \d+\s*seconds)",
|
989
|
+
re.DOTALL
|
990
|
+
)
|
991
|
+
match = pattern.search(full_response)
|
992
|
+
if match:
|
993
|
+
reasoning = match.group("reasoning").strip()
|
994
|
+
final_content = full_response.replace(reasoning, "").strip()
|
995
|
+
else:
|
996
|
+
reasoning = ""
|
997
|
+
final_content = full_response.strip()
|
998
|
+
return final_content, reasoning
|
999
|
+
|
970
1000
|
if __name__ == "__main__":
|
971
1001
|
main()
|
@@ -0,0 +1,9 @@
|
|
1
|
+
gptdiff/__init__.py,sha256=o1hrK4GFvbfKcHPlLVArz4OunE3euIicEBYaLrdDo0k,198
|
2
|
+
gptdiff/gptdiff.py,sha256=LKBq_E9GanyDv-2FBbbWvP7JUl2Ignb6zvkD2GqmdPo,39074
|
3
|
+
gptdiff/gptpatch.py,sha256=Z8CWWIfIL2o7xPLVdhzN5GSyJq0vsK4XQRzu4hMWNQk,2194
|
4
|
+
gptdiff-0.1.20.dist-info/LICENSE.txt,sha256=zCJk7yUYpMjFvlipi1dKtaljF8WdZ2NASndBYYbU8BY,1228
|
5
|
+
gptdiff-0.1.20.dist-info/METADATA,sha256=v8-LTu-NVLikIexMY5RDEf2t2VTAh7t_3hch379VzFA,8785
|
6
|
+
gptdiff-0.1.20.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
+
gptdiff-0.1.20.dist-info/entry_points.txt,sha256=0VlVNr-gc04a3SZD5_qKIBbtg_L5P2x3xlKE5ftcdkc,82
|
8
|
+
gptdiff-0.1.20.dist-info/top_level.txt,sha256=XNkQkQGINaDndEwRxg8qToOrJ9coyfAb-EHrSUXzdCE,8
|
9
|
+
gptdiff-0.1.20.dist-info/RECORD,,
|
gptdiff-0.1.18.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
gptdiff/__init__.py,sha256=o1hrK4GFvbfKcHPlLVArz4OunE3euIicEBYaLrdDo0k,198
|
2
|
-
gptdiff/gptdiff.py,sha256=ZBkgPTcCDumOD7JcWxXDdhh8qykEJb31_AsxRJhRlCE,37876
|
3
|
-
gptdiff/gptpatch.py,sha256=Z8CWWIfIL2o7xPLVdhzN5GSyJq0vsK4XQRzu4hMWNQk,2194
|
4
|
-
gptdiff-0.1.18.dist-info/LICENSE.txt,sha256=zCJk7yUYpMjFvlipi1dKtaljF8WdZ2NASndBYYbU8BY,1228
|
5
|
-
gptdiff-0.1.18.dist-info/METADATA,sha256=vI9eBGXnzwiS67yxnZ6Op6lzm8ssLTq-KSLPWKjxL8w,8785
|
6
|
-
gptdiff-0.1.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
-
gptdiff-0.1.18.dist-info/entry_points.txt,sha256=0VlVNr-gc04a3SZD5_qKIBbtg_L5P2x3xlKE5ftcdkc,82
|
8
|
-
gptdiff-0.1.18.dist-info/top_level.txt,sha256=XNkQkQGINaDndEwRxg8qToOrJ9coyfAb-EHrSUXzdCE,8
|
9
|
-
gptdiff-0.1.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|