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