use difflib to give edit change description

This commit is contained in:
Ty Dunn 2023-07-17 10:19:54 -05:00
parent 88c1f16c59
commit 594f7ceb5c

View file

@ -1,6 +1,7 @@
# These steps are depended upon by ContinueSDK
import os
import subprocess
import difflib
from textwrap import dedent
from typing import Coroutine, List, Literal, Union
@ -172,13 +173,12 @@ class DefaultModelEditCodeStep(Step):
if self._previous_contents.strip() == self._new_contents.strip():
description = "No edits were made"
else:
changes = '\n'.join(difflib.ndiff(self._previous_contents.splitlines(), self._new_contents.splitlines()))
description = await models.gpt3516k.complete(dedent(f"""\
```original
{self._previous_contents}
```
Diff summary: "{self.user_input}"
```new
{self._new_contents}
```diff
{changes}
```
Please give brief a description of the changes made above using markdown bullet points. Be concise:"""))