66"""
77
88import logging
9- from typing import Union , Dict , Any
9+ from typing import Any , Dict , Union
1010
11- from .workflow import Workflow , create_graph
1211from .configuration import ConfigLoader , load_config
1312from .exceptions import (
14- GraSPError ,
15- ValidationError ,
16- ExecutionError ,
1713 ConfigurationError ,
18- NodeError ,
1914 DataError ,
15+ ExecutionError ,
16+ GraSPError ,
2017 ModelError ,
18+ NodeError ,
2119 TimeoutError ,
20+ ValidationError ,
2221)
2322from .models import ModelConfigBuilder
23+ from .workflow import Workflow , create_graph
2424
2525try :
2626 from .core .base_task_executor import BaseTaskExecutor , DefaultTaskExecutor
27- from .core .judge_task_executor import JudgeQualityTaskExecutor
28- from .core .resumable_execution import ResumableExecutionManager
2927 from .core .dataset .dataset_processor import DatasetProcessor
3028 from .core .graph .graph_config import GraphConfig
31- from .core .graph .grasp_state import GraspState
3229 from .core .graph .grasp_message import GraspMessage
30+ from .core .graph .grasp_state import GraspState
31+ from .core .judge_task_executor import JudgeQualityTaskExecutor
32+ from .core .resumable_execution import ResumableExecutionManager
3333
3434 CORE_AVAILABLE = True
3535except ImportError as e :
3939try :
4040 from .core .dataset .dataset_config import (
4141 DataSourceConfig ,
42- OutputConfig ,
4342 DataSourceType ,
43+ OutputConfig ,
4444 OutputType ,
45- TransformConfig ,
4645 ShardConfig ,
46+ TransformConfig ,
4747 )
4848 from .core .dataset .file_handler import FileHandler
4949 from .core .dataset .huggingface_handler import HuggingFaceHandler
5454
5555# Node modules
5656try :
57- from .core .graph .nodes .base_node import BaseNode , NodeType , NodeState
58- from .core .graph .nodes .llm_node import LLMNode as CoreLLMNode
5957 from .core .graph .nodes .agent_node import AgentNode as CoreAgentNode
58+ from .core .graph .nodes .base_node import BaseNode , NodeState , NodeType
59+ from .core .graph .nodes .llm_node import LLMNode as CoreLLMNode
6060 from .core .graph .nodes .multi_llm_node import MultiLLMNode as CoreMultiLLMNode
6161 from .core .graph .nodes .weighted_sampler_node import (
6262 WeightedSamplerNode as CoreWeightedSamplerNode ,
6969# Model factory modules
7070try :
7171 from .core .models .model_factory import ModelFactory
72+ from .core .models .structured_output .schemas_factory import SimpleResponse
7273 from .core .models .structured_output .structured_output_config import (
7374 StructuredOutputConfig ,
7475 )
75- from .core .models .structured_output .schemas_factory import SimpleResponse
7676
7777 MODELS_AVAILABLE = True
7878except ImportError :
8181# Utility modules
8282try :
8383 from . import utils
84- from .utils import constants
8584 from .logger .logger_config import (
8685 logger ,
87- set_external_logger ,
8886 reset_to_internal_logger ,
87+ set_external_logger ,
8988 )
89+ from .utils import constants
9090
9191 UTILS_AVAILABLE = True
9292except ImportError :
9595# Import node builders
9696try :
9797 from .nodes import (
98- LLMNodeBuilder ,
9998 AgentNodeBuilder ,
100- MultiLLMNodeBuilder ,
10199 LambdaNodeBuilder ,
102- WeightedSamplerNodeBuilder ,
100+ LLMNodeBuilder ,
101+ MultiLLMNodeBuilder ,
103102 SubgraphNodeBuilder ,
103+ WeightedSamplerNodeBuilder ,
104104 )
105105
106106 NODE_BUILDERS_AVAILABLE = True
110110# Import data utilities
111111try :
112112 from .data import (
113- DataSource ,
114113 DataSink ,
115- DataSourceFactory ,
116114 DataSinkFactory ,
115+ DataSource ,
116+ DataSourceFactory ,
117117 from_file ,
118118 from_huggingface ,
119119 to_file ,
@@ -161,12 +161,7 @@ def quick_multi_llm(
161161 models : Dict [str , str ], prompt : str , data_source : str , output : str = "output.json"
162162):
163163 """Quick multi-LLM workflow creation."""
164- return (
165- Workflow ("quick_multi_llm" )
166- .source (data_source )
167- .multi_llm (models , prompt )
168- .sink (output )
169- )
164+ return Workflow ("quick_multi_llm" ).source (data_source ).multi_llm (models , prompt ).sink (output )
170165
171166
172167def execute_task (task_name : str , ** kwargs ):
@@ -203,17 +198,14 @@ def create_chat_workflow(name: str, conversation_type: str = "multiturn") -> Wor
203198 return workflow
204199
205200
206- def create_structured_schema (
207- fields : Dict [str , str ], name : str = "CustomSchema"
208- ) -> Dict [str , Any ]:
201+ def create_structured_schema (fields : Dict [str , str ], name : str = "CustomSchema" ) -> Dict [str , Any ]:
209202 """Create structured output schema configuration."""
210203 return {
211204 "enabled" : True ,
212205 "schema" : {
213206 "name" : name ,
214207 "fields" : {
215- field_name : {"type" : field_type }
216- for field_name , field_type in fields .items ()
208+ field_name : {"type" : field_type } for field_name , field_type in fields .items ()
217209 },
218210 },
219211 }
@@ -224,9 +216,7 @@ def pydantic_schema(model_class: str) -> Dict[str, Any]:
224216 return {"enabled" : True , "schema" : model_class }
225217
226218
227- def create_processor_config (
228- processor : Union [str , callable ], ** params
229- ) -> Dict [str , Any ]:
219+ def create_processor_config (processor : Union [str , callable ], ** params ) -> Dict [str , Any ]:
230220 """Create processor configuration."""
231221 if callable (processor ):
232222 processor_path = f"{ processor .__module__ } .{ processor .__name__ } "
@@ -240,9 +230,7 @@ def create_processor_config(
240230 return config
241231
242232
243- def create_transformation_config (
244- transform : Union [str , callable ], ** params
245- ) -> Dict [str , Any ]:
233+ def create_transformation_config (transform : Union [str , callable ], ** params ) -> Dict [str , Any ]:
246234 """Create data transformation configuration."""
247235 if callable (transform ):
248236 transform_path = f"{ transform .__module__ } .{ transform .__name__ } "
0 commit comments