aiecs 1.1.0__py3-none-any.whl → 1.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.
Potentially problematic release.
This version of aiecs might be problematic. Click here for more details.
- aiecs/__init__.py +1 -1
- aiecs/config/config.py +2 -0
- aiecs/domain/__init__.py +95 -0
- aiecs/domain/community/__init__.py +159 -0
- aiecs/domain/community/agent_adapter.py +516 -0
- aiecs/domain/community/analytics.py +465 -0
- aiecs/domain/community/collaborative_workflow.py +99 -7
- aiecs/domain/community/communication_hub.py +649 -0
- aiecs/domain/community/community_builder.py +322 -0
- aiecs/domain/community/community_integration.py +365 -12
- aiecs/domain/community/community_manager.py +481 -5
- aiecs/domain/community/decision_engine.py +459 -13
- aiecs/domain/community/exceptions.py +238 -0
- aiecs/domain/community/models/__init__.py +36 -0
- aiecs/domain/community/resource_manager.py +1 -1
- aiecs/domain/community/shared_context_manager.py +621 -0
- aiecs/domain/context/context_engine.py +37 -33
- aiecs/main.py +2 -2
- aiecs/scripts/aid/VERSION_MANAGEMENT.md +97 -0
- aiecs/scripts/aid/__init__.py +15 -0
- aiecs/scripts/aid/version_manager.py +224 -0
- aiecs/scripts/dependance_check/download_nlp_data.py +1 -0
- aiecs/tools/__init__.py +23 -23
- aiecs/tools/docs/__init__.py +5 -2
- aiecs/tools/docs/ai_document_orchestrator.py +39 -26
- aiecs/tools/docs/ai_document_writer_orchestrator.py +61 -38
- aiecs/tools/docs/content_insertion_tool.py +48 -28
- aiecs/tools/docs/document_creator_tool.py +47 -29
- aiecs/tools/docs/document_layout_tool.py +35 -20
- aiecs/tools/docs/document_parser_tool.py +56 -36
- aiecs/tools/docs/document_writer_tool.py +115 -62
- aiecs/tools/schema_generator.py +56 -56
- aiecs/tools/statistics/__init__.py +82 -0
- aiecs/tools/statistics/ai_data_analysis_orchestrator.py +581 -0
- aiecs/tools/statistics/ai_insight_generator_tool.py +473 -0
- aiecs/tools/statistics/ai_report_orchestrator_tool.py +629 -0
- aiecs/tools/statistics/data_loader_tool.py +518 -0
- aiecs/tools/statistics/data_profiler_tool.py +599 -0
- aiecs/tools/statistics/data_transformer_tool.py +531 -0
- aiecs/tools/statistics/data_visualizer_tool.py +460 -0
- aiecs/tools/statistics/model_trainer_tool.py +470 -0
- aiecs/tools/statistics/statistical_analyzer_tool.py +426 -0
- aiecs/tools/task_tools/chart_tool.py +2 -1
- aiecs/tools/task_tools/image_tool.py +43 -43
- aiecs/tools/task_tools/office_tool.py +39 -36
- aiecs/tools/task_tools/pandas_tool.py +37 -33
- aiecs/tools/task_tools/report_tool.py +67 -56
- aiecs/tools/task_tools/research_tool.py +32 -31
- aiecs/tools/task_tools/scraper_tool.py +53 -46
- aiecs/tools/task_tools/search_tool.py +1123 -0
- aiecs/tools/task_tools/stats_tool.py +20 -15
- {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/METADATA +5 -1
- {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/RECORD +57 -36
- {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/entry_points.txt +1 -0
- aiecs/tools/task_tools/search_api.py +0 -7
- {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/WHEEL +0 -0
- {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/licenses/LICENSE +0 -0
- {aiecs-1.1.0.dist-info → aiecs-1.2.0.dist-info}/top_level.txt +0 -0
aiecs/tools/schema_generator.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Automatic Schema Generation Tool
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Automatically generate Pydantic Schema from method signatures and type annotations
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import inspect
|
|
@@ -14,14 +14,14 @@ logger = logging.getLogger(__name__)
|
|
|
14
14
|
|
|
15
15
|
def _normalize_type(param_type: Type) -> Type:
|
|
16
16
|
"""
|
|
17
|
-
|
|
17
|
+
Normalize types, handle unsupported types
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Map complex types like pandas.DataFrame to Any
|
|
20
20
|
"""
|
|
21
|
-
#
|
|
21
|
+
# Get type name
|
|
22
22
|
type_name = getattr(param_type, '__name__', str(param_type))
|
|
23
23
|
|
|
24
|
-
#
|
|
24
|
+
# Check if it's a pandas type
|
|
25
25
|
if 'DataFrame' in type_name or 'Series' in type_name:
|
|
26
26
|
return Any
|
|
27
27
|
|
|
@@ -30,9 +30,9 @@ def _normalize_type(param_type: Type) -> Type:
|
|
|
30
30
|
|
|
31
31
|
def _extract_param_description_from_docstring(docstring: str, param_name: str) -> Optional[str]:
|
|
32
32
|
"""
|
|
33
|
-
|
|
33
|
+
Extract parameter description from docstring
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Supported formats:
|
|
36
36
|
- Google style: Args: param_name: description
|
|
37
37
|
- NumPy style: Parameters: param_name : type description
|
|
38
38
|
"""
|
|
@@ -47,26 +47,26 @@ def _extract_param_description_from_docstring(docstring: str, param_name: str) -
|
|
|
47
47
|
for line in lines:
|
|
48
48
|
stripped = line.strip()
|
|
49
49
|
|
|
50
|
-
#
|
|
50
|
+
# Detect Args/Parameters section
|
|
51
51
|
if stripped in ['Args:', 'Arguments:', 'Parameters:']:
|
|
52
52
|
in_args_section = True
|
|
53
53
|
continue
|
|
54
54
|
|
|
55
|
-
#
|
|
55
|
+
# Detect end
|
|
56
56
|
if in_args_section and stripped in ['Returns:', 'Raises:', 'Yields:', 'Examples:', 'Note:', 'Notes:']:
|
|
57
57
|
break
|
|
58
58
|
|
|
59
59
|
if in_args_section:
|
|
60
|
-
# Google style: param_name: description
|
|
60
|
+
# Google style: param_name: description or param_name (type): description
|
|
61
61
|
if ':' in stripped and not stripped.startswith(' '):
|
|
62
|
-
#
|
|
62
|
+
# Save previous parameter
|
|
63
63
|
if current_param == param_name and description_lines:
|
|
64
64
|
return ' '.join(description_lines).strip()
|
|
65
65
|
|
|
66
|
-
#
|
|
66
|
+
# Parse new parameter
|
|
67
67
|
parts = stripped.split(':', 1)
|
|
68
68
|
if len(parts) == 2:
|
|
69
|
-
#
|
|
69
|
+
# Remove possible type annotation (type)
|
|
70
70
|
param_part = parts[0].strip()
|
|
71
71
|
if '(' in param_part:
|
|
72
72
|
param_part = param_part.split('(')[0].strip()
|
|
@@ -74,10 +74,10 @@ def _extract_param_description_from_docstring(docstring: str, param_name: str) -
|
|
|
74
74
|
current_param = param_part
|
|
75
75
|
description_lines = [parts[1].strip()]
|
|
76
76
|
elif current_param and stripped:
|
|
77
|
-
#
|
|
77
|
+
# Continue description
|
|
78
78
|
description_lines.append(stripped)
|
|
79
79
|
|
|
80
|
-
#
|
|
80
|
+
# Check last parameter
|
|
81
81
|
if current_param == param_name and description_lines:
|
|
82
82
|
return ' '.join(description_lines).strip()
|
|
83
83
|
|
|
@@ -90,59 +90,59 @@ def generate_schema_from_method(
|
|
|
90
90
|
base_class: Type[BaseModel] = BaseModel
|
|
91
91
|
) -> Optional[Type[BaseModel]]:
|
|
92
92
|
"""
|
|
93
|
-
|
|
93
|
+
Automatically generate Pydantic Schema from method signature
|
|
94
94
|
|
|
95
95
|
Args:
|
|
96
|
-
method:
|
|
97
|
-
method_name:
|
|
98
|
-
base_class: Schema
|
|
96
|
+
method: Method to generate Schema for
|
|
97
|
+
method_name: Method name
|
|
98
|
+
base_class: Schema base class
|
|
99
99
|
|
|
100
100
|
Returns:
|
|
101
|
-
|
|
101
|
+
Generated Pydantic Schema class, returns None if unable to generate
|
|
102
102
|
"""
|
|
103
103
|
try:
|
|
104
|
-
#
|
|
104
|
+
# Get method signature
|
|
105
105
|
sig = inspect.signature(method)
|
|
106
106
|
|
|
107
|
-
#
|
|
107
|
+
# Get type annotations
|
|
108
108
|
try:
|
|
109
109
|
type_hints = get_type_hints(method)
|
|
110
110
|
except Exception as e:
|
|
111
111
|
logger.debug(f"Failed to get type hints for {method_name}: {e}")
|
|
112
112
|
type_hints = {}
|
|
113
113
|
|
|
114
|
-
#
|
|
114
|
+
# Get docstring
|
|
115
115
|
docstring = inspect.getdoc(method) or f"Execute {method_name} operation"
|
|
116
116
|
|
|
117
|
-
#
|
|
117
|
+
# Extract short description (first line)
|
|
118
118
|
first_line = docstring.split('\n')[0].strip()
|
|
119
119
|
schema_description = first_line if first_line else f"Execute {method_name} operation"
|
|
120
120
|
|
|
121
|
-
#
|
|
121
|
+
# Build field definitions
|
|
122
122
|
field_definitions = {}
|
|
123
123
|
|
|
124
124
|
for param_name, param in sig.parameters.items():
|
|
125
|
-
#
|
|
125
|
+
# Skip self parameter
|
|
126
126
|
if param_name == 'self':
|
|
127
127
|
continue
|
|
128
128
|
|
|
129
|
-
#
|
|
129
|
+
# Get parameter type and normalize
|
|
130
130
|
param_type = type_hints.get(param_name, Any)
|
|
131
131
|
param_type = _normalize_type(param_type)
|
|
132
132
|
|
|
133
|
-
#
|
|
133
|
+
# Get default value
|
|
134
134
|
has_default = param.default != inspect.Parameter.empty
|
|
135
135
|
default_value = param.default if has_default else ...
|
|
136
136
|
|
|
137
|
-
#
|
|
137
|
+
# Extract parameter description from docstring
|
|
138
138
|
field_description = _extract_param_description_from_docstring(docstring, param_name)
|
|
139
139
|
if not field_description:
|
|
140
140
|
field_description = f"Parameter {param_name}"
|
|
141
141
|
|
|
142
|
-
#
|
|
142
|
+
# Create Field
|
|
143
143
|
if has_default:
|
|
144
144
|
if default_value is None:
|
|
145
|
-
# Optional
|
|
145
|
+
# Optional parameter
|
|
146
146
|
field_definitions[param_name] = (
|
|
147
147
|
param_type,
|
|
148
148
|
Field(default=None, description=field_description)
|
|
@@ -153,21 +153,21 @@ def generate_schema_from_method(
|
|
|
153
153
|
Field(default=default_value, description=field_description)
|
|
154
154
|
)
|
|
155
155
|
else:
|
|
156
|
-
#
|
|
156
|
+
# Required parameter
|
|
157
157
|
field_definitions[param_name] = (
|
|
158
158
|
param_type,
|
|
159
159
|
Field(description=field_description)
|
|
160
160
|
)
|
|
161
161
|
|
|
162
|
-
#
|
|
162
|
+
# If no parameters (except self), return None
|
|
163
163
|
if not field_definitions:
|
|
164
164
|
logger.debug(f"No parameters found for {method_name}, skipping schema generation")
|
|
165
165
|
return None
|
|
166
166
|
|
|
167
|
-
#
|
|
167
|
+
# Generate Schema class name
|
|
168
168
|
schema_name = f"{method_name.title().replace('_', '')}Schema"
|
|
169
169
|
|
|
170
|
-
#
|
|
170
|
+
# Create Schema class, allow arbitrary types
|
|
171
171
|
schema_class = create_model(
|
|
172
172
|
schema_name,
|
|
173
173
|
__base__=base_class,
|
|
@@ -186,40 +186,40 @@ def generate_schema_from_method(
|
|
|
186
186
|
|
|
187
187
|
def generate_schemas_for_tool(tool_class: Type) -> Dict[str, Type[BaseModel]]:
|
|
188
188
|
"""
|
|
189
|
-
|
|
189
|
+
Generate Schema for all methods of a tool class
|
|
190
190
|
|
|
191
191
|
Args:
|
|
192
|
-
tool_class:
|
|
192
|
+
tool_class: Tool class
|
|
193
193
|
|
|
194
194
|
Returns:
|
|
195
|
-
|
|
195
|
+
Mapping from method names to Schema classes
|
|
196
196
|
"""
|
|
197
197
|
schemas = {}
|
|
198
198
|
|
|
199
199
|
for method_name in dir(tool_class):
|
|
200
|
-
#
|
|
200
|
+
# Skip private methods and special methods
|
|
201
201
|
if method_name.startswith('_'):
|
|
202
202
|
continue
|
|
203
203
|
|
|
204
|
-
#
|
|
204
|
+
# Skip base class methods
|
|
205
205
|
if method_name in ['run', 'run_async', 'run_batch']:
|
|
206
206
|
continue
|
|
207
207
|
|
|
208
208
|
method = getattr(tool_class, method_name)
|
|
209
209
|
|
|
210
|
-
#
|
|
210
|
+
# Skip non-method attributes
|
|
211
211
|
if not callable(method):
|
|
212
212
|
continue
|
|
213
213
|
|
|
214
|
-
#
|
|
214
|
+
# Skip classes (like Config, Schema, etc.)
|
|
215
215
|
if isinstance(method, type):
|
|
216
216
|
continue
|
|
217
217
|
|
|
218
|
-
#
|
|
218
|
+
# Generate Schema
|
|
219
219
|
schema = generate_schema_from_method(method, method_name)
|
|
220
220
|
|
|
221
221
|
if schema:
|
|
222
|
-
#
|
|
222
|
+
# Normalize method name (remove underscores, convert to lowercase)
|
|
223
223
|
normalized_name = method_name.replace('_', '').lower()
|
|
224
224
|
schemas[normalized_name] = schema
|
|
225
225
|
logger.info(f"Generated schema for {method_name}")
|
|
@@ -230,36 +230,36 @@ def generate_schemas_for_tool(tool_class: Type) -> Dict[str, Type[BaseModel]]:
|
|
|
230
230
|
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
#
|
|
233
|
+
# Usage example
|
|
234
234
|
if __name__ == '__main__':
|
|
235
235
|
import sys
|
|
236
236
|
sys.path.insert(0, '/home/coder1/python-middleware-dev')
|
|
237
237
|
|
|
238
238
|
from aiecs.tools import discover_tools, TOOL_CLASSES
|
|
239
239
|
|
|
240
|
-
#
|
|
240
|
+
# Configure logging
|
|
241
241
|
logging.basicConfig(level=logging.INFO)
|
|
242
242
|
|
|
243
|
-
#
|
|
243
|
+
# Discover tools
|
|
244
244
|
discover_tools()
|
|
245
245
|
|
|
246
|
-
#
|
|
247
|
-
print("
|
|
246
|
+
# Generate Schema for PandasTool
|
|
247
|
+
print("Generating Schema for PandasTool:")
|
|
248
248
|
print("=" * 80)
|
|
249
249
|
|
|
250
250
|
pandas_tool = TOOL_CLASSES['pandas']
|
|
251
251
|
schemas = generate_schemas_for_tool(pandas_tool)
|
|
252
252
|
|
|
253
|
-
print(f"\
|
|
253
|
+
print(f"\nGenerated {len(schemas)} Schemas:\n")
|
|
254
254
|
|
|
255
|
-
#
|
|
255
|
+
# Show first 3 examples
|
|
256
256
|
for method_name, schema in list(schemas.items())[:3]:
|
|
257
257
|
print(f"{schema.__name__}:")
|
|
258
|
-
print(f"
|
|
259
|
-
print(f"
|
|
258
|
+
print(f" Description: {schema.__doc__}")
|
|
259
|
+
print(f" Fields:")
|
|
260
260
|
for field_name, field_info in schema.model_fields.items():
|
|
261
|
-
required = "
|
|
262
|
-
default = f" (
|
|
261
|
+
required = "Required" if field_info.is_required() else "Optional"
|
|
262
|
+
default = f" (default: {field_info.default})" if not field_info.is_required() and field_info.default is not None else ""
|
|
263
263
|
print(f" - {field_name}: {field_info.description} [{required}]{default}")
|
|
264
264
|
print()
|
|
265
265
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Statistics and Data Analysis Tools Module
|
|
3
|
+
|
|
4
|
+
This module contains specialized tools for data analysis and statistical operations:
|
|
5
|
+
- data_loader: Universal data loading from multiple file formats
|
|
6
|
+
- data_profiler: Comprehensive data profiling and quality assessment
|
|
7
|
+
- data_transformer: Data cleaning, transformation, and feature engineering
|
|
8
|
+
- data_visualizer: Smart data visualization and chart generation
|
|
9
|
+
- statistical_analyzer: Advanced statistical analysis and hypothesis testing
|
|
10
|
+
- model_trainer: AutoML and machine learning model training
|
|
11
|
+
- ai_data_analysis_orchestrator: AI-powered end-to-end analysis orchestration
|
|
12
|
+
- ai_insight_generator: AI-driven insight discovery and pattern detection
|
|
13
|
+
- ai_report_orchestrator: AI-powered comprehensive report generation
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# Lazy import strategy to avoid heavy dependencies at import time
|
|
17
|
+
import os
|
|
18
|
+
import logging
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
# Define available tools for lazy loading
|
|
23
|
+
_AVAILABLE_STATISTICS_TOOLS = [
|
|
24
|
+
'data_loader_tool',
|
|
25
|
+
'data_profiler_tool',
|
|
26
|
+
'data_transformer_tool',
|
|
27
|
+
'data_visualizer_tool',
|
|
28
|
+
'statistical_analyzer_tool',
|
|
29
|
+
'model_trainer_tool',
|
|
30
|
+
'ai_data_analysis_orchestrator',
|
|
31
|
+
'ai_insight_generator_tool',
|
|
32
|
+
'ai_report_orchestrator_tool'
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
# Track which tools have been loaded
|
|
36
|
+
_LOADED_STATISTICS_TOOLS = set()
|
|
37
|
+
|
|
38
|
+
def _lazy_load_statistics_tool(tool_name: str):
|
|
39
|
+
"""Lazy load a specific statistics tool module"""
|
|
40
|
+
if tool_name in _LOADED_STATISTICS_TOOLS:
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
if tool_name == 'data_loader_tool':
|
|
45
|
+
from . import data_loader_tool
|
|
46
|
+
elif tool_name == 'data_profiler_tool':
|
|
47
|
+
from . import data_profiler_tool
|
|
48
|
+
elif tool_name == 'data_transformer_tool':
|
|
49
|
+
from . import data_transformer_tool
|
|
50
|
+
elif tool_name == 'data_visualizer_tool':
|
|
51
|
+
from . import data_visualizer_tool
|
|
52
|
+
elif tool_name == 'statistical_analyzer_tool':
|
|
53
|
+
from . import statistical_analyzer_tool
|
|
54
|
+
elif tool_name == 'model_trainer_tool':
|
|
55
|
+
from . import model_trainer_tool
|
|
56
|
+
elif tool_name == 'ai_data_analysis_orchestrator':
|
|
57
|
+
from . import ai_data_analysis_orchestrator
|
|
58
|
+
elif tool_name == 'ai_insight_generator_tool':
|
|
59
|
+
from . import ai_insight_generator_tool
|
|
60
|
+
elif tool_name == 'ai_report_orchestrator_tool':
|
|
61
|
+
from . import ai_report_orchestrator_tool
|
|
62
|
+
|
|
63
|
+
_LOADED_STATISTICS_TOOLS.add(tool_name)
|
|
64
|
+
logger.info(f"Successfully loaded statistics tool: {tool_name}")
|
|
65
|
+
|
|
66
|
+
except Exception as e:
|
|
67
|
+
logger.warning(f"Failed to load statistics tool {tool_name}: {e}")
|
|
68
|
+
|
|
69
|
+
def load_all_statistics_tools():
|
|
70
|
+
"""Load all available statistics tools"""
|
|
71
|
+
for tool_name in _AVAILABLE_STATISTICS_TOOLS:
|
|
72
|
+
_lazy_load_statistics_tool(tool_name)
|
|
73
|
+
|
|
74
|
+
# Auto-load all tools when module is imported
|
|
75
|
+
# This ensures all tools are registered
|
|
76
|
+
load_all_statistics_tools()
|
|
77
|
+
|
|
78
|
+
__all__ = [
|
|
79
|
+
'load_all_statistics_tools',
|
|
80
|
+
'_lazy_load_statistics_tool'
|
|
81
|
+
]
|
|
82
|
+
|