lionagi 0.3.7__py3-none-any.whl → 0.3.8__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. lionagi/core/director/operations/select.py +2 -92
  2. lionagi/core/rule/choice.py +2 -2
  3. lionagi/operations/__init__.py +6 -0
  4. lionagi/operations/brainstorm.py +87 -0
  5. lionagi/operations/config.py +6 -0
  6. lionagi/operations/rank.py +102 -0
  7. lionagi/operations/score.py +144 -0
  8. lionagi/operations/select.py +141 -0
  9. lionagi/version.py +1 -1
  10. lionagi-0.3.8.dist-info/METADATA +241 -0
  11. {lionagi-0.3.7.dist-info → lionagi-0.3.8.dist-info}/RECORD +13 -30
  12. lionagi/core/director/models/__init__.py +0 -13
  13. lionagi/core/director/models/action_model.py +0 -61
  14. lionagi/core/director/models/brainstorm_model.py +0 -42
  15. lionagi/core/director/models/plan_model.py +0 -51
  16. lionagi/core/director/models/reason_model.py +0 -63
  17. lionagi/core/director/models/step_model.py +0 -65
  18. lionagi/core/operations/__init__.py +0 -0
  19. lionagi/core/operations/chat/__init__.py +0 -0
  20. lionagi/core/operations/direct/__init__.py +0 -0
  21. lionagi/core/operative/__init__.py +0 -0
  22. lionagi/operations/brainstorm/__init__.py +0 -0
  23. lionagi/operations/chat/__init__.py +0 -0
  24. lionagi/operations/models/__init__.py +0 -0
  25. lionagi/operations/plan/__init__.py +0 -0
  26. lionagi/operations/plan/base.py +0 -0
  27. lionagi/operations/query/__init__.py +0 -0
  28. lionagi/operations/rank/__init__.py +0 -0
  29. lionagi/operations/react/__init__.py +0 -0
  30. lionagi/operations/route/__init__.py +0 -0
  31. lionagi/operations/score/__init__.py +0 -0
  32. lionagi/operations/select/__init__.py +0 -0
  33. lionagi/operations/strategize/__init__.py +0 -0
  34. lionagi-0.3.7.dist-info/METADATA +0 -70
  35. {lionagi-0.3.7.dist-info → lionagi-0.3.8.dist-info}/LICENSE +0 -0
  36. {lionagi-0.3.7.dist-info → lionagi-0.3.8.dist-info}/WHEEL +0 -0
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.1
2
+ Name: lionagi
3
+ Version: 0.3.8
4
+ Summary: Towards automated general intelligence.
5
+ Author: HaiyangLi
6
+ Author-email: quantocean.li@gmail.com
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Dist: aiocache (>=0.12.0,<0.13.0)
13
+ Requires-Dist: ipython (>=8.0.0,<9.0.0)
14
+ Requires-Dist: lion-core (>=0.5.6,<0.6.0)
15
+ Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
16
+ Description-Content-Type: text/markdown
17
+
18
+ ![PyPI - Version](https://img.shields.io/pypi/v/lionagi?labelColor=233476aa&color=231fc935)
19
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/lionagi?color=blue)
20
+ ![Dependencies](https://img.shields.io/badge/dependencies-4-brightgreen)
21
+ ![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)
22
+
23
+ [Documentation](https://ocean-lion.com/Welcome) | [Discord](https://discord.gg/aqSJ2v46vu) | [PyPI](https://pypi.org/project/lionagi/) | [Roadmap](https://trello.com/b/3seomsrI/lionagi)
24
+
25
+ # LION Framework
26
+ ### Language InterOperable Network - The Future of Controlled AI Operations
27
+
28
+ > Harness the power of next-generation AI while maintaining complete control and reliability.
29
+
30
+ ## Why LION?
31
+
32
+ The AI revolution is transforming how we work - but with great power comes great responsibility. LION provides the control mechanisms and reliability features needed to safely integrate advanced AI capabilities into enterprise workflows.
33
+
34
+ LION is designed to be:
35
+ - 🔒 **Controlled**: Built-in safety mechanisms and verification
36
+ - 🎯 **Precise**: Exact control over AI behaviors
37
+ - 🔧 **Flexible**: Build any workflow you need
38
+ - 🚀 **Efficient**: Minimal dependencies, maximum performance
39
+
40
+ ## Quick Start
41
+
42
+ ```python
43
+ from lionagi import Branch, iModel
44
+
45
+ # Initialize model
46
+ gpt4o = iModel(provider="openai", model="gpt-4o")
47
+
48
+ # Create a branch with personality
49
+ comedian = Branch(
50
+ system="you are a sarcastic dragon hunter",
51
+ imodel=gpt4o
52
+ )
53
+
54
+ # Chat asynchronously
55
+ response = await branch.chat(
56
+ "tell me a joke on knight vs dragon"
57
+ )
58
+ ```
59
+
60
+ ## Installation
61
+
62
+ LION maintains minimal dependencies for maximum reliability:
63
+
64
+ ```bash
65
+ pip install lionagi
66
+ ```
67
+
68
+ Dependencies:
69
+ - aiocache
70
+ - lion-core
71
+ - python-dotenv
72
+ - IPython
73
+
74
+ ## 🌟 Example Workflow
75
+
76
+ Below is an example of what you can build with LION. Note that these are sample implementations - LION provides the building blocks, you create the workflows that fit your needs.
77
+
78
+ ```mermaid
79
+ sequenceDiagram
80
+ autonumber
81
+ participant Client
82
+ participant Orchestrator
83
+ participant ResearchAgent
84
+ participant AnalysisAgent
85
+ participant ValidationAgent
86
+ participant Tools
87
+
88
+ Client->>+Orchestrator: Submit Complex Task
89
+ Note over Orchestrator: Task Analysis & Planning
90
+
91
+ %% Research Phase
92
+ Orchestrator->>+ResearchAgent: Delegate Research
93
+ activate ResearchAgent
94
+ ResearchAgent->>Tools: Access Data Sources
95
+ Tools-->>ResearchAgent: Raw Data
96
+ ResearchAgent-->>-Orchestrator: Research Results
97
+ deactivate ResearchAgent
98
+
99
+ %% Analysis Phase
100
+ Orchestrator->>+AnalysisAgent: Process Data
101
+ activate AnalysisAgent
102
+ AnalysisAgent->>Tools: Apply Models
103
+ Tools-->>AnalysisAgent: Analysis Results
104
+ AnalysisAgent-->>-Orchestrator: Processed Insights
105
+ deactivate AnalysisAgent
106
+
107
+ %% Validation Phase
108
+ Orchestrator->>+ValidationAgent: Verify Results
109
+ activate ValidationAgent
110
+ ValidationAgent->>Tools: Apply Safety Checks
111
+ Tools-->>ValidationAgent: Validation Status
112
+ ValidationAgent-->>-Orchestrator: Verified Results
113
+ deactivate ValidationAgent
114
+
115
+ Orchestrator-->>-Client: Return Validated Output
116
+ ```
117
+
118
+ ## 🏗️ System Architecture
119
+
120
+ Here's how you can structure your LION-powered system. Each component can be customized to your specific needs.
121
+
122
+ ```mermaid
123
+ graph TB
124
+ subgraph Client Layer
125
+ CL[Client Application]
126
+ end
127
+
128
+ subgraph Orchestration Layer
129
+ ORC[Orchestrator]
130
+ SEC[Security Controls]
131
+ MON[Monitoring]
132
+ end
133
+
134
+ subgraph Agent Layer
135
+ subgraph Specialized Agents
136
+ RA[Research Agent]
137
+ AA[Analysis Agent]
138
+ VA[Validation Agent]
139
+ end
140
+
141
+ subgraph Agent Controls
142
+ AC[Access Control]
143
+ AM[Action Monitor]
144
+ VE[Verification]
145
+ end
146
+ end
147
+
148
+ subgraph Resource Layer
149
+ subgraph Tool Management
150
+ TM[Tool Registry]
151
+ TP[Tool Policies]
152
+ end
153
+
154
+ subgraph Data Sources
155
+ DS[Data Access]
156
+ DV[Data Validation]
157
+ end
158
+ end
159
+
160
+ %% Connections
161
+ CL --> ORC
162
+ ORC --> RA & AA & VA
163
+ RA & AA & VA --> AC
164
+ AC --> TM
165
+ TM --> DS
166
+
167
+ %% Control Flow
168
+ ORC --> SEC
169
+ SEC --> MON
170
+ MON --> AM
171
+ AM --> VE
172
+ VE --> TP
173
+ TP --> DV
174
+
175
+ classDef primary fill:#1e40af,stroke:#1e3a8a,color:#fff
176
+ classDef secondary fill:#3b82f6,stroke:#2563eb,color:#fff
177
+ classDef control fill:#7c3aed,stroke:#6d28d9,color:#fff
178
+ ```
179
+
180
+ ## 🛠️ Building Blocks
181
+
182
+ LION provides the essential components you need to build reliable AI workflows:
183
+
184
+ - **Branch**: Core conversation unit with built-in safety mechanisms
185
+ - **iModel**: Standardized interface to AI models
186
+ - **Tools**: Framework for safe tool integration
187
+ - **Exchange**: Reliable message passing between components
188
+
189
+ Each component is designed to be:
190
+ - Fully customizable to your needs
191
+ - Safe by default
192
+ - Easy to integrate
193
+ - Highly reliable
194
+
195
+ ## 🎯 Key Use Cases
196
+
197
+ - **Enterprise Operations**
198
+ - Complex workflow automation
199
+ - Data analysis and processing
200
+ - Decision support systems
201
+
202
+ - **AI Integration**
203
+ - Controlled model deployment
204
+ - Safe tool usage
205
+ - Reliable agent operations
206
+
207
+ - **Development**
208
+ - Rapid prototyping
209
+ - System integration
210
+ - Workflow optimization
211
+
212
+ ## 🔒 Built for Reliability
213
+
214
+ LION isn't just another framework - it's your partner in responsible AI adoption. Build enterprise-grade AI systems with:
215
+
216
+ - Complete control over AI behaviors
217
+ - Comprehensive audit trails
218
+ - Built-in safety mechanisms
219
+ - Minimal dependencies
220
+ - Maximum reliability
221
+
222
+ ## 🤝 Contributing
223
+
224
+ Join our [Discord community](https://discord.gg/aqSJ2v46vu) to:
225
+ - Share ideas
226
+ - Report issues
227
+ - Contribute code
228
+ - Learn from others
229
+
230
+ ## 📚 Citation
231
+
232
+ ```bibtex
233
+ @software{Li_LionAGI_2023,
234
+ author = {Haiyang Li},
235
+ month = {12},
236
+ year = {2023},
237
+ title = {LionAGI: Intelligent Integration Framework},
238
+ url = {https://github.com/lion-agi/lionagi},
239
+ }
240
+ ```
241
+
@@ -40,14 +40,8 @@ lionagi/core/director/README.md,sha256=HoIDnEmWmWXVeDfUvkyf4nXQOYqzy2jhToZcJz0zm
40
40
  lionagi/core/director/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  lionagi/core/director/direct.py,sha256=vKcirI2vp9CvU6Y7SoznaLwppJpI9j9YBo0cvfWwxiM,9552
42
42
  lionagi/core/director/director.py,sha256=E-zgbAj5gbUgDrfE0YzFoipZnr0WWGZwIreEGGY2KJc,103
43
- lionagi/core/director/models/__init__.py,sha256=2SSysv4nrZ998HRt9a1BeoWcgVu91Nx3dy2NL4kkHDc,300
44
- lionagi/core/director/models/action_model.py,sha256=Wj04sHRlgPYiQJWEbJlzQsxKPsW4f0KkZsSWYqCcfME,1843
45
- lionagi/core/director/models/brainstorm_model.py,sha256=1P2qX58qJDb1r4U14iFdl5aHtKCg7oYBUXavYc1xzIc,1177
46
- lionagi/core/director/models/plan_model.py,sha256=SqaJlUXT7un-VTHk_LS3jjd00drMJEY4mJfNRwtalXk,1453
47
- lionagi/core/director/models/reason_model.py,sha256=anY5fvszbABci74YvQnTVtvSh59I1cj9ZNw6A8GHfB8,2124
48
- lionagi/core/director/models/step_model.py,sha256=oB_mSwlZjp5csX4YDgdX9BIu0iIefLxAhqoZU0qetXs,2008
49
43
  lionagi/core/director/operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
- lionagi/core/director/operations/select.py,sha256=6oqZVQMzkgizzHXuhuUmdySfDTLGRTzFEr1yTyRw9No,2834
44
+ lionagi/core/director/operations/select.py,sha256=0B1SXwkNdPM8z6aarECcw1I_AbiMIns7rYDSx1eyCBE,67
51
45
  lionagi/core/director/operations/utils.py,sha256=nuCvA6hXAi0oPFPdV_5kyHLGLlk1FbqhGfH2N0kPF9I,132
52
46
  lionagi/core/engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
47
  lionagi/core/engine/branch_engine.py,sha256=l59CTLk-ecsc_NgNgT3DkgP4OuuQ1lzdcOdDqie0H-k,12700
@@ -81,10 +75,6 @@ lionagi/core/message/instruction.py,sha256=I_ZqMx3IjIwGlAx3bdlBuyVycTZ9yO1i-kEP5
81
75
  lionagi/core/message/message.py,sha256=Etl4a3mUrXLsym7i6ILqTV_Xun0xZw0UCoBMl1OtsNE,2403
82
76
  lionagi/core/message/system.py,sha256=48mvib50mno9F-8fkLa8SzPxz3G1KlRgz3GkIluMFUQ,2318
83
77
  lionagi/core/message/util.py,sha256=7CFw90QA3CdnV43aQ3PU6p1fhtaTixnlj_SBkLyQmpM,9313
84
- lionagi/core/operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
85
- lionagi/core/operations/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
- lionagi/core/operations/direct/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
- lionagi/core/operative/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
78
  lionagi/core/report/__init__.py,sha256=KqfJNaSx9fzRw3eyrlIlYIiueo-jVYMgjaOdfzTUAN4,80
89
79
  lionagi/core/report/base.py,sha256=_PRSd92JttwEKnW_UX7SszpV29bLg6wPwJ_Lav-Z-9k,7173
90
80
  lionagi/core/report/form.py,sha256=IPZk5D5Ai-GV6DrvrZBoEkwIFT7_vwv8h3qME8Tph-M,7040
@@ -95,7 +85,7 @@ lionagi/core/rule/_default.py,sha256=EtKfqz6CWmF4EnzPsXCy37rn7x8VhdqiMLyfqG_N2xU
95
85
  lionagi/core/rule/action.py,sha256=9NCXzRa-eRyV1XpeC1ranlADQcpWrPezP0hzqdlwEv4,2592
96
86
  lionagi/core/rule/base.py,sha256=6MmAEu3eR9X_UBPgwAtBeOAzUHuNndlnxqY6lijZfGA,7070
97
87
  lionagi/core/rule/boolean.py,sha256=JuqVcgVWlKwZd_Y_b7i2SC7lLEAiUJlAkAvC9aYb5tI,1470
98
- lionagi/core/rule/choice.py,sha256=lQ6xYQcRMYNmBrsQ1L1JbHfb2jsbQWwLGgV_JLhbt8U,1464
88
+ lionagi/core/rule/choice.py,sha256=uj2CAPmTCdllQDYTj-tsk_V0_-xCGR7mKCOldY2rISE,1486
99
89
  lionagi/core/rule/mapping.py,sha256=jeVRbHpe3gLQ8voJGru7uwd_Ca1wqtVn6PlkR4q7u0Y,2545
100
90
  lionagi/core/rule/number.py,sha256=YKcb7HZ89ktWdLd8dA2azLg2p5HALQWqMsIm98Xw8Dw,2276
101
91
  lionagi/core/rule/rulebook.py,sha256=uBAPMzaCcH9Mr01K_w2HZ6TJIXNtKLS8ZdV3e-17nEQ,1023
@@ -246,21 +236,14 @@ lionagi/lions/researcher/data_source/finhub_.py,sha256=W63daXgIwHJQ6TDMR2ALQIDk1
246
236
  lionagi/lions/researcher/data_source/google_.py,sha256=401SKHQaSpxiOUoXl7stadl4qeF7SIX72lUNK7bKesg,6797
247
237
  lionagi/lions/researcher/data_source/wiki_.py,sha256=UPoa2dk_y5sELu7_rkdme2auDpUmc_Dn0Avgjwr2X2g,3145
248
238
  lionagi/lions/researcher/data_source/yfinance_.py,sha256=snAf897J69MyAc6fcFjF0irrMjbAh81EZ3RvaFT3hxE,977
249
- lionagi/operations/brainstorm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
250
- lionagi/operations/brainstorm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
251
- lionagi/operations/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
252
- lionagi/operations/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
253
- lionagi/operations/plan/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
254
- lionagi/operations/plan/base.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
255
- lionagi/operations/query/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
256
- lionagi/operations/rank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
257
- lionagi/operations/react/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
258
- lionagi/operations/route/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
259
- lionagi/operations/score/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
260
- lionagi/operations/select/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
261
- lionagi/operations/strategize/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
262
- lionagi/version.py,sha256=J0I0c7-a50EOnWXMryTu_E6xhXSYFBPjVpeYP_a3vRI,22
263
- lionagi-0.3.7.dist-info/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
264
- lionagi-0.3.7.dist-info/METADATA,sha256=6F2nnUX1ORQQo6giNHPHh3iuZb8AZxNs5Nw-XsqqutQ,3190
265
- lionagi-0.3.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
266
- lionagi-0.3.7.dist-info/RECORD,,
239
+ lionagi/operations/__init__.py,sha256=T7fbKqrZxLzWPpv7nYxpoMzwSfaAgyxCJwA1gQ6rVK4,163
240
+ lionagi/operations/brainstorm.py,sha256=GxLjY_IOss62UKNaFF2CUXNBrcF_D7tk-R7ZxaFkQlE,2319
241
+ lionagi/operations/config.py,sha256=DIhifP4SLV3SVa5eXCHbDNvCD6lEB3fAbgOtY6b2PHg,133
242
+ lionagi/operations/rank.py,sha256=17g-LFvN0h0VEFKOrhY9Mw7U6StZGI78zUuVRPAmnbY,3075
243
+ lionagi/operations/score.py,sha256=lSG4EgNMkiAN3c3HrpZtnSw2-bHkFN5y3ZlvI85-VLE,3874
244
+ lionagi/operations/select.py,sha256=MTJoT4oouugPU4pG0UkoozX38iysGhvlmgk2DeJGJ3E,4044
245
+ lionagi/version.py,sha256=7dTW0A5-FkrEuNOotvR8oW59M2lvIwYouVqfJzvXpKk,22
246
+ lionagi-0.3.8.dist-info/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
247
+ lionagi-0.3.8.dist-info/METADATA,sha256=F-R8jMWmz5tVglwI8tfkRZmC1euF-Z11_a9IcOBc2fU,6517
248
+ lionagi-0.3.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
249
+ lionagi-0.3.8.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- from .action_model import ActionModel
2
- from .brainstorm_model import BrainstormModel
3
- from .plan_model import PlanModel
4
- from .reason_model import ReasonModel
5
- from .step_model import StepModel
6
-
7
- __all__ = [
8
- "ReasonModel",
9
- "StepModel",
10
- "BrainstormModel",
11
- "ActionModel",
12
- "PlanModel",
13
- ]
@@ -1,61 +0,0 @@
1
- from typing import Any
2
-
3
- from lionfuncs import to_dict, validate_str
4
- from pydantic import BaseModel, Field, field_validator
5
-
6
-
7
- class ActionModel(BaseModel):
8
-
9
- title: str = Field(
10
- ...,
11
- title="Title",
12
- description="Provide a concise title summarizing the action.",
13
- )
14
- content: str = Field(
15
- ...,
16
- title="Content",
17
- description="Provide a brief description of the action to be performed.",
18
- )
19
- function: str = Field(
20
- ...,
21
- title="Function",
22
- description=(
23
- "Specify the name of the function to execute. **Choose from the provided "
24
- "`tool_schema`; do not invent function names.**"
25
- ),
26
- examples=["print", "add", "len"],
27
- )
28
- arguments: dict[str, Any] = Field(
29
- {},
30
- title="Arguments",
31
- description=(
32
- "Provide the arguments to pass to the function as a dictionary. **Use "
33
- "argument names and types as specified in the `tool_schema`; do not "
34
- "invent argument names.**"
35
- ),
36
- examples=[{"num1": 1, "num2": 2}, {"x": "hello", "y": "world"}],
37
- )
38
-
39
- @field_validator("title", mode="before")
40
- def validate_title(cls, value: Any) -> str:
41
- return validate_str(value, "title")
42
-
43
- @field_validator("content", mode="before")
44
- def validate_content(cls, value: Any) -> str:
45
- return validate_str(value, "content")
46
-
47
- @field_validator("function", mode="before")
48
- def validate_function(cls, value: Any) -> str:
49
- return validate_str(value, "function")
50
-
51
- @field_validator("arguments", mode="before")
52
- def validate_arguments(cls, value: Any) -> dict[str, Any]:
53
- return to_dict(
54
- value,
55
- fuzzy_parse=True,
56
- suppress=True,
57
- recursive=True,
58
- )
59
-
60
-
61
- __all__ = ["ActionModel"]
@@ -1,42 +0,0 @@
1
- from typing import Any
2
-
3
- from lionfuncs import validate_str
4
- from pydantic import BaseModel, Field, field_validator
5
-
6
- from .reason_model import ReasonModel
7
- from .step_model import StepModel
8
-
9
-
10
- class BrainstormModel(BaseModel):
11
-
12
- title: str = Field(
13
- ...,
14
- title="Title",
15
- description="Provide a concise title summarizing the brainstorming session.",
16
- )
17
- content: str = Field(
18
- ...,
19
- title="Content",
20
- description="Describe the context or focus of the brainstorming session.",
21
- )
22
- ideas: list[StepModel] = Field(
23
- ...,
24
- title="Ideas",
25
- description="A list of ideas for the next step, generated during brainstorming.",
26
- )
27
- reason: ReasonModel = Field(
28
- ...,
29
- title="Reason",
30
- description="Provide the high level reasoning behind the brainstorming session.",
31
- )
32
-
33
- @field_validator("title", mode="before")
34
- def validate_title(cls, value: Any) -> str:
35
- return validate_str(value, "title")
36
-
37
- @field_validator("content", mode="before")
38
- def validate_content(cls, value: Any) -> str:
39
- return validate_str(value, "content")
40
-
41
-
42
- __all__ = ["BrainstormModel"]
@@ -1,51 +0,0 @@
1
- from typing import Any, List
2
-
3
- from lionfuncs import validate_str
4
- from pydantic import BaseModel, Field, field_validator
5
-
6
- from .reason_model import ReasonModel
7
- from .step_model import StepModel
8
-
9
-
10
- class PlanModel(BaseModel):
11
- """
12
- Represents a plan consisting of multiple steps, with an overall reason.
13
-
14
- Attributes:
15
- title (str): A concise title summarizing the plan.
16
- content (str): A detailed description of the plan.
17
- reason (ReasonModel): The overall reasoning behind the plan.
18
- steps (List[StepModel]): A list of steps to execute the plan.
19
- """
20
-
21
- title: str = Field(
22
- ...,
23
- title="Title",
24
- description="Provide a concise title summarizing the plan.",
25
- )
26
- content: str = Field(
27
- ...,
28
- title="Content",
29
- description="Provide a detailed description of the plan.",
30
- )
31
- reason: ReasonModel = Field(
32
- ...,
33
- title="Reason",
34
- description="Provide the reasoning behind the entire plan.",
35
- )
36
- steps: list[StepModel] = Field(
37
- ...,
38
- title="Steps",
39
- description="A list of steps to execute the plan.",
40
- )
41
-
42
- @field_validator("title", mode="before")
43
- def validate_title(cls, value: Any) -> str:
44
- return validate_str(value, "title")
45
-
46
- @field_validator("content", mode="before")
47
- def validate_content(cls, value: Any) -> str:
48
- return validate_str(value, "content")
49
-
50
-
51
- __all__ = ["PlanModel"]
@@ -1,63 +0,0 @@
1
- import logging
2
- from typing import Any
3
-
4
- from lionfuncs import to_num, validate_str
5
- from pydantic import BaseModel, Field, field_validator
6
-
7
-
8
- class ReasonModel(BaseModel):
9
- title: str = Field(
10
- ...,
11
- title="Title",
12
- description="Provide a concise title summarizing the reason.",
13
- )
14
- content: str = Field(
15
- ...,
16
- title="Content",
17
- description=(
18
- "Provide a detailed explanation supporting the reason, including relevant "
19
- "information or context."
20
- ),
21
- )
22
- confidence_score: float | None = Field(
23
- None,
24
- description=(
25
- "Provide an objective numeric confidence score between 0 and 1 (with 3 "
26
- "decimal places) indicating how likely you successfully achieved the task "
27
- "according to user expectation. Interpret the score as:\n"
28
- "- **1**: Very confident in a good job.\n"
29
- "- **0**: Not confident at all.\n"
30
- "- **[0.8, 1]**: You can continue the path of reasoning if needed.\n"
31
- "- **[0.5, 0.8)**: Recheck your reasoning and consider reverting to a "
32
- "previous, more confident reasoning path.\n"
33
- "- **[0, 0.5)**: Stop because the reasoning is starting to be off track."
34
- ),
35
- examples=[0.821, 0.257, 0.923, 0.439],
36
- ge=0,
37
- le=1,
38
- )
39
-
40
- @field_validator("title", mode="before")
41
- def validate_title(cls, value: Any) -> str:
42
- return validate_str(value, "title")
43
-
44
- @field_validator("content", mode="before")
45
- def validate_content(cls, value: Any) -> str:
46
- return validate_str(value, "content")
47
-
48
- @field_validator("confidence_score", mode="before")
49
- def validate_confidence_score(cls, value: Any) -> float:
50
- try:
51
- return to_num(
52
- value,
53
- upper_bound=1,
54
- lower_bound=0,
55
- num_type=float,
56
- precision=3,
57
- )
58
- except Exception as e:
59
- logging.error(f"Failed to convert {value} to a number. Error: {e}")
60
- return 0.0
61
-
62
-
63
- __all__ = ["ReasonModel"]
@@ -1,65 +0,0 @@
1
- import logging
2
- from typing import Any
3
-
4
- from lionfuncs import validate_boolean, validate_str
5
- from pydantic import BaseModel, Field, field_validator
6
-
7
- from .action_model import ActionModel
8
- from .reason_model import ReasonModel
9
-
10
-
11
- class StepModel(BaseModel):
12
- title: str = Field(
13
- ...,
14
- title="Title",
15
- description="Provide a concise title summarizing the step.",
16
- )
17
- content: str = Field(
18
- ...,
19
- title="Content",
20
- description="Describe the content of the step in detail.",
21
- )
22
- reason: ReasonModel = Field(
23
- ...,
24
- title="Reason",
25
- description="Provide the reasoning behind this step, including supporting details.",
26
- )
27
- action_required: bool = Field(
28
- False,
29
- title="Action Required",
30
- description=(
31
- "Indicate whether this step requires an action. Set to **True** if an "
32
- "action is required; otherwise, set to **False**."
33
- ),
34
- )
35
- actions: list[ActionModel] = Field(
36
- [],
37
- title="Actions",
38
- description=(
39
- "List of actions to be performed if `action_required` is **True**. Leave "
40
- "empty if no action is required. **When providing actions, you must "
41
- "choose from the provided `tool_schema`. Do not invent function or "
42
- "argument names.**"
43
- ),
44
- )
45
-
46
- @field_validator("title", mode="before")
47
- def validate_title(cls, value: Any) -> str:
48
- return validate_str(value, "title")
49
-
50
- @field_validator("content", mode="before")
51
- def validate_content(cls, value: Any) -> str:
52
- return validate_str(value, "content")
53
-
54
- @field_validator("action_required", mode="before")
55
- def validate_action_required(cls, value: Any) -> bool:
56
- try:
57
- return validate_boolean(value)
58
- except Exception as e:
59
- logging.error(
60
- f"Failed to convert {value} to a boolean. Error: {e}"
61
- )
62
- return False
63
-
64
-
65
- __all__ = ["StepModel"]
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
File without changes
File without changes