flock-core 0.4.520__py3-none-any.whl → 0.5.0b2__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 (103) hide show
  1. flock/cli/manage_agents.py +3 -3
  2. flock/components/__init__.py +28 -0
  3. flock/components/evaluation/__init__.py +9 -0
  4. flock/components/evaluation/declarative_evaluation_component.py +198 -0
  5. flock/components/routing/__init__.py +15 -0
  6. flock/{routers/conditional/conditional_router.py → components/routing/conditional_routing_component.py} +60 -49
  7. flock/components/routing/default_routing_component.py +103 -0
  8. flock/components/routing/llm_routing_component.py +208 -0
  9. flock/components/utility/__init__.py +15 -0
  10. flock/{modules/enterprise_memory/enterprise_memory_module.py → components/utility/memory_utility_component.py} +195 -173
  11. flock/{modules/performance/metrics_module.py → components/utility/metrics_utility_component.py} +101 -86
  12. flock/{modules/output/output_module.py → components/utility/output_utility_component.py} +49 -49
  13. flock/core/__init__.py +2 -8
  14. flock/core/agent/__init__.py +16 -0
  15. flock/core/agent/flock_agent_components.py +104 -0
  16. flock/core/agent/flock_agent_execution.py +101 -0
  17. flock/core/agent/flock_agent_integration.py +147 -0
  18. flock/core/agent/flock_agent_lifecycle.py +177 -0
  19. flock/core/agent/flock_agent_serialization.py +378 -0
  20. flock/core/component/__init__.py +15 -0
  21. flock/core/{flock_module.py → component/agent_component_base.py} +136 -35
  22. flock/core/component/evaluation_component_base.py +56 -0
  23. flock/core/component/routing_component_base.py +75 -0
  24. flock/core/component/utility_component_base.py +69 -0
  25. flock/core/config/flock_agent_config.py +49 -2
  26. flock/core/evaluation/utils.py +1 -1
  27. flock/core/execution/evaluation_executor.py +1 -1
  28. flock/core/flock.py +137 -483
  29. flock/core/flock_agent.py +151 -1018
  30. flock/core/flock_factory.py +94 -73
  31. flock/core/{flock_registry.py → flock_registry.py.backup} +3 -17
  32. flock/core/logging/logging.py +1 -0
  33. flock/core/mcp/flock_mcp_server.py +42 -37
  34. flock/core/mixin/dspy_integration.py +5 -5
  35. flock/core/orchestration/__init__.py +18 -0
  36. flock/core/orchestration/flock_batch_processor.py +94 -0
  37. flock/core/orchestration/flock_evaluator.py +113 -0
  38. flock/core/orchestration/flock_execution.py +288 -0
  39. flock/core/orchestration/flock_initialization.py +125 -0
  40. flock/core/orchestration/flock_server_manager.py +65 -0
  41. flock/core/orchestration/flock_web_server.py +117 -0
  42. flock/core/registry/__init__.py +39 -0
  43. flock/core/registry/agent_registry.py +69 -0
  44. flock/core/registry/callable_registry.py +139 -0
  45. flock/core/registry/component_discovery.py +142 -0
  46. flock/core/registry/component_registry.py +64 -0
  47. flock/core/registry/config_mapping.py +64 -0
  48. flock/core/registry/decorators.py +137 -0
  49. flock/core/registry/registry_hub.py +202 -0
  50. flock/core/registry/server_registry.py +57 -0
  51. flock/core/registry/type_registry.py +86 -0
  52. flock/core/serialization/flock_serializer.py +33 -30
  53. flock/core/serialization/serialization_utils.py +28 -25
  54. flock/core/util/input_resolver.py +29 -2
  55. flock/platform/docker_tools.py +3 -3
  56. flock/tools/markdown_tools.py +1 -2
  57. flock/tools/text_tools.py +1 -2
  58. flock/webapp/app/main.py +9 -5
  59. flock/workflow/activities.py +59 -84
  60. flock/workflow/activities_unified.py +230 -0
  61. flock/workflow/agent_execution_activity.py +6 -6
  62. flock/workflow/flock_workflow.py +1 -1
  63. {flock_core-0.4.520.dist-info → flock_core-0.5.0b2.dist-info}/METADATA +2 -2
  64. {flock_core-0.4.520.dist-info → flock_core-0.5.0b2.dist-info}/RECORD +67 -68
  65. flock/core/flock_evaluator.py +0 -60
  66. flock/core/flock_router.py +0 -83
  67. flock/evaluators/__init__.py +0 -1
  68. flock/evaluators/declarative/__init__.py +0 -1
  69. flock/evaluators/declarative/declarative_evaluator.py +0 -194
  70. flock/evaluators/memory/memory_evaluator.py +0 -90
  71. flock/evaluators/test/test_case_evaluator.py +0 -38
  72. flock/evaluators/zep/zep_evaluator.py +0 -59
  73. flock/modules/__init__.py +0 -1
  74. flock/modules/assertion/__init__.py +0 -1
  75. flock/modules/assertion/assertion_module.py +0 -286
  76. flock/modules/callback/__init__.py +0 -1
  77. flock/modules/callback/callback_module.py +0 -91
  78. flock/modules/enterprise_memory/README.md +0 -99
  79. flock/modules/mem0/__init__.py +0 -1
  80. flock/modules/mem0/mem0_module.py +0 -126
  81. flock/modules/mem0_async/__init__.py +0 -1
  82. flock/modules/mem0_async/async_mem0_module.py +0 -126
  83. flock/modules/memory/__init__.py +0 -1
  84. flock/modules/memory/memory_module.py +0 -429
  85. flock/modules/memory/memory_parser.py +0 -125
  86. flock/modules/memory/memory_storage.py +0 -736
  87. flock/modules/output/__init__.py +0 -1
  88. flock/modules/performance/__init__.py +0 -1
  89. flock/modules/zep/__init__.py +0 -1
  90. flock/modules/zep/zep_module.py +0 -192
  91. flock/routers/__init__.py +0 -1
  92. flock/routers/agent/__init__.py +0 -1
  93. flock/routers/agent/agent_router.py +0 -236
  94. flock/routers/agent/handoff_agent.py +0 -58
  95. flock/routers/default/__init__.py +0 -1
  96. flock/routers/default/default_router.py +0 -80
  97. flock/routers/feedback/feedback_router.py +0 -114
  98. flock/routers/list_generator/list_generator_router.py +0 -166
  99. flock/routers/llm/__init__.py +0 -1
  100. flock/routers/llm/llm_router.py +0 -365
  101. {flock_core-0.4.520.dist-info → flock_core-0.5.0b2.dist-info}/WHEEL +0 -0
  102. {flock_core-0.4.520.dist-info → flock_core-0.5.0b2.dist-info}/entry_points.txt +0 -0
  103. {flock_core-0.4.520.dist-info → flock_core-0.5.0b2.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 EvaluationComponentBase(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,75 @@
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
+
10
+ from .agent_component_base import AgentComponent
11
+
12
+
13
+ class RoutingComponentBase(AgentComponent):
14
+ """Base class for routing components.
15
+
16
+ Routing components determine the next step in a workflow based on the
17
+ current agent's output. They implement workflow orchestration logic
18
+ and can enable complex multi-agent patterns.
19
+
20
+ Each agent should have at most one routing component. If no routing
21
+ component is present, the workflow ends after this agent.
22
+
23
+ Example implementations:
24
+ - ConditionalRoutingModule (rule-based routing)
25
+ - LLMRoutingModule (AI-powered routing decisions)
26
+ - DefaultRoutingModule (simple next-agent routing)
27
+ - ListGeneratorRoutingModule (dynamic agent creation)
28
+ """
29
+
30
+ @abstractmethod
31
+ async def determine_next_step(
32
+ self,
33
+ agent: Any,
34
+ result: dict[str, Any],
35
+ context: FlockContext | None = None,
36
+ ) -> str | Any | None:
37
+ """Determine the next agent in the workflow - MUST be implemented.
38
+
39
+ This method analyzes the agent's result and determines what agent
40
+ should execute next. The result will be stored in agent.next_agent
41
+ for the orchestrator to process.
42
+
43
+ Args:
44
+ agent: The agent that just completed execution
45
+ result: Result from the agent's evaluation (after post-processing)
46
+ context: Execution context with workflow state
47
+
48
+ Returns:
49
+ String (agent name), FlockAgent instance, or None to end workflow
50
+
51
+ Raises:
52
+ NotImplementedError: Must be implemented by concrete classes
53
+ """
54
+ raise NotImplementedError(
55
+ f"{self.__class__.__name__} must implement determine_next_step()"
56
+ )
57
+
58
+ async def evaluate_core(
59
+ self,
60
+ agent: Any,
61
+ inputs: dict[str, Any],
62
+ context: FlockContext | None = None,
63
+ tools: list[Any] | None = None,
64
+ mcp_tools: list[Any] | None = None,
65
+ ) -> dict[str, Any]:
66
+ """Routing components typically don't modify evaluation - pass through.
67
+
68
+ Routing components usually don't implement core evaluation logic,
69
+ they focus on workflow decisions. This default implementation
70
+ passes inputs through unchanged.
71
+
72
+ Override this if your routing component also needs to modify
73
+ the evaluation process.
74
+ """
75
+ 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
+ # HandOffRequest removed - using agent.next_agent directly
8
+
9
+ from .agent_component_base import AgentComponent
10
+
11
+
12
+ class UtilityComponentBase(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,7 @@ 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
+ # Legacy FlockEvaluator import removed
21
21
  from flock.core.logging.logging import get_logger
22
22
 
23
23
  # Potentially import metrics libraries like rouge_score, nltk, sentence_transformers
@@ -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