agstack 1.20.0__tar.gz → 1.21.1__tar.gz

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.
Files changed (77) hide show
  1. {agstack-1.20.0 → agstack-1.21.1}/PKG-INFO +1 -1
  2. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/agent.py +27 -3
  3. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/tool.py +25 -2
  4. {agstack-1.20.0 → agstack-1.21.1}/agstack.egg-info/PKG-INFO +1 -1
  5. {agstack-1.20.0 → agstack-1.21.1}/pyproject.toml +1 -1
  6. {agstack-1.20.0 → agstack-1.21.1}/LICENSE +0 -0
  7. {agstack-1.20.0 → agstack-1.21.1}/README.md +0 -0
  8. {agstack-1.20.0 → agstack-1.21.1}/agstack/__init__.py +0 -0
  9. {agstack-1.20.0 → agstack-1.21.1}/agstack/cache/__init__.py +0 -0
  10. {agstack-1.20.0 → agstack-1.21.1}/agstack/cache/base.py +0 -0
  11. {agstack-1.20.0 → agstack-1.21.1}/agstack/cache/memory.py +0 -0
  12. {agstack-1.20.0 → agstack-1.21.1}/agstack/cache/redis.py +0 -0
  13. {agstack-1.20.0 → agstack-1.21.1}/agstack/config/__init__.py +0 -0
  14. {agstack-1.20.0 → agstack-1.21.1}/agstack/config/logger.py +0 -0
  15. {agstack-1.20.0 → agstack-1.21.1}/agstack/config/manager.py +0 -0
  16. {agstack-1.20.0 → agstack-1.21.1}/agstack/config/types.py +0 -0
  17. {agstack-1.20.0 → agstack-1.21.1}/agstack/contexts.py +0 -0
  18. {agstack-1.20.0 → agstack-1.21.1}/agstack/decorators.py +0 -0
  19. {agstack-1.20.0 → agstack-1.21.1}/agstack/events.py +0 -0
  20. {agstack-1.20.0 → agstack-1.21.1}/agstack/exceptions.py +0 -0
  21. {agstack-1.20.0 → agstack-1.21.1}/agstack/fastapi/__init__.py +0 -0
  22. {agstack-1.20.0 → agstack-1.21.1}/agstack/fastapi/exception.py +0 -0
  23. {agstack-1.20.0 → agstack-1.21.1}/agstack/fastapi/middleware.py +0 -0
  24. {agstack-1.20.0 → agstack-1.21.1}/agstack/fastapi/offline.py +0 -0
  25. {agstack-1.20.0 → agstack-1.21.1}/agstack/fastapi/sse.py +0 -0
  26. {agstack-1.20.0 → agstack-1.21.1}/agstack/infra/db/__init__.py +0 -0
  27. {agstack-1.20.0 → agstack-1.21.1}/agstack/infra/es/__init__.py +0 -0
  28. {agstack-1.20.0 → agstack-1.21.1}/agstack/infra/kg/__init__.py +0 -0
  29. {agstack-1.20.0 → agstack-1.21.1}/agstack/infra/mq/__init__.py +0 -0
  30. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/__init__.py +0 -0
  31. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/client.py +0 -0
  32. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/__init__.py +0 -0
  33. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/context.py +0 -0
  34. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/event.py +0 -0
  35. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/exceptions.py +0 -0
  36. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/factory.py +0 -0
  37. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/flow.py +0 -0
  38. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/loader.py +0 -0
  39. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/__init__.py +0 -0
  40. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/agent_node.py +0 -0
  41. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/base.py +0 -0
  42. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/detect_node.py +0 -0
  43. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/echo_node.py +0 -0
  44. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/llm_chat_node.py +0 -0
  45. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/llm_embed_node.py +0 -0
  46. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/llm_rerank_node.py +0 -0
  47. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/python_node.py +0 -0
  48. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/subflow_node.py +0 -0
  49. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/switch_node.py +0 -0
  50. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/nodes/tool_node.py +0 -0
  51. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/records.py +0 -0
  52. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/registry.py +0 -0
  53. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/sandbox.py +0 -0
  54. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/state.py +0 -0
  55. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/flow/trace.py +0 -0
  56. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/prompts.py +0 -0
  57. {agstack-1.20.0 → agstack-1.21.1}/agstack/llm/token.py +0 -0
  58. {agstack-1.20.0 → agstack-1.21.1}/agstack/messagebus/__init__.py +0 -0
  59. {agstack-1.20.0 → agstack-1.21.1}/agstack/messagebus/base.py +0 -0
  60. {agstack-1.20.0 → agstack-1.21.1}/agstack/messagebus/memory.py +0 -0
  61. {agstack-1.20.0 → agstack-1.21.1}/agstack/messagebus/redis.py +0 -0
  62. {agstack-1.20.0 → agstack-1.21.1}/agstack/schema.py +0 -0
  63. {agstack-1.20.0 → agstack-1.21.1}/agstack/security/__init__.py +0 -0
  64. {agstack-1.20.0 → agstack-1.21.1}/agstack/security/casbin.py +0 -0
  65. {agstack-1.20.0 → agstack-1.21.1}/agstack/security/crypt.py +0 -0
  66. {agstack-1.20.0 → agstack-1.21.1}/agstack/status.py +0 -0
  67. {agstack-1.20.0 → agstack-1.21.1}/agstack.egg-info/SOURCES.txt +0 -0
  68. {agstack-1.20.0 → agstack-1.21.1}/agstack.egg-info/dependency_links.txt +0 -0
  69. {agstack-1.20.0 → agstack-1.21.1}/agstack.egg-info/requires.txt +0 -0
  70. {agstack-1.20.0 → agstack-1.21.1}/agstack.egg-info/top_level.txt +0 -0
  71. {agstack-1.20.0 → agstack-1.21.1}/setup.cfg +0 -0
  72. {agstack-1.20.0 → agstack-1.21.1}/tests/test_cache_memory.py +0 -0
  73. {agstack-1.20.0 → agstack-1.21.1}/tests/test_cache_redis.py +0 -0
  74. {agstack-1.20.0 → agstack-1.21.1}/tests/test_flow_io.py +0 -0
  75. {agstack-1.20.0 → agstack-1.21.1}/tests/test_flow_switch_subflow.py +0 -0
  76. {agstack-1.20.0 → agstack-1.21.1}/tests/test_messagebus_memory.py +0 -0
  77. {agstack-1.20.0 → agstack-1.21.1}/tests/test_messagebus_redis.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agstack
3
- Version: 1.20.0
3
+ Version: 1.21.1
4
4
  Summary: Production-ready toolkit for building FastAPI and LLM applications
5
5
  Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
6
6
  Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
@@ -245,13 +245,13 @@ class Agent:
245
245
  context.add_message(
246
246
  self.name,
247
247
  "tool",
248
- content=json.dumps({"error": error_msg}),
248
+ content=json.dumps({"error": error_msg}, ensure_ascii=False),
249
249
  tool_call_id=tool_call["id"],
250
250
  )
251
251
  # AG-UI: TOOL_CALL_RESULT (错误)
252
252
  yield event.tool_call_result(
253
253
  tool_call_id=tool_call["id"],
254
- content=json.dumps({"error": error_msg}),
254
+ content=json.dumps({"error": error_msg}, ensure_ascii=False),
255
255
  )
256
256
  continue
257
257
 
@@ -261,12 +261,36 @@ class Agent:
261
261
  except json.JSONDecodeError:
262
262
  tool_args = {}
263
263
 
264
+ # 执行前进度事件
265
+ progress_label = tool.get_progress_label(tool_args)
266
+ if progress_label:
267
+ yield event.custom(
268
+ name="skill_progress",
269
+ value={
270
+ "progressId": tool_call["id"],
271
+ "description": progress_label,
272
+ "status": "running",
273
+ },
274
+ )
275
+
264
276
  # 执行工具(传入 LLM 解析的参数作为 inputs)
265
277
  result = await tool.execute_async(context, tool_args)
266
278
 
279
+ # 执行后进度事件
280
+ if progress_label:
281
+ yield event.custom(
282
+ name="skill_progress",
283
+ value={
284
+ "progressId": tool_call["id"],
285
+ "status": "completed" if result.success else "failed",
286
+ },
287
+ )
288
+
267
289
  # 使用 result.content 作为 LLM 上下文(Tool 已计算好)
268
290
  result_content = result.content or (
269
- json.dumps(result.result) if result.success else json.dumps({"error": result.error})
291
+ json.dumps(result.result, ensure_ascii=False)
292
+ if result.success
293
+ else json.dumps({"error": result.error}, ensure_ascii=False)
270
294
  )
271
295
  context.add_message(
272
296
  self.name,
@@ -43,6 +43,7 @@ class Tool:
43
43
  category: str | None = None,
44
44
  summary_fn: Callable[["ToolResult"], str | None] | None = None,
45
45
  result_formatter: Callable[["ToolResult"], str] | None = None,
46
+ progress_label_fn: Callable[[dict[str, Any]], str] | None = None,
46
47
  ):
47
48
  """初始化工具
48
49
 
@@ -55,6 +56,7 @@ class Tool:
55
56
  :param category: 工具分类(retrieval / analysis / action / utility)
56
57
  :param summary_fn: 生成面向用户摘要的函数 (ToolResult) -> str | None
57
58
  :param result_formatter: 自定义 LLM 内容格式化函数 (ToolResult) -> str
59
+ :param progress_label_fn: 基于调用参数生成动态进度描述 (args) -> str
58
60
  """
59
61
  self.name = name
60
62
  self.description = description
@@ -65,6 +67,19 @@ class Tool:
65
67
  self.category = category
66
68
  self.summary_fn = summary_fn
67
69
  self.result_formatter = result_formatter
70
+ self.progress_label_fn = progress_label_fn
71
+
72
+ def get_progress_label(self, args: dict[str, Any]) -> str | None:
73
+ """基于调用参数生成面向用户的动态进度描述
74
+
75
+ 返回 None 时不发送进度事件。
76
+ """
77
+ if self.progress_label_fn:
78
+ try:
79
+ return self.progress_label_fn(args)
80
+ except Exception:
81
+ pass
82
+ return self.label
68
83
 
69
84
  async def execute_async(self, context: "FlowContext", inputs: dict[str, Any] | None = None) -> ToolResult:
70
85
  """异步执行工具(包含计时、摘要生成、结果格式化、可观测性记录)"""
@@ -78,9 +93,17 @@ class Tool:
78
93
  try:
79
94
  result.content = self.result_formatter(result)
80
95
  except Exception:
81
- result.content = json.dumps(result.result) if result.success else json.dumps({"error": result.error})
96
+ result.content = (
97
+ json.dumps(result.result, ensure_ascii=False)
98
+ if result.success
99
+ else json.dumps({"error": result.error}, ensure_ascii=False)
100
+ )
82
101
  else:
83
- result.content = json.dumps(result.result) if result.success else json.dumps({"error": result.error})
102
+ result.content = (
103
+ json.dumps(result.result, ensure_ascii=False)
104
+ if result.success
105
+ else json.dumps({"error": result.error}, ensure_ascii=False)
106
+ )
84
107
 
85
108
  # 生成面向用户的摘要
86
109
  if self.summary_fn:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agstack
3
- Version: 1.20.0
3
+ Version: 1.21.1
4
4
  Summary: Production-ready toolkit for building FastAPI and LLM applications
5
5
  Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
6
6
  Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agstack"
3
- version = "1.20.0"
3
+ version = "1.21.1"
4
4
  description = "Production-ready toolkit for building FastAPI and LLM applications"
5
5
  readme = "README.md"
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes