agentscope-runtime 1.1.0b2__py3-none-any.whl → 1.1.0b3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,9 @@
4
4
  import json
5
5
 
6
6
  from collections import OrderedDict
7
- from typing import Union, List, Callable, Optional, Dict
7
+ from typing import Union, List, Callable, Optional, Dict, Literal
8
8
  from urllib.parse import urlparse
9
+ from typing_extensions import TypedDict, Required
9
10
 
10
11
  from mcp.types import CallToolResult
11
12
  from agentscope.message import (
@@ -28,6 +29,20 @@ from ...engine.schemas.agent_schemas import (
28
29
  )
29
30
 
30
31
 
32
+ # TODO: support in core framework
33
+ class FileBlock(TypedDict, total=False):
34
+ """The file block"""
35
+
36
+ type: Required[Literal["file"]]
37
+ """The type of the block"""
38
+
39
+ source: Required[Base64Source | URLSource]
40
+ """The src of the file"""
41
+
42
+ filename: Optional[str]
43
+ """Optional filename hint (e.g. `report.pdf`)"""
44
+
45
+
31
46
  def matches_typed_dict_structure(obj, typed_dict_cls):
32
47
  if not isinstance(obj, dict):
33
48
  return False
@@ -193,6 +208,7 @@ def message_to_agentscope_msg(
193
208
  "audio": (AudioBlock, "data"),
194
209
  "data": (TextBlock, "data"),
195
210
  "video": (VideoBlock, "video_url"),
211
+ "file": (FileBlock, "file_url"),
196
212
  }
197
213
 
198
214
  msg_content = []
@@ -288,6 +304,39 @@ def message_to_agentscope_msg(
288
304
  msg_content.append(
289
305
  block_cls(type=cnt_type, source=url_source),
290
306
  )
307
+ elif cnt_type == "file":
308
+ filename = cnt.filename
309
+ if (
310
+ value
311
+ and isinstance(value, str)
312
+ and value.startswith("data:")
313
+ ):
314
+ mediatype_part = value.split(";")[0].replace(
315
+ "data:",
316
+ "",
317
+ )
318
+ base64_data = value.split(",")[1]
319
+ base64_source = Base64Source(
320
+ type="base64",
321
+ media_type=mediatype_part,
322
+ data=base64_data,
323
+ )
324
+ msg_content.append(
325
+ block_cls(
326
+ type=cnt_type,
327
+ source=base64_source,
328
+ filename=filename,
329
+ ),
330
+ )
331
+ else:
332
+ url_source = URLSource(type="url", url=value)
333
+ msg_content.append(
334
+ block_cls(
335
+ type=cnt_type,
336
+ source=url_source,
337
+ filename=filename,
338
+ ),
339
+ )
291
340
  else:
292
341
  # text & data
293
342
  if isinstance(value, str):
@@ -19,6 +19,7 @@ from ...engine.schemas.agent_schemas import (
19
19
  AudioContent,
20
20
  VideoContent,
21
21
  DataContent,
22
+ FileContent,
22
23
  McpCall,
23
24
  McpCallOutput,
24
25
  FunctionCall,
@@ -518,7 +519,7 @@ async def adapt_agentscope_message_stream(
518
519
  index=index,
519
520
  **kwargs,
520
521
  )
521
- elif element.get("text") == "audio":
522
+ elif element.get("type") == "audio":
522
523
  kwargs = {}
523
524
  if (
524
525
  isinstance(element.get("source"), dict)
@@ -602,6 +603,48 @@ async def adapt_agentscope_message_stream(
602
603
  index=index,
603
604
  **kwargs,
604
605
  )
606
+ elif element.get("type") == "file":
607
+ kwargs = {
608
+ "filename": element.get("filename"),
609
+ }
610
+ if (
611
+ isinstance(element.get("source"), dict)
612
+ and element.get("source", {}).get(
613
+ "type",
614
+ )
615
+ == "url"
616
+ ):
617
+ kwargs.update(
618
+ {
619
+ "file_url": element.get(
620
+ "source",
621
+ {},
622
+ ).get("url"),
623
+ },
624
+ )
625
+
626
+ elif (
627
+ isinstance(element.get("source"), dict)
628
+ and element.get("source").get(
629
+ "type",
630
+ )
631
+ == "base64"
632
+ ):
633
+ media_type = element.get("source", {}).get(
634
+ "media_type",
635
+ "application/octet-stream",
636
+ )
637
+ base64_data = element.get("source", {}).get(
638
+ "data",
639
+ "",
640
+ )
641
+ url = f"data:{media_type};base64,{base64_data}"
642
+ kwargs.update({"file_url": url})
643
+ delta_content = FileContent(
644
+ delta=True,
645
+ index=index,
646
+ **kwargs,
647
+ )
605
648
  else:
606
649
  delta_content = TextContent(
607
650
  delta=True,
@@ -1,2 +1,2 @@
1
1
  # -*- coding: utf-8 -*-
2
- __version__ = "v1.1.0b2"
2
+ __version__ = "v1.1.0b3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentscope-runtime
3
- Version: 1.1.0b2
3
+ Version: 1.1.0b3
4
4
  Summary: A production-ready runtime framework for agent applications, providing secure sandboxed execution environments and scalable deployment solutions with multi-framework support.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -743,7 +743,7 @@ limitations under the License.
743
743
 
744
744
  ## ✨ Contributors
745
745
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
746
- [![All Contributors](https://img.shields.io/badge/all_contributors-34-orange.svg?style=flat-square)](#contributors-)
746
+ [![All Contributors](https://img.shields.io/badge/all_contributors-35-orange.svg?style=flat-square)](#contributors-)
747
747
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
748
748
 
749
749
  Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/emoji-key/)):
@@ -796,6 +796,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/e
796
796
  <td align="center" valign="top" width="14.28%"><a href="http://dorianzheng.github.io"><img src="https://avatars.githubusercontent.com/u/8065637?v=4?s=100" width="100px;" alt="dorianzheng"/><br /><sub><b>dorianzheng</b></sub></a><br /><a href="https://github.com/agentscope-ai/agentscope-runtime/pulls?q=is%3Apr+reviewed-by%3ADorianZheng" title="Reviewed Pull Requests">👀</a> <a href="#platform-DorianZheng" title="Packaging/porting to new platform">📦</a></td>
797
797
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/cainiao1992"><img src="https://avatars.githubusercontent.com/u/18435004?v=4?s=100" width="100px;" alt="Xiangfang Chen"/><br /><sub><b>Xiangfang Chen</b></sub></a><br /><a href="https://github.com/agentscope-ai/agentscope-runtime/commits?author=cainiao1992" title="Documentation">📖</a></td>
798
798
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/Eggiverse"><img src="https://avatars.githubusercontent.com/u/36877740?v=4?s=100" width="100px;" alt="Zhang Shitian"/><br /><sub><b>Zhang Shitian</b></sub></a><br /><a href="https://github.com/agentscope-ai/agentscope-runtime/issues?q=author%3AEggiverse" title="Bug reports">🐛</a> <a href="https://github.com/agentscope-ai/agentscope-runtime/commits?author=Eggiverse" title="Code">💻</a></td>
799
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Shun-Chu"><img src="https://avatars.githubusercontent.com/u/73324318?v=4?s=100" width="100px;" alt="Chuss"/><br /><sub><b>Chuss</b></sub></a><br /><a href="https://github.com/agentscope-ai/agentscope-runtime/issues?q=author%3AShun-Chu" title="Bug reports">🐛</a></td>
799
800
  </tr>
800
801
  </tbody>
801
802
  <tfoot>
@@ -1,10 +1,10 @@
1
1
  agentscope_runtime/__init__.py,sha256=a_5aBl8PX21Kv54vwJsu5vera_RrNTUeAsSnwlQLaXo,147
2
- agentscope_runtime/version.py,sha256=c4bDZMe8UULrmKNz6-f5_fGXwi6ZL2u4xND_7u_mAvs,49
2
+ agentscope_runtime/version.py,sha256=9FOOdYI0Y47t1oRrH25ZmP0ZL6Eh1HVZ8arME4zflDw,49
3
3
  agentscope_runtime/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  agentscope_runtime/adapters/utils.py,sha256=lL6RrSwxyj2WHWgUaCtscbP9aD_Rf3UY_FCtDPJ_ISI,180
5
5
  agentscope_runtime/adapters/agentscope/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- agentscope_runtime/adapters/agentscope/message.py,sha256=qPZYfUEwaQ7De6cDUowTFxFw_jhi9EVBfXAD5w4mLFE,13031
7
- agentscope_runtime/adapters/agentscope/stream.py,sha256=mapHtmhQAc6r4OXlaKA1P7nCE7jzqTyICgvBIbGsbpg,26983
6
+ agentscope_runtime/adapters/agentscope/message.py,sha256=ubww3cNY0wVbJKvn2uFftMOo5PxgnjvHejGUI8OmIhc,14862
7
+ agentscope_runtime/adapters/agentscope/stream.py,sha256=QL_C49y65Odp-A_SqiFOPt9cQscFiMPWhgDj33ZRO9I,29005
8
8
  agentscope_runtime/adapters/agentscope/tool/__init__.py,sha256=wrBKu2FidSJuGBuhy2BEG0Xy9J9pZldtHxsKBs3iWQ0,249
9
9
  agentscope_runtime/adapters/agentscope/tool/sandbox_tool.py,sha256=amwtmhtCXDw9TVMUNFiFakNsfj3pp4fllHCBEXzvSEE,2002
10
10
  agentscope_runtime/adapters/agentscope/tool/tool.py,sha256=rgANo-1fByWIlyQk1Bmhscas3QVCVgDuSLMT1XFX76M,7235
@@ -275,9 +275,9 @@ agentscope_runtime/tools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
275
275
  agentscope_runtime/tools/utils/api_key_util.py,sha256=xIIUsvWgSt4etgYP7lS0WnqVIhZ-REzrBLwzAT-TrVI,1210
276
276
  agentscope_runtime/tools/utils/crypto_utils.py,sha256=Wqq4cn3FHQge-2Q1zGSMUyKh4V4A2baiZm8ZNhMqhPo,3382
277
277
  agentscope_runtime/tools/utils/mcp_util.py,sha256=n3GGKBEQPJ-fiNXdYnBx_90GVKWvm9eaNbR2G0q2lOw,905
278
- agentscope_runtime-1.1.0b2.dist-info/licenses/LICENSE,sha256=3MckDTgiTJ0E6cxo8FeamFVEFiwz3XJWsriuTtRJzxY,11337
279
- agentscope_runtime-1.1.0b2.dist-info/METADATA,sha256=lt5y_TxJUMU7xkcLq1CbF8-LmZwnDpZQGxI3pYeapBg,48668
280
- agentscope_runtime-1.1.0b2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
281
- agentscope_runtime-1.1.0b2.dist-info/entry_points.txt,sha256=Mpjpwe0A9lYNsFtWe_VeoGhtDVsKLIi6w9ZKzyhc17M,425
282
- agentscope_runtime-1.1.0b2.dist-info/top_level.txt,sha256=0YHketA7WcMmRmF-3lUzedeTOnP7iL77h-ekb-iG720,19
283
- agentscope_runtime-1.1.0b2.dist-info/RECORD,,
278
+ agentscope_runtime-1.1.0b3.dist-info/licenses/LICENSE,sha256=3MckDTgiTJ0E6cxo8FeamFVEFiwz3XJWsriuTtRJzxY,11337
279
+ agentscope_runtime-1.1.0b3.dist-info/METADATA,sha256=UJ8v1FXHj-Q2CUB2Ff0pLKevHZYdezOpzVxSQ4ozfuA,49019
280
+ agentscope_runtime-1.1.0b3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
281
+ agentscope_runtime-1.1.0b3.dist-info/entry_points.txt,sha256=Mpjpwe0A9lYNsFtWe_VeoGhtDVsKLIi6w9ZKzyhc17M,425
282
+ agentscope_runtime-1.1.0b3.dist-info/top_level.txt,sha256=0YHketA7WcMmRmF-3lUzedeTOnP7iL77h-ekb-iG720,19
283
+ agentscope_runtime-1.1.0b3.dist-info/RECORD,,