flock-core 0.4.0b23__py3-none-any.whl → 0.4.0b25__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.
- flock/core/flock.py +28 -7
- flock/core/flock_agent.py +159 -5
- flock/core/flock_factory.py +7 -5
- flock/core/flock_registry.py +63 -15
- flock/evaluators/declarative/declarative_evaluator.py +2 -0
- flock/evaluators/memory/memory_evaluator.py +2 -0
- flock/evaluators/test/test_case_evaluator.py +2 -0
- flock/evaluators/zep/zep_evaluator.py +2 -0
- flock/modules/assertion/assertion_module.py +1 -1
- flock/modules/callback/callback_module.py +2 -0
- flock/modules/memory/memory_module.py +2 -0
- flock/modules/output/output_module.py +2 -0
- flock/modules/performance/metrics_module.py +2 -0
- flock/modules/zep/zep_module.py +2 -0
- flock/routers/agent/agent_router.py +2 -0
- flock/routers/conditional/conditional_router.py +1 -1
- flock/routers/default/default_router.py +2 -0
- flock/routers/feedback/feedback_router.py +1 -1
- flock/routers/list_generator/list_generator_router.py +1 -1
- flock/routers/llm/llm_router.py +2 -0
- {flock_core-0.4.0b23.dist-info → flock_core-0.4.0b25.dist-info}/METADATA +1 -1
- {flock_core-0.4.0b23.dist-info → flock_core-0.4.0b25.dist-info}/RECORD +25 -28
- flock/evaluators/memory/azure_search_evaluator.py +0 -0
- flock/evaluators/natural_language/natural_language_evaluator.py +0 -66
- flock/modules/azure-search/azure_search_module.py +0 -0
- {flock_core-0.4.0b23.dist-info → flock_core-0.4.0b25.dist-info}/WHEEL +0 -0
- {flock_core-0.4.0b23.dist-info → flock_core-0.4.0b25.dist-info}/entry_points.txt +0 -0
- {flock_core-0.4.0b23.dist-info → flock_core-0.4.0b25.dist-info}/licenses/LICENSE +0 -0
flock/core/flock.py
CHANGED
|
@@ -59,6 +59,10 @@ FlockRegistry = get_registry() # Get the registry instance
|
|
|
59
59
|
# Define TypeVar for generic class methods like from_dict
|
|
60
60
|
T = TypeVar("T", bound="Flock")
|
|
61
61
|
|
|
62
|
+
from rich.traceback import install
|
|
63
|
+
|
|
64
|
+
install(show_locals=True)
|
|
65
|
+
|
|
62
66
|
|
|
63
67
|
class Flock(BaseModel, Serializable):
|
|
64
68
|
"""Orchestrator for managing and executing agent systems.
|
|
@@ -336,6 +340,10 @@ class Flock(BaseModel, Serializable):
|
|
|
336
340
|
"No start_agent specified and multiple/no agents exist."
|
|
337
341
|
)
|
|
338
342
|
|
|
343
|
+
# Check if start_agent is in agents
|
|
344
|
+
if start_agent_name not in self._agents:
|
|
345
|
+
raise ValueError(f"Start agent '{start_agent_name}' not found.")
|
|
346
|
+
|
|
339
347
|
run_input = input if input is not None else self._start_input
|
|
340
348
|
effective_run_id = run_id or f"flockrun_{uuid.uuid4().hex[:8]}"
|
|
341
349
|
|
|
@@ -350,9 +358,13 @@ class Flock(BaseModel, Serializable):
|
|
|
350
358
|
try:
|
|
351
359
|
resolved_start_agent = self._agents.get(start_agent_name)
|
|
352
360
|
if not resolved_start_agent:
|
|
353
|
-
resolved_start_agent = FlockRegistry.get_agent(
|
|
361
|
+
resolved_start_agent = FlockRegistry.get_agent(
|
|
362
|
+
start_agent_name
|
|
363
|
+
)
|
|
354
364
|
if not resolved_start_agent:
|
|
355
|
-
raise ValueError(
|
|
365
|
+
raise ValueError(
|
|
366
|
+
f"Start agent '{start_agent_name}' not found."
|
|
367
|
+
)
|
|
356
368
|
self.add_agent(resolved_start_agent)
|
|
357
369
|
|
|
358
370
|
run_context = context if context else FlockContext()
|
|
@@ -384,15 +396,20 @@ class Flock(BaseModel, Serializable):
|
|
|
384
396
|
|
|
385
397
|
# Execute workflow
|
|
386
398
|
if not self.enable_temporal:
|
|
387
|
-
result = await run_local_workflow(
|
|
399
|
+
result = await run_local_workflow(
|
|
400
|
+
run_context, box_result=False
|
|
401
|
+
)
|
|
388
402
|
else:
|
|
389
|
-
result = await run_temporal_workflow(
|
|
403
|
+
result = await run_temporal_workflow(
|
|
404
|
+
run_context, box_result=False
|
|
405
|
+
)
|
|
390
406
|
|
|
391
407
|
span.set_attribute("result.type", str(type(result)))
|
|
392
408
|
result_str = str(result)
|
|
393
409
|
span.set_attribute(
|
|
394
410
|
"result.preview",
|
|
395
|
-
result_str[:1000]
|
|
411
|
+
result_str[:1000]
|
|
412
|
+
+ ("..." if len(result_str) > 1000 else ""),
|
|
396
413
|
)
|
|
397
414
|
|
|
398
415
|
if box_result:
|
|
@@ -400,13 +417,17 @@ class Flock(BaseModel, Serializable):
|
|
|
400
417
|
logger.debug("Boxing final result.")
|
|
401
418
|
return Box(result)
|
|
402
419
|
except ImportError:
|
|
403
|
-
logger.warning(
|
|
420
|
+
logger.warning(
|
|
421
|
+
"Box library not installed, returning raw dict."
|
|
422
|
+
)
|
|
404
423
|
return result
|
|
405
424
|
else:
|
|
406
425
|
return result
|
|
407
426
|
|
|
408
427
|
except Exception as e:
|
|
409
|
-
logger.error(
|
|
428
|
+
logger.error(
|
|
429
|
+
f"Flock run '{self.name}' failed: {e}", exc_info=True
|
|
430
|
+
)
|
|
410
431
|
span.record_exception(e)
|
|
411
432
|
span.set_status(trace.Status(trace.StatusCode.ERROR, str(e)))
|
|
412
433
|
return {
|
flock/core/flock_agent.py
CHANGED
|
@@ -23,9 +23,9 @@ from rich.console import Console
|
|
|
23
23
|
|
|
24
24
|
# Core Flock components (ensure these are importable)
|
|
25
25
|
from flock.core.context.context import FlockContext
|
|
26
|
-
from flock.core.flock_evaluator import FlockEvaluator
|
|
27
|
-
from flock.core.flock_module import FlockModule
|
|
28
|
-
from flock.core.flock_router import FlockRouter
|
|
26
|
+
from flock.core.flock_evaluator import FlockEvaluator, FlockEvaluatorConfig
|
|
27
|
+
from flock.core.flock_module import FlockModule, FlockModuleConfig
|
|
28
|
+
from flock.core.flock_router import FlockRouter, FlockRouterConfig
|
|
29
29
|
from flock.core.logging.logging import get_logger
|
|
30
30
|
|
|
31
31
|
# Mixins and Serialization components
|
|
@@ -45,6 +45,15 @@ tracer = trace.get_tracer(__name__)
|
|
|
45
45
|
T = TypeVar("T", bound="FlockAgent")
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
SignatureType = (
|
|
49
|
+
str
|
|
50
|
+
| Callable[..., str]
|
|
51
|
+
| type[BaseModel]
|
|
52
|
+
| Callable[..., type[BaseModel]]
|
|
53
|
+
| None
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
48
57
|
# Make FlockAgent inherit from Serializable
|
|
49
58
|
class FlockAgent(BaseModel, Serializable, DSPyIntegrationMixin, ABC):
|
|
50
59
|
"""Core, declarative base class for Flock agents, enabling serialization,
|
|
@@ -61,14 +70,14 @@ class FlockAgent(BaseModel, Serializable, DSPyIntegrationMixin, ABC):
|
|
|
61
70
|
"",
|
|
62
71
|
description="A human-readable description or a callable returning one.",
|
|
63
72
|
)
|
|
64
|
-
input:
|
|
73
|
+
input: SignatureType = Field(
|
|
65
74
|
None,
|
|
66
75
|
description=(
|
|
67
76
|
"Signature for input keys. Supports type hints (:) and descriptions (|). "
|
|
68
77
|
"E.g., 'query: str | Search query, context: dict | Conversation context'. Can be a callable."
|
|
69
78
|
),
|
|
70
79
|
)
|
|
71
|
-
output:
|
|
80
|
+
output: SignatureType = Field(
|
|
72
81
|
None,
|
|
73
82
|
description=(
|
|
74
83
|
"Signature for output keys. Supports type hints (:) and descriptions (|). "
|
|
@@ -111,6 +120,43 @@ class FlockAgent(BaseModel, Serializable, DSPyIntegrationMixin, ABC):
|
|
|
111
120
|
description="Runtime context associated with the flock execution.",
|
|
112
121
|
)
|
|
113
122
|
|
|
123
|
+
def __init__(
|
|
124
|
+
self,
|
|
125
|
+
name: str,
|
|
126
|
+
model: str | None = None,
|
|
127
|
+
description: str | Callable[..., str] | None = "",
|
|
128
|
+
input: SignatureType = None,
|
|
129
|
+
output: SignatureType = None,
|
|
130
|
+
tools: list[Callable[..., Any]] | None = None,
|
|
131
|
+
evaluator: "FlockEvaluator | None" = None,
|
|
132
|
+
handoff_router: "FlockRouter | None" = None,
|
|
133
|
+
modules: dict[str, "FlockModule"] | None = None, # Use dict for modules
|
|
134
|
+
write_to_file: bool = False,
|
|
135
|
+
wait_for_input: bool = False,
|
|
136
|
+
**kwargs,
|
|
137
|
+
):
|
|
138
|
+
super().__init__(
|
|
139
|
+
name=name,
|
|
140
|
+
model=model,
|
|
141
|
+
description=description,
|
|
142
|
+
input=input, # Store the raw input spec
|
|
143
|
+
output=output, # Store the raw output spec
|
|
144
|
+
tools=tools,
|
|
145
|
+
write_to_file=write_to_file,
|
|
146
|
+
wait_for_input=wait_for_input,
|
|
147
|
+
evaluator=evaluator,
|
|
148
|
+
handoff_router=handoff_router,
|
|
149
|
+
modules=modules
|
|
150
|
+
if modules is not None
|
|
151
|
+
else {}, # Ensure modules is a dict
|
|
152
|
+
**kwargs,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
if isinstance(self.input, type) and issubclass(self.input, BaseModel):
|
|
156
|
+
self._input_model = self.input
|
|
157
|
+
if isinstance(self.output, type) and issubclass(self.output, BaseModel):
|
|
158
|
+
self._output_model = self.output
|
|
159
|
+
|
|
114
160
|
# --- Existing Methods (add_module, remove_module, etc.) ---
|
|
115
161
|
# (Keep these methods as they were, adding type hints where useful)
|
|
116
162
|
def add_module(self, module: FlockModule) -> None:
|
|
@@ -359,6 +405,114 @@ class FlockAgent(BaseModel, Serializable, DSPyIntegrationMixin, ABC):
|
|
|
359
405
|
span.record_exception(temporal_error)
|
|
360
406
|
raise
|
|
361
407
|
|
|
408
|
+
def add_component(
|
|
409
|
+
self,
|
|
410
|
+
config_instance: FlockModuleConfig
|
|
411
|
+
| FlockRouterConfig
|
|
412
|
+
| FlockEvaluatorConfig,
|
|
413
|
+
component_name: str | None = None,
|
|
414
|
+
) -> "FlockAgent":
|
|
415
|
+
"""Adds or replaces a component (Evaluator, Router, Module) based on its configuration object.
|
|
416
|
+
|
|
417
|
+
Args:
|
|
418
|
+
config_instance: An instance of a config class inheriting from
|
|
419
|
+
FlockModuleConfig, FlockRouterConfig, or FlockEvaluatorConfig.
|
|
420
|
+
component_name: Explicit name for the component (required for Modules if not in config).
|
|
421
|
+
|
|
422
|
+
Returns:
|
|
423
|
+
self for potential chaining.
|
|
424
|
+
"""
|
|
425
|
+
from flock.core.flock_registry import get_registry
|
|
426
|
+
|
|
427
|
+
config_type = type(config_instance)
|
|
428
|
+
registry = get_registry() # Get registry instance
|
|
429
|
+
logger.debug(
|
|
430
|
+
f"Attempting to add component via config: {config_type.__name__}"
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
# --- 1. Find Component Class using Registry Map ---
|
|
434
|
+
ComponentClass = registry.get_component_class_for_config(config_type)
|
|
435
|
+
|
|
436
|
+
if not ComponentClass:
|
|
437
|
+
logger.error(
|
|
438
|
+
f"No component class registered for config type {config_type.__name__}. Use @flock_component(config_class=...) on the component."
|
|
439
|
+
)
|
|
440
|
+
raise TypeError(
|
|
441
|
+
f"Cannot find component class for config {config_type.__name__}"
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
component_class_name = ComponentClass.__name__
|
|
445
|
+
logger.debug(
|
|
446
|
+
f"Found component class '{component_class_name}' mapped to config '{config_type.__name__}'"
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
# --- 2. Determine Assignment Target and Name (Same as before) ---
|
|
450
|
+
instance_name = component_name
|
|
451
|
+
attribute_name: str = ""
|
|
452
|
+
|
|
453
|
+
if issubclass(ComponentClass, FlockEvaluator):
|
|
454
|
+
attribute_name = "evaluator"
|
|
455
|
+
if not instance_name:
|
|
456
|
+
instance_name = getattr(
|
|
457
|
+
config_instance, "name", component_class_name.lower()
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
elif issubclass(ComponentClass, FlockRouter):
|
|
461
|
+
attribute_name = "handoff_router"
|
|
462
|
+
if not instance_name:
|
|
463
|
+
instance_name = getattr(
|
|
464
|
+
config_instance, "name", component_class_name.lower()
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
elif issubclass(ComponentClass, FlockModule):
|
|
468
|
+
attribute_name = "modules"
|
|
469
|
+
if not instance_name:
|
|
470
|
+
instance_name = getattr(
|
|
471
|
+
config_instance, "name", component_class_name.lower()
|
|
472
|
+
)
|
|
473
|
+
if not instance_name:
|
|
474
|
+
raise ValueError(
|
|
475
|
+
"Module name must be provided either in config or as component_name argument."
|
|
476
|
+
)
|
|
477
|
+
# Ensure config has name if module expects it
|
|
478
|
+
if hasattr(config_instance, "name") and not getattr(
|
|
479
|
+
config_instance, "name", None
|
|
480
|
+
):
|
|
481
|
+
setattr(config_instance, "name", instance_name)
|
|
482
|
+
|
|
483
|
+
else: # Should be caught by registry map logic ideally
|
|
484
|
+
raise TypeError(
|
|
485
|
+
f"Class '{component_class_name}' mapped from config is not a valid Flock component."
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
# --- 3. Instantiate the Component (Same as before) ---
|
|
489
|
+
try:
|
|
490
|
+
init_args = {"config": config_instance, "name": instance_name}
|
|
491
|
+
|
|
492
|
+
component_instance = ComponentClass(**init_args)
|
|
493
|
+
except Exception as e:
|
|
494
|
+
logger.error(
|
|
495
|
+
f"Failed to instantiate {ComponentClass.__name__} with config {config_type.__name__}: {e}",
|
|
496
|
+
exc_info=True,
|
|
497
|
+
)
|
|
498
|
+
raise RuntimeError(f"Component instantiation failed: {e}") from e
|
|
499
|
+
|
|
500
|
+
# --- 4. Assign to the Agent (Same as before) ---
|
|
501
|
+
if attribute_name == "modules":
|
|
502
|
+
if not isinstance(self.modules, dict):
|
|
503
|
+
self.modules = {}
|
|
504
|
+
self.modules[instance_name] = component_instance
|
|
505
|
+
logger.info(
|
|
506
|
+
f"Added/Updated module '{instance_name}' (type: {ComponentClass.__name__}) to agent '{self.name}'"
|
|
507
|
+
)
|
|
508
|
+
else:
|
|
509
|
+
setattr(self, attribute_name, component_instance)
|
|
510
|
+
logger.info(
|
|
511
|
+
f"Set {attribute_name} to {ComponentClass.__name__} (instance name: '{instance_name}') for agent '{self.name}'"
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
return self
|
|
515
|
+
|
|
362
516
|
# resolve_callables remains useful for dynamic definitions
|
|
363
517
|
def resolve_callables(self, context: FlockContext | None = None) -> None:
|
|
364
518
|
"""Resolves callable fields (description, input, output) using context."""
|
flock/core/flock_factory.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from collections.abc import Callable
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from flock.core.flock_agent import FlockAgent
|
|
6
|
+
from flock.core.flock_agent import FlockAgent, SignatureType
|
|
7
7
|
from flock.core.logging.formatters.themes import OutputTheme
|
|
8
8
|
from flock.evaluators.declarative.declarative_evaluator import (
|
|
9
9
|
DeclarativeEvaluator,
|
|
@@ -24,8 +24,8 @@ class FlockFactory:
|
|
|
24
24
|
name: str,
|
|
25
25
|
description: str | Callable[..., str] | None = None,
|
|
26
26
|
model: str | Callable[..., str] | None = None,
|
|
27
|
-
input:
|
|
28
|
-
output:
|
|
27
|
+
input: SignatureType = None,
|
|
28
|
+
output: SignatureType = None,
|
|
29
29
|
tools: list[Callable[..., Any] | Any] | None = None,
|
|
30
30
|
use_cache: bool = True,
|
|
31
31
|
enable_rich_tables: bool = False,
|
|
@@ -42,10 +42,12 @@ class FlockFactory:
|
|
|
42
42
|
) -> FlockAgent:
|
|
43
43
|
"""Creates a default FlockAgent.
|
|
44
44
|
|
|
45
|
-
The default agent includes
|
|
45
|
+
The default agent includes the following modules:
|
|
46
|
+
- DeclarativeEvaluator
|
|
46
47
|
- OutputModule
|
|
48
|
+
- MetricsModule
|
|
47
49
|
|
|
48
|
-
It also includes
|
|
50
|
+
It also includes direct acces to the most important configurations.
|
|
49
51
|
"""
|
|
50
52
|
eval_config = DeclarativeEvaluatorConfig(
|
|
51
53
|
model=model,
|
flock/core/flock_registry.py
CHANGED
|
@@ -32,6 +32,7 @@ if TYPE_CHECKING:
|
|
|
32
32
|
from flock.core.flock_router import FlockRouter
|
|
33
33
|
|
|
34
34
|
COMPONENT_BASE_TYPES = (FlockModule, FlockEvaluator, FlockRouter)
|
|
35
|
+
|
|
35
36
|
IS_COMPONENT_CHECK_ENABLED = True
|
|
36
37
|
else:
|
|
37
38
|
# Define dummy types or skip check if not type checking
|
|
@@ -41,12 +42,15 @@ else:
|
|
|
41
42
|
|
|
42
43
|
# Fallback if core types aren't available during setup
|
|
43
44
|
|
|
45
|
+
from flock.core.flock_module import FlockModuleConfig
|
|
44
46
|
from flock.core.logging.logging import get_logger
|
|
45
47
|
|
|
46
48
|
logger = get_logger("registry")
|
|
47
49
|
T = TypeVar("T")
|
|
48
50
|
ClassType = TypeVar("ClassType", bound=type)
|
|
49
51
|
FuncType = TypeVar("FuncType", bound=Callable)
|
|
52
|
+
ConfigType = TypeVar("ConfigType", bound=BaseModel)
|
|
53
|
+
_COMPONENT_CONFIG_MAP: dict[type[BaseModel], type[any]] = {}
|
|
50
54
|
|
|
51
55
|
|
|
52
56
|
class FlockRegistry:
|
|
@@ -105,6 +109,45 @@ class FlockRegistry:
|
|
|
105
109
|
except Exception as e:
|
|
106
110
|
logger.error(f"Failed to auto-register core type {t}: {e}")
|
|
107
111
|
|
|
112
|
+
@staticmethod
|
|
113
|
+
def register_config_component_pair(
|
|
114
|
+
config_cls: type[ConfigType], component_cls: type[ClassType]
|
|
115
|
+
):
|
|
116
|
+
"""Explicitly registers the mapping between a config and component class."""
|
|
117
|
+
from flock.core.flock_evaluator import (
|
|
118
|
+
FlockEvaluatorConfig,
|
|
119
|
+
)
|
|
120
|
+
from flock.core.flock_router import FlockRouterConfig
|
|
121
|
+
|
|
122
|
+
if not issubclass(
|
|
123
|
+
config_cls,
|
|
124
|
+
FlockModuleConfig | FlockRouterConfig | FlockEvaluatorConfig,
|
|
125
|
+
):
|
|
126
|
+
logger.warning(
|
|
127
|
+
f"Config class {config_cls.__name__} does not inherit from a standard Flock config base."
|
|
128
|
+
)
|
|
129
|
+
# Add more checks if needed (e.g., component_cls inherits from Module/Router/Evaluator)
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
config_cls in _COMPONENT_CONFIG_MAP
|
|
133
|
+
and _COMPONENT_CONFIG_MAP[config_cls] != component_cls
|
|
134
|
+
):
|
|
135
|
+
logger.warning(
|
|
136
|
+
f"Config class {config_cls.__name__} already mapped to {_COMPONENT_CONFIG_MAP[config_cls].__name__}. Overwriting with {component_cls.__name__}."
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
_COMPONENT_CONFIG_MAP[config_cls] = component_cls
|
|
140
|
+
logger.debug(
|
|
141
|
+
f"Registered config mapping: {config_cls.__name__} -> {component_cls.__name__}"
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
@staticmethod
|
|
145
|
+
def get_component_class_for_config(
|
|
146
|
+
config_cls: type[ConfigType],
|
|
147
|
+
) -> type[ClassType] | None:
|
|
148
|
+
"""Looks up the Component Class associated with a Config Class."""
|
|
149
|
+
return _COMPONENT_CONFIG_MAP.get(config_cls)
|
|
150
|
+
|
|
108
151
|
# --- Path String Generation ---
|
|
109
152
|
@staticmethod
|
|
110
153
|
def _get_path_string(obj: Callable | type) -> str | None:
|
|
@@ -439,36 +482,41 @@ def get_registry() -> FlockRegistry:
|
|
|
439
482
|
|
|
440
483
|
# Type hinting for decorators to preserve signature
|
|
441
484
|
@overload
|
|
442
|
-
def flock_component(cls: ClassType) -> ClassType: ...
|
|
485
|
+
def flock_component(cls: ClassType) -> ClassType: ... # Basic registration
|
|
443
486
|
@overload
|
|
444
487
|
def flock_component(
|
|
445
|
-
*, name: str | None = None
|
|
446
|
-
) -> Callable[[ClassType], ClassType]: ...
|
|
488
|
+
*, name: str | None = None, config_class: type[ConfigType] | None = None
|
|
489
|
+
) -> Callable[[ClassType], ClassType]: ... # With options
|
|
447
490
|
|
|
448
491
|
|
|
449
492
|
def flock_component(
|
|
450
|
-
cls: ClassType | None = None,
|
|
493
|
+
cls: ClassType | None = None,
|
|
494
|
+
*,
|
|
495
|
+
name: str | None = None,
|
|
496
|
+
config_class: type[ConfigType] | None = None,
|
|
451
497
|
) -> Any:
|
|
452
|
-
"""Decorator to register a Flock Component class
|
|
453
|
-
|
|
454
|
-
Usage:
|
|
455
|
-
@flock_component
|
|
456
|
-
class MyModule(FlockModule): ...
|
|
457
|
-
|
|
458
|
-
@flock_component(name="CustomRouterAlias")
|
|
459
|
-
class MyRouter(FlockRouter): ...
|
|
460
|
-
"""
|
|
498
|
+
"""Decorator to register a Flock Component class and optionally link its config class."""
|
|
461
499
|
registry = get_registry()
|
|
462
500
|
|
|
463
501
|
def decorator(inner_cls: ClassType) -> ClassType:
|
|
464
502
|
if not inspect.isclass(inner_cls):
|
|
465
503
|
raise TypeError("@flock_component can only decorate classes.")
|
|
504
|
+
|
|
466
505
|
component_name = name or inner_cls.__name__
|
|
467
|
-
registry.register_component(
|
|
506
|
+
registry.register_component(
|
|
507
|
+
inner_cls, name=component_name
|
|
508
|
+
) # Register component by name
|
|
509
|
+
|
|
510
|
+
# If config_class is provided, register the mapping
|
|
511
|
+
if config_class:
|
|
512
|
+
FlockRegistry.register_config_component_pair(
|
|
513
|
+
config_class, inner_cls
|
|
514
|
+
)
|
|
515
|
+
|
|
468
516
|
return inner_cls
|
|
469
517
|
|
|
470
518
|
if cls is None:
|
|
471
|
-
# Called as @flock_component(name="...")
|
|
519
|
+
# Called as @flock_component(name="...", config_class=...)
|
|
472
520
|
return decorator
|
|
473
521
|
else:
|
|
474
522
|
# Called as @flock_component
|
|
@@ -7,6 +7,7 @@ from rich.console import Console
|
|
|
7
7
|
|
|
8
8
|
from flock.core.flock_agent import FlockAgent
|
|
9
9
|
from flock.core.flock_evaluator import FlockEvaluator, FlockEvaluatorConfig
|
|
10
|
+
from flock.core.flock_registry import flock_component
|
|
10
11
|
from flock.core.logging.logging import get_logger
|
|
11
12
|
from flock.core.mixin.dspy_integration import DSPyIntegrationMixin
|
|
12
13
|
from flock.core.mixin.prompt_parser import PromptParserMixin
|
|
@@ -35,6 +36,7 @@ class DeclarativeEvaluatorConfig(FlockEvaluatorConfig):
|
|
|
35
36
|
kwargs: dict[str, Any] = Field(default_factory=dict)
|
|
36
37
|
|
|
37
38
|
|
|
39
|
+
@flock_component(config_class=DeclarativeEvaluatorConfig)
|
|
38
40
|
class DeclarativeEvaluator(
|
|
39
41
|
FlockEvaluator, DSPyIntegrationMixin, PromptParserMixin
|
|
40
42
|
):
|
|
@@ -4,6 +4,7 @@ from pydantic import Field
|
|
|
4
4
|
|
|
5
5
|
from flock.core.flock_agent import FlockAgent
|
|
6
6
|
from flock.core.flock_evaluator import FlockEvaluator, FlockEvaluatorConfig
|
|
7
|
+
from flock.core.flock_registry import flock_component
|
|
7
8
|
from flock.core.mixin.dspy_integration import DSPyIntegrationMixin
|
|
8
9
|
from flock.core.mixin.prompt_parser import PromptParserMixin
|
|
9
10
|
from flock.modules.memory.memory_module import MemoryModule, MemoryModuleConfig
|
|
@@ -45,6 +46,7 @@ class MemoryEvaluatorConfig(FlockEvaluatorConfig):
|
|
|
45
46
|
)
|
|
46
47
|
|
|
47
48
|
|
|
49
|
+
@flock_component(config_class=MemoryEvaluatorConfig)
|
|
48
50
|
class MemoryEvaluator(FlockEvaluator, DSPyIntegrationMixin, PromptParserMixin):
|
|
49
51
|
"""Evaluator that uses DSPy for generation."""
|
|
50
52
|
|
|
@@ -4,6 +4,7 @@ from pydantic import Field
|
|
|
4
4
|
|
|
5
5
|
from flock.core.flock_agent import FlockAgent
|
|
6
6
|
from flock.core.flock_evaluator import FlockEvaluator, FlockEvaluatorConfig
|
|
7
|
+
from flock.core.flock_registry import flock_component
|
|
7
8
|
from flock.core.mixin.dspy_integration import DSPyIntegrationMixin
|
|
8
9
|
|
|
9
10
|
|
|
@@ -13,6 +14,7 @@ class TestCaseEvaluatorConfig(FlockEvaluatorConfig):
|
|
|
13
14
|
pass
|
|
14
15
|
|
|
15
16
|
|
|
17
|
+
@flock_component(config_class=TestCaseEvaluatorConfig)
|
|
16
18
|
class TestCaseEvaluator(FlockEvaluator, DSPyIntegrationMixin):
|
|
17
19
|
"""Evaluator for test cases."""
|
|
18
20
|
|
|
@@ -4,6 +4,7 @@ from pydantic import Field
|
|
|
4
4
|
|
|
5
5
|
from flock.core.flock_agent import FlockAgent
|
|
6
6
|
from flock.core.flock_evaluator import FlockEvaluator, FlockEvaluatorConfig
|
|
7
|
+
from flock.core.flock_registry import flock_component
|
|
7
8
|
from flock.core.mixin.dspy_integration import DSPyIntegrationMixin
|
|
8
9
|
from flock.core.mixin.prompt_parser import PromptParserMixin
|
|
9
10
|
from flock.modules.zep.zep_module import ZepModule, ZepModuleConfig
|
|
@@ -17,6 +18,7 @@ class ZepEvaluatorConfig(FlockEvaluatorConfig):
|
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
|
|
21
|
+
@flock_component(config_class=ZepEvaluatorConfig)
|
|
20
22
|
class ZepEvaluator(FlockEvaluator, DSPyIntegrationMixin, PromptParserMixin):
|
|
21
23
|
"""Evaluator that uses DSPy for generation."""
|
|
22
24
|
|
|
@@ -7,6 +7,7 @@ from pydantic import Field
|
|
|
7
7
|
|
|
8
8
|
from flock.core import FlockModule, FlockModuleConfig
|
|
9
9
|
from flock.core.context.context import FlockContext
|
|
10
|
+
from flock.core.flock_registry import flock_component
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class CallbackModuleConfig(FlockModuleConfig):
|
|
@@ -36,6 +37,7 @@ class CallbackModuleConfig(FlockModuleConfig):
|
|
|
36
37
|
)
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
@flock_component(config_class=CallbackModuleConfig)
|
|
39
41
|
class CallbackModule(FlockModule):
|
|
40
42
|
"""Module that provides callback functionality for agent lifecycle events."""
|
|
41
43
|
|
|
@@ -12,6 +12,7 @@ from flock.core.context.context import FlockContext
|
|
|
12
12
|
# from flock.core import FlockAgent
|
|
13
13
|
from flock.core.flock_agent import FlockAgent
|
|
14
14
|
from flock.core.flock_module import FlockModule, FlockModuleConfig
|
|
15
|
+
from flock.core.flock_registry import flock_component
|
|
15
16
|
from flock.core.logging.logging import get_logger
|
|
16
17
|
from flock.modules.memory.memory_parser import MemoryMappingParser
|
|
17
18
|
from flock.modules.memory.memory_storage import FlockMemoryStore, MemoryEntry
|
|
@@ -59,6 +60,7 @@ class MemoryModuleConfig(FlockModuleConfig):
|
|
|
59
60
|
)
|
|
60
61
|
|
|
61
62
|
|
|
63
|
+
@flock_component(config_class=MemoryModuleConfig)
|
|
62
64
|
class MemoryModule(FlockModule):
|
|
63
65
|
"""Module that adds memory capabilities to a Flock agent."""
|
|
64
66
|
|
|
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
5
5
|
from pydantic import Field
|
|
6
6
|
|
|
7
7
|
from flock.core.context.context_vars import FLOCK_BATCH_SILENT_MODE
|
|
8
|
+
from flock.core.flock_registry import flock_component
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
10
11
|
from flock.core import FlockAgent
|
|
@@ -60,6 +61,7 @@ class OutputModuleConfig(FlockModuleConfig):
|
|
|
60
61
|
)
|
|
61
62
|
|
|
62
63
|
|
|
64
|
+
@flock_component(config_class=OutputModuleConfig)
|
|
63
65
|
class OutputModule(FlockModule):
|
|
64
66
|
"""Module that handles output formatting and display."""
|
|
65
67
|
|
|
@@ -14,6 +14,7 @@ from pydantic import BaseModel, Field, validator
|
|
|
14
14
|
from flock.core.context.context import FlockContext
|
|
15
15
|
from flock.core.flock_agent import FlockAgent
|
|
16
16
|
from flock.core.flock_module import FlockModule, FlockModuleConfig
|
|
17
|
+
from flock.core.flock_registry import flock_component
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class MetricPoint(BaseModel):
|
|
@@ -69,6 +70,7 @@ class MetricsModuleConfig(FlockModuleConfig):
|
|
|
69
70
|
return v
|
|
70
71
|
|
|
71
72
|
|
|
73
|
+
@flock_component(config_class=MetricsModuleConfig)
|
|
72
74
|
class MetricsModule(FlockModule):
|
|
73
75
|
"""Module for collecting and analyzing agent performance metrics."""
|
|
74
76
|
|
flock/modules/zep/zep_module.py
CHANGED
|
@@ -8,6 +8,7 @@ from zep_python.types import Message as ZepMessage, SessionSearchResult
|
|
|
8
8
|
from flock.core.context.context import FlockContext
|
|
9
9
|
from flock.core.flock_agent import FlockAgent
|
|
10
10
|
from flock.core.flock_module import FlockModule, FlockModuleConfig
|
|
11
|
+
from flock.core.flock_registry import flock_component
|
|
11
12
|
from flock.core.logging.logging import get_logger
|
|
12
13
|
|
|
13
14
|
logger = get_logger("module.zep")
|
|
@@ -25,6 +26,7 @@ class ZepModuleConfig(FlockModuleConfig):
|
|
|
25
26
|
enable_write: bool = False
|
|
26
27
|
|
|
27
28
|
|
|
29
|
+
@flock_component(config_class=ZepModuleConfig)
|
|
28
30
|
class ZepModule(FlockModule):
|
|
29
31
|
"""Module that adds Zep capabilities to a Flock agent."""
|
|
30
32
|
|
|
@@ -4,6 +4,7 @@ from typing import Any
|
|
|
4
4
|
|
|
5
5
|
from flock.core.context.context import FlockContext
|
|
6
6
|
from flock.core.flock_agent import FlockAgent
|
|
7
|
+
from flock.core.flock_registry import flock_component
|
|
7
8
|
from flock.core.flock_router import (
|
|
8
9
|
FlockRouter,
|
|
9
10
|
FlockRouterConfig,
|
|
@@ -34,6 +35,7 @@ class AgentRouterConfig(FlockRouterConfig):
|
|
|
34
35
|
confidence_threshold: float = 0.5 # No additional parameters needed for now
|
|
35
36
|
|
|
36
37
|
|
|
38
|
+
@flock_component(config_class=AgentRouterConfig)
|
|
37
39
|
class AgentRouter(FlockRouter):
|
|
38
40
|
"""Router that uses a FlockAgent to determine the next agent in a workflow.
|
|
39
41
|
|
|
@@ -146,7 +146,7 @@ class ConditionalRouterConfig(FlockRouterConfig):
|
|
|
146
146
|
return self
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
@flock_component
|
|
149
|
+
@flock_component(config_class=ConditionalRouterConfig)
|
|
150
150
|
class ConditionalRouter(FlockRouter):
|
|
151
151
|
"""Routes workflow based on evaluating a condition against a value in the FlockContext.
|
|
152
152
|
Supports various built-in checks (string, number, list, type, bool, existence)
|
|
@@ -7,6 +7,7 @@ from pydantic import Field
|
|
|
7
7
|
|
|
8
8
|
from flock.core.context.context import FlockContext
|
|
9
9
|
from flock.core.flock_agent import FlockAgent
|
|
10
|
+
from flock.core.flock_registry import flock_component
|
|
10
11
|
from flock.core.flock_router import (
|
|
11
12
|
FlockRouter,
|
|
12
13
|
FlockRouterConfig,
|
|
@@ -25,6 +26,7 @@ class DefaultRouterConfig(FlockRouterConfig):
|
|
|
25
26
|
)
|
|
26
27
|
|
|
27
28
|
|
|
29
|
+
@flock_component(config_class=DefaultRouterConfig)
|
|
28
30
|
class DefaultRouter(FlockRouter):
|
|
29
31
|
"""Default router implementation.
|
|
30
32
|
|
|
@@ -47,7 +47,7 @@ class IterativeListGeneratorRouterConfig(FlockRouterConfig):
|
|
|
47
47
|
# item_type_str: Optional[str] = None # e.g., 'dict[str, str]' or 'MyChapterType'
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
@flock_component
|
|
50
|
+
@flock_component(config_class=IterativeListGeneratorRouterConfig)
|
|
51
51
|
class IterativeListGeneratorRouter(FlockRouter):
|
|
52
52
|
name: str = "iterative_list_generator"
|
|
53
53
|
config: IterativeListGeneratorRouterConfig = Field(
|
flock/routers/llm/llm_router.py
CHANGED
|
@@ -7,6 +7,7 @@ import litellm
|
|
|
7
7
|
|
|
8
8
|
from flock.core.context.context import FlockContext
|
|
9
9
|
from flock.core.flock_agent import FlockAgent
|
|
10
|
+
from flock.core.flock_registry import flock_component
|
|
10
11
|
from flock.core.flock_router import (
|
|
11
12
|
FlockRouter,
|
|
12
13
|
FlockRouterConfig,
|
|
@@ -29,6 +30,7 @@ class LLMRouterConfig(FlockRouterConfig):
|
|
|
29
30
|
prompt: str = ""
|
|
30
31
|
|
|
31
32
|
|
|
33
|
+
@flock_component(config_class=LLMRouterConfig)
|
|
32
34
|
class LLMRouter(FlockRouter):
|
|
33
35
|
"""Router that uses an LLM to determine the next agent in a workflow.
|
|
34
36
|
|
|
@@ -19,12 +19,12 @@ flock/cli/view_results.py,sha256=dOzK0O1FHSIDERnx48y-2Xke9BkOHS7pcOhs64AyIg0,781
|
|
|
19
19
|
flock/cli/yaml_editor.py,sha256=K3N0bh61G1TSDAZDnurqW9e_-hO6CtSQKXQqlDhCjVo,12527
|
|
20
20
|
flock/cli/assets/release_notes.md,sha256=bqnk50jxM3w5uY44Dc7MkdT8XmRREFxrVBAG9XCOSSU,4896
|
|
21
21
|
flock/core/__init__.py,sha256=p7lmQULRu9ejIAELfanZiyMhW0CougIPvyFHW2nqBFQ,847
|
|
22
|
-
flock/core/flock.py,sha256=
|
|
23
|
-
flock/core/flock_agent.py,sha256=
|
|
22
|
+
flock/core/flock.py,sha256=0hKRlG8CRwjq5uicaxxKQCtlD2PP84c1IaO_RxZ-tG0,25666
|
|
23
|
+
flock/core/flock_agent.py,sha256=k2HDMG8yd8It9eZglLA4RDhTHrqq48bE7YEzIayqjq8,39054
|
|
24
24
|
flock/core/flock_evaluator.py,sha256=dOXZeDOGZcAmJ9ahqq_2bdGUU1VOXY4skmwTVpAjiVw,1685
|
|
25
|
-
flock/core/flock_factory.py,sha256=
|
|
25
|
+
flock/core/flock_factory.py,sha256=uRqcpu1fFbsDKp5YhGk47c6NjC36vAowQ3wzaQqmkBo,2972
|
|
26
26
|
flock/core/flock_module.py,sha256=96aFVYAgwpKN53xGbivQDUpikOYGFCxK5mqhclOcxY0,3003
|
|
27
|
-
flock/core/flock_registry.py,sha256=
|
|
27
|
+
flock/core/flock_registry.py,sha256=Qcu9juUFNyDAOEsqVxauwVlWdfgKZrSzc8yT8JMiK-c,24246
|
|
28
28
|
flock/core/flock_router.py,sha256=1OAXDsdaIIFApEfo6SRfFEDoTuGt3Si7n2MXiySEfis,2644
|
|
29
29
|
flock/core/api/__init__.py,sha256=OKlhzDWZJfA6ddBwxQUmATY0TSzESsH032u00iVGvdA,228
|
|
30
30
|
flock/core/api/endpoints.py,sha256=qQnJmtcYGkjdKtLllVpyJVjc-iZrvu5EEeVIryyt4tc,12987
|
|
@@ -76,34 +76,31 @@ flock/core/util/file_path_utils.py,sha256=Odf7uU32C-x1KNighbNERSiMtkzW4h8laABIoF
|
|
|
76
76
|
flock/core/util/hydrator.py,sha256=QJvCA8F4nkSP5akp3yg0cT6oaajOr1n7sldW5dCs6Lo,10733
|
|
77
77
|
flock/core/util/input_resolver.py,sha256=ttFiz5L_uzSvxEhWOPL09WfLF--RlLOikLP5hrgE7Mo,6138
|
|
78
78
|
flock/core/util/loader.py,sha256=j3q2qem5bFMP2SmMuYjb-ISxsNGNZd1baQmpvAnRUUk,2244
|
|
79
|
-
flock/evaluators/declarative/declarative_evaluator.py,sha256=
|
|
80
|
-
flock/evaluators/memory/
|
|
81
|
-
flock/evaluators/
|
|
82
|
-
flock/evaluators/
|
|
83
|
-
flock/
|
|
84
|
-
flock/
|
|
85
|
-
flock/modules/
|
|
86
|
-
flock/modules/azure-search/azure_search_module.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
|
-
flock/modules/callback/callback_module.py,sha256=volGGgHtY19qj1wHR6m5a_hmXSbV3Ca3uY6I76YmcfU,2833
|
|
88
|
-
flock/modules/memory/memory_module.py,sha256=bSkdFBW-Pp5ldHhXi8v4kfRM7zknfLR2fsOtbTosucI,14916
|
|
79
|
+
flock/evaluators/declarative/declarative_evaluator.py,sha256=mzg6Ch1JFGZb09goLC3dXxpuojIMR3AcFuoQaIUjEAk,6219
|
|
80
|
+
flock/evaluators/memory/memory_evaluator.py,sha256=ySwz7kcc8suXMJ7gKNSWThW8iOMlE8lUcUzEAHvv8rw,3559
|
|
81
|
+
flock/evaluators/test/test_case_evaluator.py,sha256=3Emcoty0LOLLBIuPGxSpKphuZC9Fu1DTr1vbGg-hd0Q,1233
|
|
82
|
+
flock/evaluators/zep/zep_evaluator.py,sha256=6_5vTdU0yJAH8I8w3-MPXiAZx6iUPhAVCsHjrHzkPLM,2058
|
|
83
|
+
flock/modules/assertion/assertion_module.py,sha256=vzv38E8mvVBQXON_YJ8GFF4kB-sWNychQrMVFmugEjU,12860
|
|
84
|
+
flock/modules/callback/callback_module.py,sha256=q2z-KX7QHlbfDncEP9c_W_DxhYyD6fe9MQfISO9OgrU,2939
|
|
85
|
+
flock/modules/memory/memory_module.py,sha256=MBsUCpnMWY184PlZUKw91b8Yf0jCg9ixsxiqx2tK8LM,15020
|
|
89
86
|
flock/modules/memory/memory_parser.py,sha256=FLH7GL8XThvHiCMfX3eQH7Sz-f62fzhAUmO6_gaDI7U,4372
|
|
90
87
|
flock/modules/memory/memory_storage.py,sha256=CNcLDMmvv0x7Z3YMKr6VveS_VCa7rKPw8l2d-XgqokA,27246
|
|
91
|
-
flock/modules/output/output_module.py,sha256=
|
|
92
|
-
flock/modules/performance/metrics_module.py,sha256=
|
|
93
|
-
flock/modules/zep/zep_module.py,sha256=
|
|
88
|
+
flock/modules/output/output_module.py,sha256=V2g7UF538dwCe4J2QsemADMOnorGfK5Z995Q2ZIV7K4,7385
|
|
89
|
+
flock/modules/performance/metrics_module.py,sha256=D7MHnkHcGe7BfKFV85LqGujZcXM7Mh95BkSmO7UbJEk,16895
|
|
90
|
+
flock/modules/zep/zep_module.py,sha256=uWhSXma4EIMt70L1_588FLnoLNmU8l7Vhhy1viRK1dk,6115
|
|
94
91
|
flock/platform/docker_tools.py,sha256=fpA7-6rJBjPOUBLdQP4ny2QPgJ_042nmqRn5GtKnoYw,1445
|
|
95
92
|
flock/platform/jaeger_install.py,sha256=MyOMJQx4TQSMYvdUJxfiGSo3YCtsfkbNXcAcQ9bjETA,2898
|
|
96
93
|
flock/routers/__init__.py,sha256=w9uL34Auuo26-q_EGlE8Z9iHsw6S8qutTAH_ZI7pn7M,39
|
|
97
94
|
flock/routers/agent/__init__.py,sha256=0ZOYpR8BMnR5iCGfcUiv99g7aT_g13xvm2Shl-XzybY,65
|
|
98
|
-
flock/routers/agent/agent_router.py,sha256=
|
|
95
|
+
flock/routers/agent/agent_router.py,sha256=d4rberqXguJFmDB_hLTaeaDP_rOvCnVQufPELA-pD6M,8327
|
|
99
96
|
flock/routers/agent/handoff_agent.py,sha256=p-0XEPXIyv1T3DGAhhXg2SYXmrwEaJ5pnuLgRSvbiZg,1903
|
|
100
|
-
flock/routers/conditional/conditional_router.py,sha256=
|
|
97
|
+
flock/routers/conditional/conditional_router.py,sha256=_ETx3GhuS3uYqNz6AYWO0JIPov02l1WqxI7Xq-qyMTY,21261
|
|
101
98
|
flock/routers/default/__init__.py,sha256=DOatGX_aE2DWvf55a0Tv7qDK05QFD-hL3sm7g58hmLU,61
|
|
102
|
-
flock/routers/default/default_router.py,sha256=
|
|
103
|
-
flock/routers/feedback/feedback_router.py,sha256=
|
|
104
|
-
flock/routers/list_generator/list_generator_router.py,sha256=
|
|
99
|
+
flock/routers/default/default_router.py,sha256=RgJm6RcS8ah1S49mM9TccfJpenQ0SzzbPCX0K8ZtnHs,2384
|
|
100
|
+
flock/routers/feedback/feedback_router.py,sha256=RODEmPrrNZ-ODdZ0mGfmO8auEnH6KvHN3f5rmFGeq1M,4947
|
|
101
|
+
flock/routers/list_generator/list_generator_router.py,sha256=mofBBZFSfqek_uiYbiC-6avdfhTF8Q8tyEVka1xxALs,7741
|
|
105
102
|
flock/routers/llm/__init__.py,sha256=OV89ebq8RPWZwCJTS2_P46Q0yKD_03rwq_fBOsETd08,63
|
|
106
|
-
flock/routers/llm/llm_router.py,sha256=
|
|
103
|
+
flock/routers/llm/llm_router.py,sha256=F2GAKaiJxWCdtvI1G9vLkoLaY6kR_DgJYoRLenVN9FI,12335
|
|
107
104
|
flock/themes/3024-day.toml,sha256=uOVHqEzSyHx0WlUk3D0lne4RBsNBAPCTy3C58yU7kEY,667
|
|
108
105
|
flock/themes/3024-night.toml,sha256=qsXUwd6ZYz6J-R129_Ao2TKlvvK60svhZJJjB5c8Tfo,1667
|
|
109
106
|
flock/themes/aardvark-blue.toml,sha256=5ZgsxP3pWLPN3yJ2Wd9ErCo7fy_VJpIfje4kriDKlqo,1667
|
|
@@ -445,8 +442,8 @@ flock/workflow/activities.py,sha256=Rcgcepa-RzaEjKo2aNuI14O_sX8ij0RrqeyPa0oSw8M,
|
|
|
445
442
|
flock/workflow/agent_activities.py,sha256=NhBZscflEf2IMfSRa_pBM_TRP7uVEF_O0ROvWZ33eDc,963
|
|
446
443
|
flock/workflow/temporal_setup.py,sha256=VWBgmBgfTBjwM5ruS_dVpA5AVxx6EZ7oFPGw4j3m0l0,1091
|
|
447
444
|
flock/workflow/workflow.py,sha256=I9MryXW_bqYVTHx-nl2epbTqeRy27CAWHHA7ZZA0nAk,1696
|
|
448
|
-
flock_core-0.4.
|
|
449
|
-
flock_core-0.4.
|
|
450
|
-
flock_core-0.4.
|
|
451
|
-
flock_core-0.4.
|
|
452
|
-
flock_core-0.4.
|
|
445
|
+
flock_core-0.4.0b25.dist-info/METADATA,sha256=Ph3rXzRZxPyXT03fVs_uebGvo9scAX-Fa_FqN5tAG_U,13004
|
|
446
|
+
flock_core-0.4.0b25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
447
|
+
flock_core-0.4.0b25.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
|
|
448
|
+
flock_core-0.4.0b25.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
|
|
449
|
+
flock_core-0.4.0b25.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
from flock.core.flock_evaluator import FlockEvaluator
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class NaturalLanguageEvaluator(FlockEvaluator):
|
|
7
|
-
"""Evaluator that uses natural language prompting."""
|
|
8
|
-
|
|
9
|
-
name: str = "natural_language"
|
|
10
|
-
prompt_template: str = ""
|
|
11
|
-
client: Any = None # OpenAI client
|
|
12
|
-
|
|
13
|
-
async def setup(self, input_schema: str, output_schema: str) -> None:
|
|
14
|
-
"""Set up prompt template and client."""
|
|
15
|
-
from openai import AsyncOpenAI
|
|
16
|
-
|
|
17
|
-
# Create prompt template
|
|
18
|
-
self.prompt_template = f"""
|
|
19
|
-
You are an AI assistant that processes inputs and generates outputs.
|
|
20
|
-
|
|
21
|
-
Input Format:
|
|
22
|
-
{input_schema}
|
|
23
|
-
|
|
24
|
-
Required Output Format:
|
|
25
|
-
{output_schema}
|
|
26
|
-
|
|
27
|
-
Please process the following input and provide output in the required format:
|
|
28
|
-
{{input}}
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
# Set up client
|
|
32
|
-
self.client = AsyncOpenAI()
|
|
33
|
-
|
|
34
|
-
async def evaluate(self, inputs: dict[str, Any]) -> dict[str, Any]:
|
|
35
|
-
"""Evaluate using natural language."""
|
|
36
|
-
if not self.client:
|
|
37
|
-
raise RuntimeError("Evaluator not set up")
|
|
38
|
-
|
|
39
|
-
# Format input for prompt
|
|
40
|
-
input_str = "\n".join(f"{k}: {v}" for k, v in inputs.items())
|
|
41
|
-
|
|
42
|
-
# Get completion
|
|
43
|
-
response = await self.client.chat.completions.create(
|
|
44
|
-
model=self.config.model,
|
|
45
|
-
messages=[
|
|
46
|
-
{
|
|
47
|
-
"role": "user",
|
|
48
|
-
"content": self.prompt_template.format(input=input_str),
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
temperature=self.config.temperature,
|
|
52
|
-
max_tokens=self.config.max_tokens,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
# Parse response into dictionary
|
|
56
|
-
try:
|
|
57
|
-
import json
|
|
58
|
-
|
|
59
|
-
return json.loads(response.choices[0].message.content)
|
|
60
|
-
except json.JSONDecodeError:
|
|
61
|
-
return {"result": response.choices[0].message.content}
|
|
62
|
-
|
|
63
|
-
async def cleanup(self) -> None:
|
|
64
|
-
"""Close client."""
|
|
65
|
-
if self.client:
|
|
66
|
-
await self.client.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|