Skip to content

Commit 2a66167

Browse files
author
lmh
committed
fix: async upload
1 parent fb94d8e commit 2a66167

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

volcenginesdkarkruntime/resources/responses/responses.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
)
1919

2020
import httpx
21+
import asyncio
2122
from typing_extensions import Literal
2223
from urllib.parse import urlparse, unquote_plus
2324
from ..._types import Body, Query, Headers
@@ -38,6 +39,7 @@
3839
from ...types.responses.tool_param import ToolParam
3940
from ...types.responses.response_input_param import (
4041
ResponseInputParam,
42+
ResponseInputItemParam,
4143
)
4244
from ...types.responses.response_input_message_content_list_param import (
4345
ResponseInputContentParam,
@@ -325,6 +327,7 @@ async def delete(
325327
)
326328

327329
async def _prepare_responses_input(self, input: ResponseInputParam):
330+
tasks = []
328331
for input_item in input: # type: ResponseInputItemParam
329332
if "content" not in input_item: # skip non-content message
330333
continue
@@ -334,7 +337,9 @@ async def _prepare_responses_input(self, input: ResponseInputParam):
334337
continue
335338

336339
for content in content_list: # type: ResponseInputContentParam
337-
await self._prepare_responses_input_file(content=content)
340+
tasks.append(self._prepare_responses_input_file(content=content))
341+
342+
await asyncio.gather(*tasks)
338343

339344
async def _prepare_responses_input_file(self, content: ResponseInputContentParam):
340345
if "type" not in content: # skip non-type content

0 commit comments

Comments
 (0)