in aidial_sdk/chat_completion/choice.py [0:0]
def add_attachment(self, *args, **kwargs) -> None:
if not self._opened:
raise runtime_error(
"Trying to add attachment to an unopened choice"
)
if self._closed:
raise runtime_error("Trying to add attachment to a closed choice")
attachment_chunk = None
try:
attachment_chunk = AttachmentChunk(
choice_index=self._index,
attachment_index=self._last_attachment_index,
**create_attachment(*args, **kwargs).dict(),
)
except ValidationError as e:
raise runtime_error(e.errors()[0]["msg"])
self.send_chunk(attachment_chunk)
self._last_attachment_index += 1