Skip to content

Commit 3bc8fec

Browse files
committed
chore(chat): disable translation until implemented in frontend
1 parent 05bd480 commit 3bc8fec

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

src/askui/chat/api/messages/translator.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
from io import BytesIO
2-
from pathlib import Path
3-
4-
from fastapi import UploadFile
5-
from fastapi.datastructures import Headers
61
from PIL import Image
72

83
from askui.chat.api.files.service import FileService
@@ -13,7 +8,6 @@
138
MessageParam,
149
ToolResultBlockParam,
1510
)
16-
from askui.logger import logger
1711
from askui.models.shared.agent_message_param import (
1812
Base64ImageSourceParam,
1913
TextBlockParam,
@@ -31,7 +25,7 @@
3125
from askui.models.shared.agent_message_param import (
3226
ToolResultBlockParam as AnthropicToolResultBlockParam,
3327
)
34-
from askui.utils.image_utils import base64_to_image, image_to_base64
28+
from askui.utils.image_utils import image_to_base64
3529

3630

3731
class ImageBlockParamSourceTranslator:
@@ -44,26 +38,28 @@ async def from_anthropic(
4438
if source.type == "url":
4539
return source
4640
if source.type == "base64": # noqa: RET503
47-
try:
48-
image = base64_to_image(source.data)
49-
bytes_io = BytesIO()
50-
image.save(bytes_io, format="PNG")
51-
bytes_io.seek(0)
52-
file = await self._file_service.upload_file(
53-
file=UploadFile(
54-
file=bytes_io,
55-
headers=Headers(
56-
{
57-
"Content-Type": "image/png",
58-
}
59-
),
60-
)
61-
)
62-
except Exception as e: # noqa: BLE001
63-
logger.warning(f"Failed to save image: {e}", exc_info=True)
64-
return source
65-
else:
66-
return FileImageSourceParam(id=file.id, type="file")
41+
# Readd translation to FileImageSourceParam as soon as we support it in frontend
42+
return source
43+
# try:
44+
# image = base64_to_image(source.data)
45+
# bytes_io = BytesIO()
46+
# image.save(bytes_io, format="PNG")
47+
# bytes_io.seek(0)
48+
# file = await self._file_service.upload_file(
49+
# file=UploadFile(
50+
# file=bytes_io,
51+
# headers=Headers(
52+
# {
53+
# "Content-Type": "image/png",
54+
# }
55+
# ),
56+
# )
57+
# )
58+
# except Exception as e: # noqa: BLE001
59+
# logger.warning(f"Failed to save image: {e}", exc_info=True)
60+
# return source
61+
# else:
62+
# return FileImageSourceParam(id=file.id, type="file")
6763

6864
async def to_anthropic(
6965
self,

0 commit comments

Comments
 (0)