agentscope-runtime 0.1.6__py3-none-any.whl → 0.2.0__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.
- agentscope_runtime/common/container_clients/__init__.py +0 -0
- agentscope_runtime/{sandbox/manager → common}/container_clients/kubernetes_client.py +546 -6
- agentscope_runtime/engine/__init__.py +12 -0
- agentscope_runtime/engine/agents/agentscope_agent.py +130 -10
- agentscope_runtime/engine/agents/agno_agent.py +8 -10
- agentscope_runtime/engine/agents/langgraph_agent.py +52 -9
- agentscope_runtime/engine/app/__init__.py +6 -0
- agentscope_runtime/engine/app/agent_app.py +239 -0
- agentscope_runtime/engine/app/base_app.py +181 -0
- agentscope_runtime/engine/app/celery_mixin.py +92 -0
- agentscope_runtime/engine/deployers/__init__.py +13 -0
- agentscope_runtime/engine/deployers/adapter/responses/__init__.py +0 -0
- agentscope_runtime/engine/deployers/adapter/responses/response_api_adapter_utils.py +2890 -0
- agentscope_runtime/engine/deployers/adapter/responses/response_api_agent_adapter.py +51 -0
- agentscope_runtime/engine/deployers/adapter/responses/response_api_protocol_adapter.py +314 -0
- agentscope_runtime/engine/deployers/base.py +1 -0
- agentscope_runtime/engine/deployers/cli_fc_deploy.py +203 -0
- agentscope_runtime/engine/deployers/kubernetes_deployer.py +272 -0
- agentscope_runtime/engine/deployers/local_deployer.py +414 -501
- agentscope_runtime/engine/deployers/modelstudio_deployer.py +838 -0
- agentscope_runtime/engine/deployers/utils/__init__.py +0 -0
- agentscope_runtime/engine/deployers/utils/deployment_modes.py +14 -0
- agentscope_runtime/engine/deployers/utils/docker_image_utils/__init__.py +8 -0
- agentscope_runtime/engine/deployers/utils/docker_image_utils/docker_image_builder.py +429 -0
- agentscope_runtime/engine/deployers/utils/docker_image_utils/dockerfile_generator.py +240 -0
- agentscope_runtime/engine/deployers/utils/docker_image_utils/runner_image_factory.py +306 -0
- agentscope_runtime/engine/deployers/utils/package_project_utils.py +1163 -0
- agentscope_runtime/engine/deployers/utils/service_utils/__init__.py +9 -0
- agentscope_runtime/engine/deployers/utils/service_utils/fastapi_factory.py +1064 -0
- agentscope_runtime/engine/deployers/utils/service_utils/fastapi_templates.py +157 -0
- agentscope_runtime/engine/deployers/utils/service_utils/process_manager.py +268 -0
- agentscope_runtime/engine/deployers/utils/service_utils/service_config.py +75 -0
- agentscope_runtime/engine/deployers/utils/service_utils/service_factory.py +220 -0
- agentscope_runtime/engine/deployers/utils/service_utils/standalone_main.py.j2 +211 -0
- agentscope_runtime/engine/deployers/utils/wheel_packager.py +389 -0
- agentscope_runtime/engine/helpers/agent_api_builder.py +651 -0
- agentscope_runtime/engine/runner.py +76 -35
- agentscope_runtime/engine/schemas/agent_schemas.py +112 -2
- agentscope_runtime/engine/schemas/embedding.py +37 -0
- agentscope_runtime/engine/schemas/modelstudio_llm.py +310 -0
- agentscope_runtime/engine/schemas/oai_llm.py +538 -0
- agentscope_runtime/engine/schemas/realtime.py +254 -0
- agentscope_runtime/engine/services/tablestore_memory_service.py +4 -1
- agentscope_runtime/engine/tracing/__init__.py +9 -3
- agentscope_runtime/engine/tracing/asyncio_util.py +24 -0
- agentscope_runtime/engine/tracing/base.py +66 -34
- agentscope_runtime/engine/tracing/local_logging_handler.py +45 -31
- agentscope_runtime/engine/tracing/message_util.py +528 -0
- agentscope_runtime/engine/tracing/tracing_metric.py +20 -8
- agentscope_runtime/engine/tracing/tracing_util.py +130 -0
- agentscope_runtime/engine/tracing/wrapper.py +794 -169
- agentscope_runtime/sandbox/box/base/base_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/browser/browser_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/dummy/dummy_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/gui/gui_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/training_box/training_box.py +0 -42
- agentscope_runtime/sandbox/client/http_client.py +52 -18
- agentscope_runtime/sandbox/constant.py +3 -0
- agentscope_runtime/sandbox/custom/custom_sandbox.py +2 -1
- agentscope_runtime/sandbox/custom/example.py +2 -1
- agentscope_runtime/sandbox/enums.py +0 -1
- agentscope_runtime/sandbox/manager/sandbox_manager.py +29 -22
- agentscope_runtime/sandbox/model/container.py +6 -0
- agentscope_runtime/sandbox/registry.py +1 -1
- agentscope_runtime/sandbox/tools/tool.py +4 -0
- agentscope_runtime/version.py +1 -1
- {agentscope_runtime-0.1.6.dist-info → agentscope_runtime-0.2.0.dist-info}/METADATA +103 -59
- {agentscope_runtime-0.1.6.dist-info → agentscope_runtime-0.2.0.dist-info}/RECORD +87 -52
- {agentscope_runtime-0.1.6.dist-info → agentscope_runtime-0.2.0.dist-info}/entry_points.txt +1 -0
- /agentscope_runtime/{sandbox/manager/container_clients → common}/__init__.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/__init__.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_mapping.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_mapping.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_mapping.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/container_clients/agentrun_client.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/container_clients/base_client.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/container_clients/docker_client.py +0 -0
- {agentscope_runtime-0.1.6.dist-info → agentscope_runtime-0.2.0.dist-info}/WHEEL +0 -0
- {agentscope_runtime-0.1.6.dist-info → agentscope_runtime-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {agentscope_runtime-0.1.6.dist-info → agentscope_runtime-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -9,7 +9,8 @@ from typing import Any, Dict, Optional
|
|
|
9
9
|
|
|
10
10
|
from pydantic import BaseModel
|
|
11
11
|
|
|
12
|
-
from .
|
|
12
|
+
from . import TracingUtil
|
|
13
|
+
from .base import TracerHandler
|
|
13
14
|
|
|
14
15
|
DEFAULT_LOG_NAME = "agentscope-runtime"
|
|
15
16
|
|
|
@@ -64,7 +65,11 @@ class JsonFormatter(logging.Formatter):
|
|
|
64
65
|
"code": getattr(record, "code", None),
|
|
65
66
|
"message": record.getMessage(),
|
|
66
67
|
"task_id": getattr(record, "task_id", None),
|
|
67
|
-
"request_id": getattr(
|
|
68
|
+
"request_id": getattr(
|
|
69
|
+
record,
|
|
70
|
+
"request_id",
|
|
71
|
+
TracingUtil.get_request_id(),
|
|
72
|
+
),
|
|
68
73
|
"context": getattr(record, "context", None),
|
|
69
74
|
"interval": getattr(record, "interval", None),
|
|
70
75
|
"ds_service_id": DS_SVC_ID,
|
|
@@ -88,7 +93,6 @@ class LocalLogHandler(TracerHandler):
|
|
|
88
93
|
max_bytes: int = 1024 * 1024 * 1024,
|
|
89
94
|
backup_count: int = 7,
|
|
90
95
|
enable_console: bool = False,
|
|
91
|
-
propagate: bool = False,
|
|
92
96
|
**kwargs: Any,
|
|
93
97
|
) -> None:
|
|
94
98
|
"""Initialize the llm chat log handler.
|
|
@@ -103,17 +107,12 @@ class LocalLogHandler(TracerHandler):
|
|
|
103
107
|
backup_count (int): Number of log files to keep. Defaults to 7.
|
|
104
108
|
enable_console (bool): Whether to enable console logging.
|
|
105
109
|
Defaults to False.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Defaults to False.
|
|
109
|
-
**kwargs (Any): Additional keyword arguments.
|
|
110
|
+
**kwargs (Any): Additional keyword arguments (unused but kept for
|
|
111
|
+
compatibility).
|
|
110
112
|
"""
|
|
113
|
+
# Store kwargs for potential future use
|
|
114
|
+
self._extra_kwargs = kwargs
|
|
111
115
|
self.logger = logging.getLogger(DEFAULT_LOG_NAME)
|
|
112
|
-
# Set propagate attribute to control log message propagation
|
|
113
|
-
# Note: Python logging propagate defaults to True, we set it to
|
|
114
|
-
# False by default
|
|
115
|
-
self.logger.propagate = propagate
|
|
116
|
-
|
|
117
116
|
if enable_console:
|
|
118
117
|
handler = logging.StreamHandler()
|
|
119
118
|
handler.setFormatter(JsonFormatter())
|
|
@@ -127,7 +126,6 @@ class LocalLogHandler(TracerHandler):
|
|
|
127
126
|
)
|
|
128
127
|
|
|
129
128
|
self.logger.setLevel(log_level)
|
|
130
|
-
self.kwargs = kwargs
|
|
131
129
|
|
|
132
130
|
def _set_file_handle(
|
|
133
131
|
self,
|
|
@@ -188,6 +186,9 @@ class LocalLogHandler(TracerHandler):
|
|
|
188
186
|
original (Dict[str, Any]): The original dictionary to update.
|
|
189
187
|
update (Dict[str, Any]): The dictionary containing updates.
|
|
190
188
|
"""
|
|
189
|
+
if not isinstance(original, dict):
|
|
190
|
+
return
|
|
191
|
+
|
|
191
192
|
for key, value in update.items():
|
|
192
193
|
if (
|
|
193
194
|
isinstance(value, dict)
|
|
@@ -200,19 +201,19 @@ class LocalLogHandler(TracerHandler):
|
|
|
200
201
|
|
|
201
202
|
def on_start(
|
|
202
203
|
self,
|
|
203
|
-
|
|
204
|
+
event_name: str,
|
|
204
205
|
payload: Dict[str, Any],
|
|
205
206
|
**kwargs: Any,
|
|
206
207
|
) -> None:
|
|
207
208
|
"""Handle the start of a trace event.
|
|
208
209
|
|
|
209
210
|
Args:
|
|
210
|
-
|
|
211
|
+
event_name (str): The name of event being traced.
|
|
211
212
|
payload (Dict[str, Any]): The payload data for the event.
|
|
212
213
|
**kwargs (Any): Additional keyword arguments.
|
|
213
214
|
"""
|
|
214
|
-
step = f"{
|
|
215
|
-
request_id =
|
|
215
|
+
step = f"{event_name}_start"
|
|
216
|
+
request_id = TracingUtil.get_request_id()
|
|
216
217
|
context = payload.get("context", payload)
|
|
217
218
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
|
|
218
219
|
interval = {"type": step, "cost": 0}
|
|
@@ -236,27 +237,32 @@ class LocalLogHandler(TracerHandler):
|
|
|
236
237
|
|
|
237
238
|
def on_end(
|
|
238
239
|
self,
|
|
239
|
-
|
|
240
|
+
event_name: str,
|
|
240
241
|
start_payload: Dict[str, Any],
|
|
241
|
-
end_payload:
|
|
242
|
+
end_payload: Any,
|
|
242
243
|
start_time: float,
|
|
243
244
|
**kwargs: Any,
|
|
244
245
|
) -> None:
|
|
245
246
|
"""Handle the end of a trace event.
|
|
246
247
|
|
|
247
248
|
Args:
|
|
248
|
-
|
|
249
|
+
event_name (str): The name of event being traced.
|
|
249
250
|
start_payload (Dict[str, Any]): The payload data from event start.
|
|
250
|
-
end_payload (
|
|
251
|
+
end_payload (Any): The payload data from event end.
|
|
251
252
|
start_time (float): The timestamp when the event started.
|
|
252
253
|
**kwargs (Any): Additional keyword arguments.
|
|
253
254
|
"""
|
|
254
255
|
|
|
255
|
-
|
|
256
|
+
request_id = TracingUtil.get_request_id()
|
|
257
|
+
|
|
258
|
+
if isinstance(end_payload, dict):
|
|
259
|
+
context = end_payload
|
|
260
|
+
else:
|
|
261
|
+
context = {}
|
|
262
|
+
if end_payload is not None:
|
|
263
|
+
context["output"] = end_payload
|
|
256
264
|
|
|
257
|
-
step = f"{
|
|
258
|
-
request_id = end_payload.get("request_id", "")
|
|
259
|
-
context = end_payload.get("context", end_payload)
|
|
265
|
+
step = f"{event_name}_end"
|
|
260
266
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
|
|
261
267
|
duration = time.time() - start_time
|
|
262
268
|
interval = {"type": step, "cost": f"{duration:.3f}"}
|
|
@@ -287,14 +293,14 @@ class LocalLogHandler(TracerHandler):
|
|
|
287
293
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
|
|
288
294
|
if "step_suffix" in kwargs:
|
|
289
295
|
step_suffix = kwargs["step_suffix"]
|
|
290
|
-
|
|
296
|
+
event_name = kwargs["event_name"]
|
|
291
297
|
payload = kwargs["payload"]
|
|
292
298
|
start_time = kwargs["start_time"]
|
|
293
299
|
start_payload = kwargs["start_payload"]
|
|
294
300
|
|
|
295
301
|
LocalLogHandler._deep_update(payload, start_payload)
|
|
296
302
|
|
|
297
|
-
step = f"{
|
|
303
|
+
step = f"{event_name}_{step_suffix}"
|
|
298
304
|
duration = time.time() - start_time
|
|
299
305
|
interval = {"type": step, "cost": f"{duration:.3f}"}
|
|
300
306
|
else:
|
|
@@ -302,12 +308,20 @@ class LocalLogHandler(TracerHandler):
|
|
|
302
308
|
interval = {"type": step, "cost": "0"}
|
|
303
309
|
payload = {}
|
|
304
310
|
|
|
311
|
+
request_id = TracingUtil.get_request_id()
|
|
312
|
+
|
|
313
|
+
if isinstance(payload, dict):
|
|
314
|
+
context = payload
|
|
315
|
+
else:
|
|
316
|
+
context = {"payload": str(payload)}
|
|
317
|
+
|
|
305
318
|
runtime_context = LogContext(
|
|
306
319
|
time=timestamp,
|
|
307
320
|
step=step,
|
|
308
321
|
interval=interval,
|
|
309
|
-
context=
|
|
322
|
+
context=context,
|
|
310
323
|
message=message,
|
|
324
|
+
request_id=request_id,
|
|
311
325
|
)
|
|
312
326
|
self.logger.info(
|
|
313
327
|
runtime_context.message,
|
|
@@ -316,7 +330,7 @@ class LocalLogHandler(TracerHandler):
|
|
|
316
330
|
|
|
317
331
|
def on_error(
|
|
318
332
|
self,
|
|
319
|
-
|
|
333
|
+
event_name: str,
|
|
320
334
|
start_payload: Dict[str, Any],
|
|
321
335
|
error: Exception,
|
|
322
336
|
start_time: float,
|
|
@@ -326,14 +340,14 @@ class LocalLogHandler(TracerHandler):
|
|
|
326
340
|
"""Handle an error during tracing.
|
|
327
341
|
|
|
328
342
|
Args:
|
|
329
|
-
|
|
343
|
+
event_name (str): The name of event being traced.
|
|
330
344
|
start_payload (Dict[str, Any]): The payload data from event start.
|
|
331
345
|
error (Exception): The exception that occurred.
|
|
332
346
|
start_time (float): The timestamp when the event started.
|
|
333
347
|
traceback_info (str): The traceback information.
|
|
334
348
|
**kwargs (Any): Additional keyword arguments.
|
|
335
349
|
"""
|
|
336
|
-
step = f"{
|
|
350
|
+
step = f"{event_name}_error"
|
|
337
351
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
|
|
338
352
|
duration = time.time() - start_time
|
|
339
353
|
interval = {"type": step, "cost": f"{duration:.3f}"}
|