diff --git a/chatlas/_chat.py b/chatlas/_chat.py
index 8dfd109..9989404 100644
--- a/chatlas/_chat.py
+++ b/chatlas/_chat.py
@@ -948,11 +948,11 @@ def export(
is_html = filename.suffix == ".html"
# Get contents from each turn
- contents = ""
+ content_arr: list[str] = []
for turn in turns:
turn_content = "\n\n".join(
[
- str(content)
+ str(content).strip()
for content in turn.contents
if include == "all" or isinstance(content, ContentText)
]
@@ -963,7 +963,8 @@ def export(
turn_content = f""
else:
turn_content = f"## {turn.role.capitalize()}\n\n{turn_content}"
- contents += f"{turn_content}\n\n"
+ content_arr.append(turn_content)
+ contents = "\n\n".join(content_arr)
# Shiny chat message components requires container elements
if is_html:
diff --git a/chatlas/_content.py b/chatlas/_content.py
index 0f2737a..76ea2bd 100644
--- a/chatlas/_content.py
+++ b/chatlas/_content.py
@@ -155,7 +155,7 @@ def __str__(self):
args_str = self._arguments_str()
func_call = f"{self.name}({args_str})"
comment = f"# tool request ({self.id})"
- return f"\n```python\n{comment}\n{func_call}\n```\n"
+ return f"```python\n{comment}\n{func_call}\n```\n"
def _repr_markdown_(self):
return self.__str__()
@@ -246,7 +246,7 @@ def __str__(self):
return json.dumps(self.value, indent=2)
def _repr_markdown_(self):
- return f"""\n```json\n{self.__str__()}\n```\n"""
+ return f"""```json\n{self.__str__()}\n```"""
def __repr__(self, indent: int = 0):
return " " * indent + f""