Merged
Conversation
zakahan
requested changes
Aug 22, 2025
zakahan
approved these changes
Aug 22, 2025
| url = messages.media | ||
| if self.agent.tracers: | ||
| tos_handler = TOSHandler() | ||
| url = tos_handler.gen_url( |
| self.user_id, self.app_name, session_id, messages.media | ||
| ) | ||
| asyncio.create_task(tos_handler.upload_to_tos(url, data, "bytes")) | ||
| tos_handler.close_client() |
Collaborator
There was a problem hiding this comment.
may be need a wrapper for upload_to_tos to avoid manually close client?
| class TOSHandler: | ||
| def __init__(self): | ||
| """Initialize TOS configuration information""" | ||
| self.region = getenv("DATABASE_TOS_REGION") |
Collaborator
There was a problem hiding this comment.
class TOSHandlerConfig(BaseModel)
| return f".{candidate.lower()}" | ||
| return f".{parts[-1].lower()}" | ||
|
|
||
| def gen_url( |
Collaborator
There was a problem hiding this comment.
use build_url here, as other places use build
| config: TOSConfig = Field(default_factory=TOSConfig) | ||
| client: Optional[Any] = Field(default=None, description="TOS client instance") | ||
|
|
||
| def __init__(self, **data: Any): |
Collaborator
There was a problem hiding this comment.
model_post_init
self._client
| self, | ||
| object_key: str, | ||
| data: Union[str, bytes], | ||
| data_type: Literal["file", "bytes"], |
Collaborator
There was a problem hiding this comment.
remove this arg, check it by code
|
|
||
| def __init__(self, **data: Any): | ||
| super().__init__(**data) | ||
| self.client = self._init() |
Collaborator
There was a problem hiding this comment.
health check
logger.info
| return False | ||
|
|
||
| def _do_upload_file(self, object_key: str, file_path: str) -> bool: | ||
| client = self._init_tos_client() |
| ) | ||
|
|
||
| def _convert_messages(self, messages) -> list: | ||
| def _build_object_key( |
Collaborator
There was a problem hiding this comment.
_build_tos_object_key
yaozheng-fang
approved these changes
Aug 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add toshandler