Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0027da7

Browse files
small xml tag related fix
1 parent e5c714a commit 0027da7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ __pycache__
66

77
samples/*
88
desktop.ini
9-
logs/*
9+
logs/*
10+
11+
test.ipynb

src/promptings/MapCoder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ def trim_text(text: str, trimmed_text: str):
149149

150150
@staticmethod
151151
def replace_tag(text: str, tag: str):
152-
return text.replace(f'<{tag}>', f'<{tag}><![CDATA[').replace(f'</{tag}>', f']]></{tag}>').strip()
152+
if f'<{tag}><![CDATA[' in text and f']]></{tag}>' in text:
153+
return text
154+
else:
155+
return text.replace(f'<{tag}>', f'<{tag}><![CDATA[').replace(f'</{tag}>', f']]></{tag}>').strip()
153156

154157
@staticmethod
155158
def get_sample_io_str(sample_io: any) -> str:

0 commit comments

Comments
 (0)