Skip to content

Commit

Permalink
fix: fixed regression in 78e5f52
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 18, 2023
1 parent be40f10 commit 7160b97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gptme/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def is_supported_codeblock(codeblock: str) -> bool:
def get_codeblocks(content: str) -> Generator[str, None, None]:
"""Returns all codeblocks in a message."""
for codeblock in ("\n" + content).split("\n```")[1::2]:
yield codeblock
yield codeblock + "\n"


def init_tools() -> None:
Expand Down
2 changes: 1 addition & 1 deletion gptme/tools/save.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from collections.abc import Generator
from pathlib import Path

from ..message import Message
from ..util import ask_execute
Expand Down
6 changes: 4 additions & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_get_codeblocks():
assert (
codeblocks[0]
== """python
print("hello world")"""
print("hello world")
"""
)

# test a codeblock which contains triple backticks
Expand All @@ -65,5 +66,6 @@ def test_get_codeblocks():
assert (
codeblocks[0]
== """python
print("hello ``` world")"""
print("hello ``` world")
"""
)

0 comments on commit 7160b97

Please sign in to comment.