agently 4.0.7.2__tar.gz → 4.0.7.4__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 (89) hide show
  1. agently-4.0.7.4/PKG-INFO +351 -0
  2. agently-4.0.7.4/README.md +323 -0
  3. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/SessionExtension.py +10 -4
  4. agently-4.0.7.4/agently/core/Session.py +223 -0
  5. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/__init__.py +1 -0
  6. agently-4.0.7.4/agently/integrations/fastapi.py +18 -0
  7. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/Session.py +19 -9
  8. {agently-4.0.7.2 → agently-4.0.7.4}/pyproject.toml +1 -1
  9. agently-4.0.7.2/PKG-INFO +0 -433
  10. agently-4.0.7.2/README.md +0 -405
  11. agently-4.0.7.2/agently/core/Session.py +0 -85
  12. {agently-4.0.7.2 → agently-4.0.7.4}/LICENSE +0 -0
  13. {agently-4.0.7.2 → agently-4.0.7.4}/agently/__init__.py +0 -0
  14. {agently-4.0.7.2 → agently-4.0.7.4}/agently/_default_init.py +0 -0
  15. {agently-4.0.7.2 → agently-4.0.7.4}/agently/_default_settings.yaml +0 -0
  16. {agently-4.0.7.2 → agently-4.0.7.4}/agently/base.py +0 -0
  17. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/AutoFuncExtension.py +0 -0
  18. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/ChatSessionExtension.py +0 -0
  19. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/ConfigurePromptExtension.py +0 -0
  20. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/KeyWaiterExtension.py +0 -0
  21. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/ToolExtension.py +0 -0
  22. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/agent_extensions/__init__.py +0 -0
  23. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/hookers/ConsoleHooker.py +0 -0
  24. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/hookers/PureLoggerHooker.py +0 -0
  25. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/hookers/SystemMessageHooker.py +0 -0
  26. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/plugins/ModelRequester/OpenAICompatible.py +0 -0
  27. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/plugins/PromptGenerator/AgentlyPromptGenerator.py +0 -0
  28. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/plugins/ResponseParser/AgentlyResponseParser.py +0 -0
  29. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/plugins/Session/AgentlyMemoSession.py +0 -0
  30. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/plugins/ToolManager/AgentlyToolManager.py +0 -0
  31. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/plugins/__init__.py +0 -0
  32. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/tools/Browse.py +0 -0
  33. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/tools/Cmd.py +0 -0
  34. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/tools/Search.py +0 -0
  35. {agently-4.0.7.2 → agently-4.0.7.4}/agently/builtins/tools/__init__.py +0 -0
  36. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/Agent.py +0 -0
  37. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/EventCenter.py +0 -0
  38. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/ExtensionHandlers.py +0 -0
  39. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/ModelRequest.py +0 -0
  40. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/PluginManager.py +0 -0
  41. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/Prompt.py +0 -0
  42. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/Tool.py +0 -0
  43. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/BluePrint.py +0 -0
  44. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/Chunk.py +0 -0
  45. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/Execution.py +0 -0
  46. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/Process.py +0 -0
  47. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/TriggerFlow.py +0 -0
  48. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/__init__.py +0 -0
  49. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/process/BaseProcess.py +0 -0
  50. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/process/ForEachProcess.py +0 -0
  51. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/process/MatchCaseProcess.py +0 -0
  52. {agently-4.0.7.2 → agently-4.0.7.4}/agently/core/TriggerFlow/process/__init__.py +0 -0
  53. {agently-4.0.7.2 → agently-4.0.7.4}/agently/integrations/chromadb.py +0 -0
  54. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/__init__.py +0 -0
  55. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/__init__.py +0 -0
  56. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/event.py +0 -0
  57. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/prompt.py +0 -0
  58. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/request.py +0 -0
  59. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/response.py +0 -0
  60. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/serializable.py +0 -0
  61. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/data/tool.py +0 -0
  62. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/BuiltInTool.py +0 -0
  63. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/EventHooker.py +0 -0
  64. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/ModelRequester.py +0 -0
  65. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/PromptGenerator.py +0 -0
  66. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/ResponseParser.py +0 -0
  67. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/ToolManager.py +0 -0
  68. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/__init__.py +0 -0
  69. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/plugins/base.py +0 -0
  70. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/trigger_flow/__init__.py +0 -0
  71. {agently-4.0.7.2 → agently-4.0.7.4}/agently/types/trigger_flow/trigger_flow.py +0 -0
  72. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/AGENT_UTILS_GUIDE.md +0 -0
  73. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/DataFormatter.py +0 -0
  74. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/DataLocator.py +0 -0
  75. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/DataPathBuilder.py +0 -0
  76. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/FunctionShifter.py +0 -0
  77. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/GeneratorConsumer.py +0 -0
  78. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/LazyImport.py +0 -0
  79. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/Logger.py +0 -0
  80. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/Messenger.py +0 -0
  81. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/PythonSandbox.py +0 -0
  82. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/RuntimeData.py +0 -0
  83. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/SerializableRuntimeData.py +0 -0
  84. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/Settings.py +0 -0
  85. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/Storage.py +0 -0
  86. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/StreamingJSONCompleter.py +0 -0
  87. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/StreamingJSONParser.py +0 -0
  88. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/TimeInfo.py +0 -0
  89. {agently-4.0.7.2 → agently-4.0.7.4}/agently/utils/__init__.py +0 -0
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.4
2
+ Name: agently
3
+ Version: 4.0.7.4
4
+ Summary:
5
+ License: Apache-2.0
6
+ License-File: LICENSE
7
+ Author: Agently Team
8
+ Author-email: developer@agently.tech
9
+ Requires-Python: >=3.10
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Requires-Dist: greenlet (>=3.2.3,<4.0.0)
18
+ Requires-Dist: httpx (>=0.28.1,<0.29.0)
19
+ Requires-Dist: httpx-sse (>=0.4.1,<0.5.0)
20
+ Requires-Dist: json5 (>=0.12.0,<0.13.0)
21
+ Requires-Dist: packaging (>=25.0,<26.0)
22
+ Requires-Dist: pydantic (>=2.11.7,<3.0.0)
23
+ Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
24
+ Requires-Dist: stamina (>=25.1.0,<26.0.0)
25
+ Requires-Dist: toml (>=0.10.2,<0.11.0)
26
+ Description-Content-Type: text/markdown
27
+
28
+ <img width="640" alt="image" src="https://github.com/user-attachments/assets/c645d031-c8b0-4dba-a515-9d7a4b0a6881" />
29
+
30
+ # Agently 4 🚀
31
+
32
+ > **Build production‑grade AI apps faster, with stable outputs and maintainable workflows.**
33
+
34
+ [English Introduction](https://github.com/AgentEra/Agently/blob/main/README.md) | [中文介绍](https://github.com/AgentEra/Agently/blob/main/README_CN.md)
35
+
36
+ [![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/AgentEra/Agently/blob/main/LICENSE)
37
+ [![PyPI version](https://img.shields.io/pypi/v/agently.svg)](https://pypi.org/project/agently/)
38
+ [![Downloads](https://img.shields.io/pypi/dm/agently.svg)](https://pypistats.org/packages/agently)
39
+ [![GitHub Stars](https://img.shields.io/github/stars/AgentEra/Agently.svg?style=social)](https://github.com/AgentEra/Agently/stargazers)
40
+ [![Twitter Follow](https://img.shields.io/twitter/follow/AgentlyTech?style=social)](https://x.com/AgentlyTech)
41
+ <a href="https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf">
42
+ <img alt="WeChat" src="https://img.shields.io/badge/WeChat%20Group-Join-brightgreen?logo=wechat&style=flat-square">
43
+ </a>
44
+
45
+ <p align="center">
46
+ <a href="https://github.com/AgentEra/Agently/discussions"><img src="https://img.shields.io/badge/💬_Community-Join-blueviolet?style=for-the-badge"></a>
47
+ <a href="https://agently.tech"><img src="https://img.shields.io/badge/🌐_Website-Docs-brightgreen?style=for-the-badge"></a>
48
+ <a href="https://github.com/AgentEra/Agently/issues"><img src="https://img.shields.io/badge/🐛_Issues-Report-red?style=for-the-badge"></a>
49
+ </p>
50
+
51
+ ---
52
+
53
+ <p align="center">
54
+ <b>🔥 <a href="https://agently.tech/docs">Latest Docs</a> | 🚀 <a href="#quickstart">5‑minute Quickstart</a> | 💡 <a href="#-core-features">Core Features</a></b>
55
+ </p>
56
+
57
+ ---
58
+
59
+ ## 📚 Quick Links
60
+
61
+ - **Docs (EN)**: https://agently.tech/docs
62
+ - **Docs (中文)**: https://agently.cn/docs
63
+ - **Agent Systems Playbook (EN)**: https://agently.tech/docs/en/agent-systems/overview.html
64
+ - **Agent Systems Playbook (中文)**: https://agently.cn/docs/agent-systems/overview.html
65
+ - **Coding Agent Guide (EN)**: https://agently.tech/docs/en/agent-docs.html
66
+ - **Coding Agent Guide (中文)**: https://agently.cn/docs/agent-docs.html
67
+ - **Agent Docs Pack**: https://agently.cn/docs/agent_docs.zip
68
+
69
+ ## 🤔 Why Agently?
70
+
71
+ Many GenAI POCs fail in production not because models are weak, but because **engineering control is missing**:
72
+
73
+ | Common challenge | How Agently helps |
74
+ |:--|:--|
75
+ | Output schema drifts, JSON parsing fails | **Contract‑first output control** with `output()` + `ensure_keys` |
76
+ | Workflows get complex and hard to maintain | **TriggerFlow orchestration** with `to` / `if` / `match` / `batch` / `for_each` |
77
+ | Multi‑turn state becomes unstable | **Session & Memo** with memory, summaries, and persistence strategies |
78
+ | Tool calls are hard to audit | **Tool logs** via `extra.tool_logs` |
79
+ | Switching models is expensive | **OpenAICompatible** unified model settings |
80
+
81
+ **Agently turns LLM uncertainty into a stable, testable, maintainable engineering system.**
82
+
83
+ ## ✨ Core Features
84
+
85
+ ### 1) 📝 Contract‑first Output Control
86
+ Define the structure with `output()`, enforce critical keys with `ensure_keys`.
87
+
88
+ ```python
89
+ result = (
90
+ agent
91
+ .input("Analyze user feedback")
92
+ .output({
93
+ "sentiment": (str, "positive/neutral/negative"),
94
+ "key_issues": [(str, "issue summary")],
95
+ "priority": (int, "1-5, 5 is highest")
96
+ })
97
+ .start(ensure_keys=["sentiment", "key_issues[*]"])
98
+ )
99
+ ```
100
+
101
+ ### 2) ⚡ Structured Streaming (Instant)
102
+ Consume structured fields as they are generated.
103
+
104
+ ```python
105
+ response = (
106
+ agent
107
+ .input("Explain recursion and give 2 tips")
108
+ .output({"definition": (str, "one sentence"), "tips": [(str, "tip")]})
109
+ .get_response()
110
+ )
111
+
112
+ for msg in response.get_generator(type="instant"):
113
+ if msg.path == "definition" and msg.delta:
114
+ ui.update_definition(msg.delta)
115
+ if msg.wildcard_path == "tips[*]" and msg.delta:
116
+ ui.add_tip(msg.delta)
117
+ ```
118
+
119
+ ### 3) 🧩 TriggerFlow Orchestration
120
+ Readable, testable workflows with branching and concurrency.
121
+
122
+ ```python
123
+ (
124
+ flow.to(handle_request)
125
+ .if_condition(lambda d: d.value["type"] == "query")
126
+ .to(handle_query)
127
+ .elif_condition(lambda d: d.value["type"] == "order")
128
+ .to(check_inventory)
129
+ .to(create_order)
130
+ .end_condition()
131
+ )
132
+ ```
133
+
134
+ ### 4) 🧠 Session & Memo (Multi‑turn Memory)
135
+ Quick / Lite / Memo modes with summaries and persistence strategies.
136
+
137
+ ```python
138
+ from agently import Agently
139
+ from agently.core import Session
140
+
141
+ agent = Agently.create_agent()
142
+ session = Session(agent=agent).configure(
143
+ mode="memo",
144
+ limit={"chars": 6000, "messages": 12},
145
+ every_n_turns=2,
146
+ )
147
+ agent.attach_session(session)
148
+ ```
149
+
150
+ ### 5) 🔧 Tool Calls + Logs
151
+ Tool selection and usage are logged in `extra.tool_logs`.
152
+
153
+ ```python
154
+ @agent.tool_func
155
+ def add(a: int, b: int) -> int:
156
+ return a + b
157
+
158
+ response = agent.input("12+34=?").use_tool(add).get_response()
159
+ full = response.get_data(type="all")
160
+ print(full["extra"]["tool_logs"])
161
+ ```
162
+
163
+ ### 6) 🌐 Unified Model Settings (OpenAICompatible)
164
+ One config for multiple providers and local models.
165
+
166
+ ```python
167
+ from agently import Agently
168
+
169
+ Agently.set_settings(
170
+ "OpenAICompatible",
171
+ {
172
+ "base_url": "https://api.deepseek.com/v1",
173
+ "model": "deepseek-chat",
174
+ "auth": "DEEPSEEK_API_KEY",
175
+ },
176
+ )
177
+ ```
178
+
179
+ ## 🚀 Quickstart
180
+
181
+ ### Install
182
+
183
+ ```bash
184
+ pip install -U agently
185
+ ```
186
+
187
+ *Requirements: Python >= 3.10, recommended Agently >= 4.0.7.2*
188
+
189
+ ### 5‑minute example
190
+
191
+ **1. Structured output**
192
+
193
+ ```python
194
+ from agently import Agently
195
+
196
+ agent = Agently.create_agent()
197
+
198
+ result = (
199
+ agent.input("Introduce Python in one sentence and list 2 advantages")
200
+ .output({
201
+ "introduction": (str, "one sentence"),
202
+ "advantages": [(str, "advantage")]
203
+ })
204
+ .start(ensure_keys=["introduction", "advantages[*]"])
205
+ )
206
+
207
+ print(result)
208
+ ```
209
+
210
+ **2. Workflow routing**
211
+
212
+ ```python
213
+ from agently import TriggerFlow, TriggerFlowEventData
214
+
215
+ flow = TriggerFlow()
216
+
217
+ @flow.chunk
218
+ def classify_intent(data: TriggerFlowEventData):
219
+ text = data.value
220
+ if "price" in text:
221
+ return "price_query"
222
+ if "feature" in text:
223
+ return "feature_query"
224
+ if "buy" in text:
225
+ return "purchase"
226
+ return "other"
227
+
228
+ @flow.chunk
229
+ def handle_price(_: TriggerFlowEventData):
230
+ return {"response": "Pricing depends on the plan..."}
231
+
232
+ @flow.chunk
233
+ def handle_feature(_: TriggerFlowEventData):
234
+ return {"response": "Our product supports..."}
235
+
236
+ (
237
+ flow.to(classify_intent)
238
+ .match()
239
+ .case("price_query")
240
+ .to(handle_price)
241
+ .case("feature_query")
242
+ .to(handle_feature)
243
+ .case_else()
244
+ .to(lambda d: {"response": "What would you like to know?"})
245
+ .end_match()
246
+ .end()
247
+ )
248
+
249
+ print(flow.start("How much does it cost?"))
250
+ ```
251
+
252
+ ## ✅ Is Your App Production‑Ready? — Release Readiness Checklist
253
+
254
+ Based on teams shipping real projects with Agently, this **production readiness checklist** helps reduce common risks before release.
255
+
256
+ | Area | Check | Recommended Practice |
257
+ | :--- | :--- | :--- |
258
+ | **📝 Output Stability** | Are key interfaces stable? | Define schemas with `output()` and lock critical fields with `ensure_keys`. |
259
+ | **⚡ Real‑time UX** | Need updates while generating? | Consume `type="instant"` structured streaming events. |
260
+ | **🔍 Observability** | Tool calls auditable? | Inspect `extra.tool_logs` for full arguments and results. |
261
+ | **🧩 Workflow Robustness** | Complex flows fully tested? | Unit test each TriggerFlow branch and concurrency limit with expected outputs. |
262
+ | **🧠 Memory & Context** | Multi‑turn experience consistent? | Define Session/Memo summary, trimming, and persistence policies. |
263
+ | **📄 Prompt Management** | Can logic evolve safely? | Version and configure prompts to keep changes traceable. |
264
+ | **🌐 Model Strategy** | Can you switch or downgrade models? | Centralize settings with `OpenAICompatible` for fast provider switching. |
265
+ | **🚀 Performance & Scale** | Can it handle concurrency? | Validate async performance in real web‑service scenarios. |
266
+ | **🧪 Quality Assurance** | Regression tests complete? | Create fixed inputs with expected outputs for core scenarios. |
267
+
268
+
269
+ ## 📈 Who Uses Agently to Solve Real Problems?
270
+
271
+ > "Agently helped us turn evaluation rules into executable workflows and keep key scoring accuracy at 75%+, significantly improving bid‑evaluation efficiency." — Project lead at a large energy SOE
272
+
273
+ > "Agently enabled a closed loop from clarification to query planning to rendering, reaching 90%+ first‑response accuracy and stable production performance." — Data lead at a large energy group
274
+
275
+ > "Agently’s orchestration and session capabilities let us ship a teaching assistant for course management and Q&A quickly, with continuous iteration." — Project lead at a university teaching‑assistant initiative
276
+
277
+ **Your project can be next.**
278
+ 📢 [Share your case on GitHub Discussions →](https://github.com/AgentEra/Agently/discussions/categories/show-and-tell)
279
+ ## ❓ FAQ
280
+
281
+ **Q: How is Agently different from LangChain or LlamaIndex?**
282
+ **A:** Agently is **built for production**. It focuses on stable interfaces (contract‑first outputs), readable/testable orchestration (TriggerFlow), and observable tool calls (`tool_logs`). It’s a better fit for teams that need reliability and maintainability after launch.
283
+
284
+ **Q: Which models are supported? Is switching expensive?**
285
+ **A:** With `OpenAICompatible`, you can connect OpenAI, Claude, DeepSeek, Qwen and most OpenAI‑compatible endpoints, plus local models like Llama/Qwen. **The same business code can switch models without rewrites**, reducing vendor lock‑in.
286
+
287
+ **Q: What’s the learning curve? Where should I start?**
288
+ **A:** The core API is straightforward—**you can run your first agent in minutes**. Start with [Quickstart](https://agently.tech/docs/en/quickstart.html), then dive into [Output Control](https://agently.tech/docs/en/output-control/overview.html) and [TriggerFlow](https://agently.tech/docs/en/triggerflow/overview.html).
289
+
290
+ **Q: How do I deploy an Agently‑based service?**
291
+ **A:** Agently doesn’t lock you into a specific deployment path. It provides async APIs and FastAPI examples. The [FastAPI integration example](https://github.com/AgentEra/Agently/tree/main/examples/step_by_step/13-auto_loop_fastapi) covers SSE, WebSocket, and standard POST.
292
+
293
+ **Q: Do you offer enterprise support?**
294
+ **A:** The core framework is open‑source under **Apache 2.0**. For enterprise support, training, or deep collaboration, contact us via the [community](https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf).
295
+
296
+
297
+ ## 🧭 Docs Guide (Key Paths)
298
+
299
+ - **Getting Started**
300
+ - Quickstart: https://agently.tech/docs/en/quickstart.html
301
+ - Model Settings: https://agently.tech/docs/en/model-settings.html
302
+ - Coding Agent Guide: https://agently.tech/docs/en/agent-docs.html
303
+ - **Output Control (Structured Output)**
304
+ - Overview: https://agently.tech/docs/en/output-control/overview.html
305
+ - Output Format: https://agently.tech/docs/en/output-control/format.html
306
+ - ensure_keys: https://agently.tech/docs/en/output-control/ensure-keys.html
307
+ - Instant Streaming: https://agently.tech/docs/en/output-control/instant-streaming.html
308
+ - **Result & Streaming Events**
309
+ - Result Data: https://agently.tech/docs/en/model-response/result-data.html
310
+ - Streaming Events: https://agently.tech/docs/en/model-response/streaming.html
311
+ - **Session & Memo**
312
+ - Overview: https://agently.tech/docs/en/agent-extensions/session-memo/
313
+ - Quickstart: https://agently.tech/docs/en/agent-extensions/session-memo/quickstart.html
314
+ - **TriggerFlow Orchestration**
315
+ - Overview: https://agently.tech/docs/en/triggerflow/overview.html
316
+ - when Branch: https://agently.tech/docs/en/triggerflow/when-branch.html
317
+ - if / elif / else: https://agently.tech/docs/en/triggerflow/if-branch.html
318
+ - match / case: https://agently.tech/docs/en/triggerflow/match-branch.html
319
+ - batch: https://agently.tech/docs/en/triggerflow/batch.html
320
+ - for_each: https://agently.tech/docs/en/triggerflow/for-each.html
321
+ - Runtime Stream: https://agently.tech/docs/en/triggerflow/runtime-stream.html
322
+ - **Tools & Extensions**
323
+ - Tools: https://agently.tech/docs/en/agent-extensions/tools.html
324
+ - MCP: https://agently.tech/docs/en/agent-extensions/mcp.html
325
+ - auto_func: https://agently.tech/docs/en/agent-extensions/auto-func.html
326
+ - KeyWaiter: https://agently.tech/docs/en/agent-extensions/key-waiter.html
327
+ - **Prompt Management**: https://agently.tech/docs/en/prompt-management/overview.html
328
+ - **Async & Settings**: https://agently.tech/docs/en/async-support.html / https://agently.tech/docs/en/settings.html
329
+ - **Playbook**: https://agently.tech/docs/en/agent-systems/overview.html
330
+
331
+ ## 🤝 Community
332
+
333
+ - Discussions: https://github.com/AgentEra/Agently/discussions
334
+ - Issues: https://github.com/AgentEra/Agently/issues
335
+ - WeChat Group: https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf
336
+
337
+ ## 📄 License
338
+
339
+ Agently is licensed under [Apache 2.0](LICENSE).
340
+
341
+ ---
342
+
343
+ <p align="center">
344
+ <b>Start building your production‑ready AI apps →</b><br>
345
+ <code>pip install -U agently</code>
346
+ </p>
347
+
348
+ <p align="center">
349
+ <sub>Questions? Read the <a href="https://agently.tech/docs">docs</a> or join the <a href="https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf">community</a>.</sub>
350
+ </p>
351
+
@@ -0,0 +1,323 @@
1
+ <img width="640" alt="image" src="https://github.com/user-attachments/assets/c645d031-c8b0-4dba-a515-9d7a4b0a6881" />
2
+
3
+ # Agently 4 🚀
4
+
5
+ > **Build production‑grade AI apps faster, with stable outputs and maintainable workflows.**
6
+
7
+ [English Introduction](https://github.com/AgentEra/Agently/blob/main/README.md) | [中文介绍](https://github.com/AgentEra/Agently/blob/main/README_CN.md)
8
+
9
+ [![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/AgentEra/Agently/blob/main/LICENSE)
10
+ [![PyPI version](https://img.shields.io/pypi/v/agently.svg)](https://pypi.org/project/agently/)
11
+ [![Downloads](https://img.shields.io/pypi/dm/agently.svg)](https://pypistats.org/packages/agently)
12
+ [![GitHub Stars](https://img.shields.io/github/stars/AgentEra/Agently.svg?style=social)](https://github.com/AgentEra/Agently/stargazers)
13
+ [![Twitter Follow](https://img.shields.io/twitter/follow/AgentlyTech?style=social)](https://x.com/AgentlyTech)
14
+ <a href="https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf">
15
+ <img alt="WeChat" src="https://img.shields.io/badge/WeChat%20Group-Join-brightgreen?logo=wechat&style=flat-square">
16
+ </a>
17
+
18
+ <p align="center">
19
+ <a href="https://github.com/AgentEra/Agently/discussions"><img src="https://img.shields.io/badge/💬_Community-Join-blueviolet?style=for-the-badge"></a>
20
+ <a href="https://agently.tech"><img src="https://img.shields.io/badge/🌐_Website-Docs-brightgreen?style=for-the-badge"></a>
21
+ <a href="https://github.com/AgentEra/Agently/issues"><img src="https://img.shields.io/badge/🐛_Issues-Report-red?style=for-the-badge"></a>
22
+ </p>
23
+
24
+ ---
25
+
26
+ <p align="center">
27
+ <b>🔥 <a href="https://agently.tech/docs">Latest Docs</a> | 🚀 <a href="#quickstart">5‑minute Quickstart</a> | 💡 <a href="#-core-features">Core Features</a></b>
28
+ </p>
29
+
30
+ ---
31
+
32
+ ## 📚 Quick Links
33
+
34
+ - **Docs (EN)**: https://agently.tech/docs
35
+ - **Docs (中文)**: https://agently.cn/docs
36
+ - **Agent Systems Playbook (EN)**: https://agently.tech/docs/en/agent-systems/overview.html
37
+ - **Agent Systems Playbook (中文)**: https://agently.cn/docs/agent-systems/overview.html
38
+ - **Coding Agent Guide (EN)**: https://agently.tech/docs/en/agent-docs.html
39
+ - **Coding Agent Guide (中文)**: https://agently.cn/docs/agent-docs.html
40
+ - **Agent Docs Pack**: https://agently.cn/docs/agent_docs.zip
41
+
42
+ ## 🤔 Why Agently?
43
+
44
+ Many GenAI POCs fail in production not because models are weak, but because **engineering control is missing**:
45
+
46
+ | Common challenge | How Agently helps |
47
+ |:--|:--|
48
+ | Output schema drifts, JSON parsing fails | **Contract‑first output control** with `output()` + `ensure_keys` |
49
+ | Workflows get complex and hard to maintain | **TriggerFlow orchestration** with `to` / `if` / `match` / `batch` / `for_each` |
50
+ | Multi‑turn state becomes unstable | **Session & Memo** with memory, summaries, and persistence strategies |
51
+ | Tool calls are hard to audit | **Tool logs** via `extra.tool_logs` |
52
+ | Switching models is expensive | **OpenAICompatible** unified model settings |
53
+
54
+ **Agently turns LLM uncertainty into a stable, testable, maintainable engineering system.**
55
+
56
+ ## ✨ Core Features
57
+
58
+ ### 1) 📝 Contract‑first Output Control
59
+ Define the structure with `output()`, enforce critical keys with `ensure_keys`.
60
+
61
+ ```python
62
+ result = (
63
+ agent
64
+ .input("Analyze user feedback")
65
+ .output({
66
+ "sentiment": (str, "positive/neutral/negative"),
67
+ "key_issues": [(str, "issue summary")],
68
+ "priority": (int, "1-5, 5 is highest")
69
+ })
70
+ .start(ensure_keys=["sentiment", "key_issues[*]"])
71
+ )
72
+ ```
73
+
74
+ ### 2) ⚡ Structured Streaming (Instant)
75
+ Consume structured fields as they are generated.
76
+
77
+ ```python
78
+ response = (
79
+ agent
80
+ .input("Explain recursion and give 2 tips")
81
+ .output({"definition": (str, "one sentence"), "tips": [(str, "tip")]})
82
+ .get_response()
83
+ )
84
+
85
+ for msg in response.get_generator(type="instant"):
86
+ if msg.path == "definition" and msg.delta:
87
+ ui.update_definition(msg.delta)
88
+ if msg.wildcard_path == "tips[*]" and msg.delta:
89
+ ui.add_tip(msg.delta)
90
+ ```
91
+
92
+ ### 3) 🧩 TriggerFlow Orchestration
93
+ Readable, testable workflows with branching and concurrency.
94
+
95
+ ```python
96
+ (
97
+ flow.to(handle_request)
98
+ .if_condition(lambda d: d.value["type"] == "query")
99
+ .to(handle_query)
100
+ .elif_condition(lambda d: d.value["type"] == "order")
101
+ .to(check_inventory)
102
+ .to(create_order)
103
+ .end_condition()
104
+ )
105
+ ```
106
+
107
+ ### 4) 🧠 Session & Memo (Multi‑turn Memory)
108
+ Quick / Lite / Memo modes with summaries and persistence strategies.
109
+
110
+ ```python
111
+ from agently import Agently
112
+ from agently.core import Session
113
+
114
+ agent = Agently.create_agent()
115
+ session = Session(agent=agent).configure(
116
+ mode="memo",
117
+ limit={"chars": 6000, "messages": 12},
118
+ every_n_turns=2,
119
+ )
120
+ agent.attach_session(session)
121
+ ```
122
+
123
+ ### 5) 🔧 Tool Calls + Logs
124
+ Tool selection and usage are logged in `extra.tool_logs`.
125
+
126
+ ```python
127
+ @agent.tool_func
128
+ def add(a: int, b: int) -> int:
129
+ return a + b
130
+
131
+ response = agent.input("12+34=?").use_tool(add).get_response()
132
+ full = response.get_data(type="all")
133
+ print(full["extra"]["tool_logs"])
134
+ ```
135
+
136
+ ### 6) 🌐 Unified Model Settings (OpenAICompatible)
137
+ One config for multiple providers and local models.
138
+
139
+ ```python
140
+ from agently import Agently
141
+
142
+ Agently.set_settings(
143
+ "OpenAICompatible",
144
+ {
145
+ "base_url": "https://api.deepseek.com/v1",
146
+ "model": "deepseek-chat",
147
+ "auth": "DEEPSEEK_API_KEY",
148
+ },
149
+ )
150
+ ```
151
+
152
+ ## 🚀 Quickstart
153
+
154
+ ### Install
155
+
156
+ ```bash
157
+ pip install -U agently
158
+ ```
159
+
160
+ *Requirements: Python >= 3.10, recommended Agently >= 4.0.7.2*
161
+
162
+ ### 5‑minute example
163
+
164
+ **1. Structured output**
165
+
166
+ ```python
167
+ from agently import Agently
168
+
169
+ agent = Agently.create_agent()
170
+
171
+ result = (
172
+ agent.input("Introduce Python in one sentence and list 2 advantages")
173
+ .output({
174
+ "introduction": (str, "one sentence"),
175
+ "advantages": [(str, "advantage")]
176
+ })
177
+ .start(ensure_keys=["introduction", "advantages[*]"])
178
+ )
179
+
180
+ print(result)
181
+ ```
182
+
183
+ **2. Workflow routing**
184
+
185
+ ```python
186
+ from agently import TriggerFlow, TriggerFlowEventData
187
+
188
+ flow = TriggerFlow()
189
+
190
+ @flow.chunk
191
+ def classify_intent(data: TriggerFlowEventData):
192
+ text = data.value
193
+ if "price" in text:
194
+ return "price_query"
195
+ if "feature" in text:
196
+ return "feature_query"
197
+ if "buy" in text:
198
+ return "purchase"
199
+ return "other"
200
+
201
+ @flow.chunk
202
+ def handle_price(_: TriggerFlowEventData):
203
+ return {"response": "Pricing depends on the plan..."}
204
+
205
+ @flow.chunk
206
+ def handle_feature(_: TriggerFlowEventData):
207
+ return {"response": "Our product supports..."}
208
+
209
+ (
210
+ flow.to(classify_intent)
211
+ .match()
212
+ .case("price_query")
213
+ .to(handle_price)
214
+ .case("feature_query")
215
+ .to(handle_feature)
216
+ .case_else()
217
+ .to(lambda d: {"response": "What would you like to know?"})
218
+ .end_match()
219
+ .end()
220
+ )
221
+
222
+ print(flow.start("How much does it cost?"))
223
+ ```
224
+
225
+ ## ✅ Is Your App Production‑Ready? — Release Readiness Checklist
226
+
227
+ Based on teams shipping real projects with Agently, this **production readiness checklist** helps reduce common risks before release.
228
+
229
+ | Area | Check | Recommended Practice |
230
+ | :--- | :--- | :--- |
231
+ | **📝 Output Stability** | Are key interfaces stable? | Define schemas with `output()` and lock critical fields with `ensure_keys`. |
232
+ | **⚡ Real‑time UX** | Need updates while generating? | Consume `type="instant"` structured streaming events. |
233
+ | **🔍 Observability** | Tool calls auditable? | Inspect `extra.tool_logs` for full arguments and results. |
234
+ | **🧩 Workflow Robustness** | Complex flows fully tested? | Unit test each TriggerFlow branch and concurrency limit with expected outputs. |
235
+ | **🧠 Memory & Context** | Multi‑turn experience consistent? | Define Session/Memo summary, trimming, and persistence policies. |
236
+ | **📄 Prompt Management** | Can logic evolve safely? | Version and configure prompts to keep changes traceable. |
237
+ | **🌐 Model Strategy** | Can you switch or downgrade models? | Centralize settings with `OpenAICompatible` for fast provider switching. |
238
+ | **🚀 Performance & Scale** | Can it handle concurrency? | Validate async performance in real web‑service scenarios. |
239
+ | **🧪 Quality Assurance** | Regression tests complete? | Create fixed inputs with expected outputs for core scenarios. |
240
+
241
+
242
+ ## 📈 Who Uses Agently to Solve Real Problems?
243
+
244
+ > "Agently helped us turn evaluation rules into executable workflows and keep key scoring accuracy at 75%+, significantly improving bid‑evaluation efficiency." — Project lead at a large energy SOE
245
+
246
+ > "Agently enabled a closed loop from clarification to query planning to rendering, reaching 90%+ first‑response accuracy and stable production performance." — Data lead at a large energy group
247
+
248
+ > "Agently’s orchestration and session capabilities let us ship a teaching assistant for course management and Q&A quickly, with continuous iteration." — Project lead at a university teaching‑assistant initiative
249
+
250
+ **Your project can be next.**
251
+ 📢 [Share your case on GitHub Discussions →](https://github.com/AgentEra/Agently/discussions/categories/show-and-tell)
252
+ ## ❓ FAQ
253
+
254
+ **Q: How is Agently different from LangChain or LlamaIndex?**
255
+ **A:** Agently is **built for production**. It focuses on stable interfaces (contract‑first outputs), readable/testable orchestration (TriggerFlow), and observable tool calls (`tool_logs`). It’s a better fit for teams that need reliability and maintainability after launch.
256
+
257
+ **Q: Which models are supported? Is switching expensive?**
258
+ **A:** With `OpenAICompatible`, you can connect OpenAI, Claude, DeepSeek, Qwen and most OpenAI‑compatible endpoints, plus local models like Llama/Qwen. **The same business code can switch models without rewrites**, reducing vendor lock‑in.
259
+
260
+ **Q: What’s the learning curve? Where should I start?**
261
+ **A:** The core API is straightforward—**you can run your first agent in minutes**. Start with [Quickstart](https://agently.tech/docs/en/quickstart.html), then dive into [Output Control](https://agently.tech/docs/en/output-control/overview.html) and [TriggerFlow](https://agently.tech/docs/en/triggerflow/overview.html).
262
+
263
+ **Q: How do I deploy an Agently‑based service?**
264
+ **A:** Agently doesn’t lock you into a specific deployment path. It provides async APIs and FastAPI examples. The [FastAPI integration example](https://github.com/AgentEra/Agently/tree/main/examples/step_by_step/13-auto_loop_fastapi) covers SSE, WebSocket, and standard POST.
265
+
266
+ **Q: Do you offer enterprise support?**
267
+ **A:** The core framework is open‑source under **Apache 2.0**. For enterprise support, training, or deep collaboration, contact us via the [community](https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf).
268
+
269
+
270
+ ## 🧭 Docs Guide (Key Paths)
271
+
272
+ - **Getting Started**
273
+ - Quickstart: https://agently.tech/docs/en/quickstart.html
274
+ - Model Settings: https://agently.tech/docs/en/model-settings.html
275
+ - Coding Agent Guide: https://agently.tech/docs/en/agent-docs.html
276
+ - **Output Control (Structured Output)**
277
+ - Overview: https://agently.tech/docs/en/output-control/overview.html
278
+ - Output Format: https://agently.tech/docs/en/output-control/format.html
279
+ - ensure_keys: https://agently.tech/docs/en/output-control/ensure-keys.html
280
+ - Instant Streaming: https://agently.tech/docs/en/output-control/instant-streaming.html
281
+ - **Result & Streaming Events**
282
+ - Result Data: https://agently.tech/docs/en/model-response/result-data.html
283
+ - Streaming Events: https://agently.tech/docs/en/model-response/streaming.html
284
+ - **Session & Memo**
285
+ - Overview: https://agently.tech/docs/en/agent-extensions/session-memo/
286
+ - Quickstart: https://agently.tech/docs/en/agent-extensions/session-memo/quickstart.html
287
+ - **TriggerFlow Orchestration**
288
+ - Overview: https://agently.tech/docs/en/triggerflow/overview.html
289
+ - when Branch: https://agently.tech/docs/en/triggerflow/when-branch.html
290
+ - if / elif / else: https://agently.tech/docs/en/triggerflow/if-branch.html
291
+ - match / case: https://agently.tech/docs/en/triggerflow/match-branch.html
292
+ - batch: https://agently.tech/docs/en/triggerflow/batch.html
293
+ - for_each: https://agently.tech/docs/en/triggerflow/for-each.html
294
+ - Runtime Stream: https://agently.tech/docs/en/triggerflow/runtime-stream.html
295
+ - **Tools & Extensions**
296
+ - Tools: https://agently.tech/docs/en/agent-extensions/tools.html
297
+ - MCP: https://agently.tech/docs/en/agent-extensions/mcp.html
298
+ - auto_func: https://agently.tech/docs/en/agent-extensions/auto-func.html
299
+ - KeyWaiter: https://agently.tech/docs/en/agent-extensions/key-waiter.html
300
+ - **Prompt Management**: https://agently.tech/docs/en/prompt-management/overview.html
301
+ - **Async & Settings**: https://agently.tech/docs/en/async-support.html / https://agently.tech/docs/en/settings.html
302
+ - **Playbook**: https://agently.tech/docs/en/agent-systems/overview.html
303
+
304
+ ## 🤝 Community
305
+
306
+ - Discussions: https://github.com/AgentEra/Agently/discussions
307
+ - Issues: https://github.com/AgentEra/Agently/issues
308
+ - WeChat Group: https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf
309
+
310
+ ## 📄 License
311
+
312
+ Agently is licensed under [Apache 2.0](LICENSE).
313
+
314
+ ---
315
+
316
+ <p align="center">
317
+ <b>Start building your production‑ready AI apps →</b><br>
318
+ <code>pip install -U agently</code>
319
+ </p>
320
+
321
+ <p align="center">
322
+ <sub>Questions? Read the <a href="https://agently.tech/docs">docs</a> or join the <a href="https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf">community</a>.</sub>
323
+ </p>