flock-core 0.4.528__py3-none-any.whl → 0.5.0b0__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 flock-core might be problematic. Click here for more details.

Files changed (130) hide show
  1. flock/cli/execute_flock.py +1 -1
  2. flock/cli/manage_agents.py +6 -6
  3. flock/components/__init__.py +30 -0
  4. flock/components/evaluation/__init__.py +9 -0
  5. flock/components/evaluation/declarative_evaluation_component.py +222 -0
  6. flock/components/routing/__init__.py +15 -0
  7. flock/{routers/conditional/conditional_router.py → components/routing/conditional_routing_component.py} +61 -53
  8. flock/components/routing/default_routing_component.py +103 -0
  9. flock/components/routing/llm_routing_component.py +206 -0
  10. flock/components/utility/__init__.py +15 -0
  11. flock/{modules/enterprise_memory/enterprise_memory_module.py → components/utility/memory_utility_component.py} +195 -173
  12. flock/{modules/performance/metrics_module.py → components/utility/metrics_utility_component.py} +110 -95
  13. flock/{modules/output/output_module.py → components/utility/output_utility_component.py} +47 -45
  14. flock/core/__init__.py +26 -18
  15. flock/core/agent/__init__.py +16 -0
  16. flock/core/agent/flock_agent_components.py +104 -0
  17. flock/core/agent/flock_agent_execution.py +101 -0
  18. flock/core/agent/flock_agent_integration.py +206 -0
  19. flock/core/agent/flock_agent_lifecycle.py +177 -0
  20. flock/core/agent/flock_agent_serialization.py +381 -0
  21. flock/core/api/endpoints.py +2 -2
  22. flock/core/api/service.py +2 -2
  23. flock/core/component/__init__.py +15 -0
  24. flock/core/{flock_module.py → component/agent_component_base.py} +136 -34
  25. flock/core/component/evaluation_component.py +56 -0
  26. flock/core/component/routing_component.py +74 -0
  27. flock/core/component/utility_component.py +69 -0
  28. flock/core/config/flock_agent_config.py +49 -2
  29. flock/core/evaluation/utils.py +3 -2
  30. flock/core/execution/batch_executor.py +1 -1
  31. flock/core/execution/evaluation_executor.py +2 -2
  32. flock/core/execution/opik_executor.py +1 -1
  33. flock/core/flock.py +147 -493
  34. flock/core/flock_agent.py +195 -1032
  35. flock/core/flock_factory.py +114 -90
  36. flock/core/flock_scheduler.py +1 -1
  37. flock/core/flock_server_manager.py +8 -8
  38. flock/core/logging/logging.py +1 -0
  39. flock/core/mcp/flock_mcp_server.py +53 -48
  40. flock/core/mcp/{flock_mcp_tool_base.py → flock_mcp_tool.py} +2 -2
  41. flock/core/mcp/mcp_client.py +9 -9
  42. flock/core/mcp/mcp_client_manager.py +9 -9
  43. flock/core/mcp/mcp_config.py +24 -24
  44. flock/core/mixin/dspy_integration.py +5 -5
  45. flock/core/orchestration/__init__.py +18 -0
  46. flock/core/orchestration/flock_batch_processor.py +94 -0
  47. flock/core/orchestration/flock_evaluator.py +113 -0
  48. flock/core/orchestration/flock_execution.py +288 -0
  49. flock/core/orchestration/flock_initialization.py +125 -0
  50. flock/core/orchestration/flock_server_manager.py +67 -0
  51. flock/core/orchestration/flock_web_server.py +117 -0
  52. flock/core/registry/__init__.py +45 -0
  53. flock/core/registry/agent_registry.py +69 -0
  54. flock/core/registry/callable_registry.py +139 -0
  55. flock/core/registry/component_discovery.py +142 -0
  56. flock/core/registry/component_registry.py +64 -0
  57. flock/core/registry/config_mapping.py +64 -0
  58. flock/core/registry/decorators.py +137 -0
  59. flock/core/registry/registry_hub.py +205 -0
  60. flock/core/registry/server_registry.py +57 -0
  61. flock/core/registry/type_registry.py +86 -0
  62. flock/core/serialization/flock_serializer.py +36 -32
  63. flock/core/serialization/serialization_utils.py +28 -25
  64. flock/core/util/hydrator.py +1 -1
  65. flock/core/util/input_resolver.py +29 -2
  66. flock/mcp/servers/sse/flock_sse_server.py +10 -10
  67. flock/mcp/servers/stdio/flock_stdio_server.py +10 -10
  68. flock/mcp/servers/streamable_http/flock_streamable_http_server.py +10 -10
  69. flock/mcp/servers/websockets/flock_websocket_server.py +10 -10
  70. flock/platform/docker_tools.py +3 -3
  71. flock/webapp/app/chat.py +1 -1
  72. flock/webapp/app/main.py +9 -5
  73. flock/webapp/app/services/flock_service.py +1 -1
  74. flock/webapp/app/services/sharing_store.py +1 -0
  75. flock/workflow/activities.py +67 -92
  76. flock/workflow/agent_execution_activity.py +6 -6
  77. flock/workflow/flock_workflow.py +1 -1
  78. flock_core-0.5.0b0.dist-info/METADATA +272 -0
  79. {flock_core-0.4.528.dist-info → flock_core-0.5.0b0.dist-info}/RECORD +82 -95
  80. flock/core/flock_evaluator.py +0 -60
  81. flock/core/flock_registry.py +0 -702
  82. flock/core/flock_router.py +0 -83
  83. flock/evaluators/__init__.py +0 -1
  84. flock/evaluators/declarative/__init__.py +0 -1
  85. flock/evaluators/declarative/declarative_evaluator.py +0 -217
  86. flock/evaluators/memory/memory_evaluator.py +0 -90
  87. flock/evaluators/test/test_case_evaluator.py +0 -38
  88. flock/evaluators/zep/zep_evaluator.py +0 -59
  89. flock/modules/__init__.py +0 -1
  90. flock/modules/assertion/__init__.py +0 -1
  91. flock/modules/assertion/assertion_module.py +0 -286
  92. flock/modules/callback/__init__.py +0 -1
  93. flock/modules/callback/callback_module.py +0 -91
  94. flock/modules/enterprise_memory/README.md +0 -99
  95. flock/modules/mem0/__init__.py +0 -1
  96. flock/modules/mem0/mem0_module.py +0 -126
  97. flock/modules/mem0_async/__init__.py +0 -1
  98. flock/modules/mem0_async/async_mem0_module.py +0 -126
  99. flock/modules/memory/__init__.py +0 -1
  100. flock/modules/memory/memory_module.py +0 -429
  101. flock/modules/memory/memory_parser.py +0 -125
  102. flock/modules/memory/memory_storage.py +0 -736
  103. flock/modules/output/__init__.py +0 -1
  104. flock/modules/performance/__init__.py +0 -1
  105. flock/modules/zep/__init__.py +0 -1
  106. flock/modules/zep/zep_module.py +0 -192
  107. flock/routers/__init__.py +0 -1
  108. flock/routers/agent/__init__.py +0 -1
  109. flock/routers/agent/agent_router.py +0 -236
  110. flock/routers/agent/handoff_agent.py +0 -58
  111. flock/routers/default/__init__.py +0 -1
  112. flock/routers/default/default_router.py +0 -80
  113. flock/routers/feedback/feedback_router.py +0 -114
  114. flock/routers/list_generator/list_generator_router.py +0 -166
  115. flock/routers/llm/__init__.py +0 -1
  116. flock/routers/llm/llm_router.py +0 -365
  117. flock/tools/__init__.py +0 -0
  118. flock/tools/azure_tools.py +0 -781
  119. flock/tools/code_tools.py +0 -167
  120. flock/tools/file_tools.py +0 -149
  121. flock/tools/github_tools.py +0 -157
  122. flock/tools/markdown_tools.py +0 -205
  123. flock/tools/system_tools.py +0 -9
  124. flock/tools/text_tools.py +0 -810
  125. flock/tools/web_tools.py +0 -90
  126. flock/tools/zendesk_tools.py +0 -147
  127. flock_core-0.4.528.dist-info/METADATA +0 -675
  128. {flock_core-0.4.528.dist-info → flock_core-0.5.0b0.dist-info}/WHEEL +0 -0
  129. {flock_core-0.4.528.dist-info → flock_core-0.5.0b0.dist-info}/entry_points.txt +0 -0
  130. {flock_core-0.4.528.dist-info → flock_core-0.5.0b0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,56 @@
1
+ # src/flock/core/component/evaluation_component_base.py
2
+ """Base class for evaluation components in the unified component system."""
3
+
4
+ from abc import abstractmethod
5
+ from typing import Any
6
+
7
+ from flock.core.context.context import FlockContext
8
+
9
+ from .agent_component_base import AgentComponent
10
+
11
+
12
+ class EvaluationComponent(AgentComponent):
13
+ """Base class for evaluation components.
14
+
15
+ Evaluation components implement the core intelligence/logic of an agent.
16
+ They are responsible for taking inputs and producing outputs using some
17
+ evaluation strategy (e.g., DSPy, direct LLM calls, deterministic logic).
18
+
19
+ Each agent should have exactly one primary evaluation component.
20
+
21
+ Example implementations:
22
+ - DeclarativeEvaluationComponent (DSPy-based)
23
+ - ScriptEvaluationComponent (Python script-based)
24
+ - LLMEvaluationComponent (direct LLM API)
25
+ """
26
+
27
+ @abstractmethod
28
+ async def evaluate_core(
29
+ self,
30
+ agent: Any,
31
+ inputs: dict[str, Any],
32
+ context: FlockContext | None = None,
33
+ tools: list[Any] | None = None,
34
+ mcp_tools: list[Any] | None = None,
35
+ ) -> dict[str, Any]:
36
+ """Core evaluation logic - MUST be implemented by concrete classes.
37
+
38
+ This is the heart of the agent's intelligence. It takes the processed
39
+ inputs (after all on_pre_evaluate hooks) and produces the agent's output.
40
+
41
+ Args:
42
+ agent: The agent being executed
43
+ inputs: Input data for evaluation (after pre-processing)
44
+ context: Execution context with variables, history, etc.
45
+ tools: Available callable tools for the agent
46
+ mcp_tools: Available MCP server tools
47
+
48
+ Returns:
49
+ Evaluation result as a dictionary
50
+
51
+ Raises:
52
+ NotImplementedError: Must be implemented by concrete classes
53
+ """
54
+ raise NotImplementedError(
55
+ f"{self.__class__.__name__} must implement evaluate_core()"
56
+ )
@@ -0,0 +1,74 @@
1
+ # src/flock/core/component/routing_component_base.py
2
+ """Base class for routing components in the unified component system."""
3
+
4
+ from abc import abstractmethod
5
+ from typing import Any
6
+
7
+ from flock.core.context.context import FlockContext
8
+
9
+ from .agent_component_base import AgentComponent
10
+
11
+
12
+ class RoutingComponent(AgentComponent):
13
+ """Base class for routing components.
14
+
15
+ Routing components determine the next step in a workflow based on the
16
+ current agent's output. They implement workflow orchestration logic
17
+ and can enable complex multi-agent patterns.
18
+
19
+ Each agent should have at most one routing component. If no routing
20
+ component is present, the workflow ends after this agent.
21
+
22
+ Example implementations:
23
+ - ConditionalRoutingModule (rule-based routing)
24
+ - LLMRoutingModule (AI-powered routing decisions)
25
+ - DefaultRoutingModule (simple next-agent routing)
26
+ - ListGeneratorRoutingModule (dynamic agent creation)
27
+ """
28
+
29
+ @abstractmethod
30
+ async def determine_next_step(
31
+ self,
32
+ agent: Any,
33
+ result: dict[str, Any],
34
+ context: FlockContext | None = None,
35
+ ) -> str | Any | None:
36
+ """Determine the next agent in the workflow - MUST be implemented.
37
+
38
+ This method analyzes the agent's result and determines what agent
39
+ should execute next. The result will be stored in agent.next_agent
40
+ for the orchestrator to process.
41
+
42
+ Args:
43
+ agent: The agent that just completed execution
44
+ result: Result from the agent's evaluation (after post-processing)
45
+ context: Execution context with workflow state
46
+
47
+ Returns:
48
+ String (agent name), FlockAgent instance, or None to end workflow
49
+
50
+ Raises:
51
+ NotImplementedError: Must be implemented by concrete classes
52
+ """
53
+ raise NotImplementedError(
54
+ f"{self.__class__.__name__} must implement determine_next_step()"
55
+ )
56
+
57
+ async def evaluate_core(
58
+ self,
59
+ agent: Any,
60
+ inputs: dict[str, Any],
61
+ context: FlockContext | None = None,
62
+ tools: list[Any] | None = None,
63
+ mcp_tools: list[Any] | None = None,
64
+ ) -> dict[str, Any]:
65
+ """Routing components typically don't modify evaluation - pass through.
66
+
67
+ Routing components usually don't implement core evaluation logic,
68
+ they focus on workflow decisions. This default implementation
69
+ passes inputs through unchanged.
70
+
71
+ Override this if your routing component also needs to modify
72
+ the evaluation process.
73
+ """
74
+ return inputs
@@ -0,0 +1,69 @@
1
+ # src/flock/core/component/utility_component_base.py
2
+ """Base class for utility components in the unified component system."""
3
+
4
+ from typing import Any
5
+
6
+ from flock.core.context.context import FlockContext
7
+
8
+ # HandOffRequest removed - using agent.next_agent directly
9
+ from .agent_component_base import AgentComponent
10
+
11
+
12
+ class UtilityComponent(AgentComponent):
13
+ """Base class for utility/enhancement components.
14
+
15
+ Utility components add cross-cutting concerns to agents without being
16
+ the primary evaluation or routing logic. They typically use the standard
17
+ lifecycle hooks to enhance agent behavior.
18
+
19
+ These components focus on concerns like:
20
+ - Memory management
21
+ - Output formatting
22
+ - Metrics collection
23
+ - Logging and tracing
24
+ - Input validation
25
+ - Error handling
26
+ - Caching
27
+ - Rate limiting
28
+
29
+ Example implementations:
30
+ - MemoryUtilityModule (memory persistence)
31
+ - OutputUtilityModule (result formatting)
32
+ - MetricsUtilityModule (performance tracking)
33
+ - AssertionUtilityModule (result validation)
34
+ """
35
+
36
+ async def evaluate_core(
37
+ self,
38
+ agent: Any,
39
+ inputs: dict[str, Any],
40
+ context: FlockContext | None = None,
41
+ tools: list[Any] | None = None,
42
+ mcp_tools: list[Any] | None = None,
43
+ ) -> dict[str, Any]:
44
+ """Utility components typically don't implement core evaluation.
45
+
46
+ This default implementation passes inputs through unchanged.
47
+ Utility components usually enhance behavior through the standard
48
+ lifecycle hooks (on_pre_evaluate, on_post_evaluate, etc.).
49
+
50
+ Override this only if your utility component needs to participate
51
+ in the core evaluation process.
52
+ """
53
+ return inputs
54
+
55
+ async def determine_next_step(
56
+ self,
57
+ agent: Any,
58
+ result: dict[str, Any],
59
+ context: FlockContext | None = None,
60
+ ) -> None:
61
+ """Utility components typically don't implement routing logic.
62
+
63
+ This default implementation does nothing, as utility components
64
+ usually enhance behavior through other lifecycle hooks.
65
+
66
+ Override this only if your utility component needs to influence
67
+ workflow routing decisions by setting agent.next_agent.
68
+ """
69
+ pass
@@ -1,11 +1,58 @@
1
+ """Configuration settings for FlockAgent."""
1
2
 
3
+ from typing import Literal
2
4
 
3
- from pydantic import BaseModel
5
+ from pydantic import BaseModel, Field
4
6
 
5
7
 
6
8
  class FlockAgentConfig(BaseModel):
7
9
  """FlockAgentConfig is a class that holds the configuration for a Flock agent.
10
+
8
11
  It is used to store various settings and parameters that can be accessed throughout the agent's lifecycle.
9
12
  """
10
13
 
11
- pass
14
+ write_to_file: bool = Field(
15
+ default=False,
16
+ description="Write the agent's output to a file.",
17
+ )
18
+ wait_for_input: bool = Field(
19
+ default=False,
20
+ description="Wait for user input after the agent's output is displayed.",
21
+ )
22
+
23
+ handoff_strategy: Literal["append", "override", "static", "map"] = Field(
24
+ default="static",
25
+ description="""Strategy for passing data to the next agent.
26
+
27
+ example:
28
+ ReviewAgent.next_agent = SummaryAgent
29
+ ReviewAgent(output = "text:str, keywords:list[str], rating:int")
30
+ SummaryAgent(input = "text:str, title:str")
31
+
32
+ 'append' means the difference in signature is appended to the next agent's input signature.
33
+ SummaryAgent(input = "text:str, title:str, keywords:list[str], rating:int")
34
+
35
+ 'override' means the target agent's signature is getting overriden.
36
+ SummaryAgent(input = "text:str, keywords:list[str], rating:int")
37
+
38
+ 'static' means the the target agent's signature is not changed at all.
39
+ If source agent has no output fields that match the target agent's input,
40
+ there will be no data passed to the next agent.
41
+ SummaryAgent(input = "text:str, title:str")
42
+
43
+ 'map' means the source agent's output is mapped to the target agent's input
44
+ based on 'handoff_map' configuration.
45
+
46
+ """,
47
+ )
48
+
49
+ handoff_map: dict[str, str] | None = Field(
50
+ default=None,
51
+ description="""Mapping of source agent output fields to target agent input fields.
52
+
53
+ Used with 'handoff_strategy' = 'map'.
54
+ Example: {"text": "text", "keywords": "title"}
55
+
56
+ If a field is not mapped, it will not be passed to the next agent.
57
+ """,
58
+ )
@@ -17,7 +17,8 @@ from opik.evaluation import evaluate
17
17
 
18
18
  from flock.core.flock import Flock
19
19
  from flock.core.flock_agent import FlockAgent
20
- from flock.core.flock_evaluator import FlockEvaluator
20
+
21
+ # Legacy FlockEvaluator import removed
21
22
  from flock.core.logging.logging import get_logger
22
23
 
23
24
  # Potentially import metrics libraries like rouge_score, nltk, sentence_transformers
@@ -58,7 +59,7 @@ def evaluate_with_opik(
58
59
 
59
60
  # Use the shared Flock instance instead of creating a new one
60
61
  result_flock = shared_flock.run(
61
- start_agent=start_agent, input=agent_input, box_result=False
62
+ agent=start_agent, input=agent_input, box_result=False
62
63
  )
63
64
 
64
65
  # agent_output = result_flock.get(answer_mapping[key], "No answer found")
@@ -228,7 +228,7 @@ class BatchProcessor:
228
228
  try:
229
229
  # Use the synchronous wrapper to avoid nested event-loop issues inside threads
230
230
  result = self.flock.run(
231
- start_agent=start_agent,
231
+ agent=start_agent,
232
232
  input=full_input,
233
233
  box_result=box_results,
234
234
  )
@@ -43,7 +43,7 @@ from flock.core.logging.logging import get_logger
43
43
  if TYPE_CHECKING:
44
44
  from flock.core.flock import Flock
45
45
  from flock.core.flock_agent import FlockAgent
46
- from flock.core.flock_evaluator import FlockEvaluator
46
+ # Legacy FlockEvaluator import removed
47
47
  # Conditional types
48
48
 
49
49
 
@@ -188,7 +188,7 @@ class EvaluationExecutor:
188
188
  try:
189
189
  # Run the agent/flock for this item
190
190
  agent_output = await self.flock.run_async(
191
- start_agent=start_agent, # Name or instance
191
+ agent=start_agent, # Name or instance
192
192
  input=agent_inputs_with_static,
193
193
  box_result=True, # Use Box for easier access via dot notation
194
194
  # context=... # Assuming isolated context for now
@@ -64,7 +64,7 @@ class OpikExecutor:
64
64
 
65
65
  # Evaluation task
66
66
  def evaluation_task(dataset_item):
67
- flock_result = self.flock.run(start_agent=start_agent, input=dataset_item, box_result=False)
67
+ flock_result = self.flock.run(agent=start_agent, input=dataset_item, box_result=False)
68
68
 
69
69
  result = {
70
70
  "input": dataset_item.get("test"),