flock-core 0.3.23__py3-none-any.whl → 0.3.30__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/__init__.py +2 -2
- flock/core/api/__init__.py +11 -0
- flock/core/api/endpoints.py +222 -0
- flock/core/api/main.py +237 -0
- flock/core/api/models.py +34 -0
- flock/core/api/run_store.py +72 -0
- flock/core/api/ui/__init__.py +0 -0
- flock/core/api/ui/routes.py +271 -0
- flock/core/api/ui/utils.py +119 -0
- flock/core/flock.py +475 -397
- flock/core/flock_agent.py +384 -121
- flock/core/flock_registry.py +614 -0
- flock/core/logging/logging.py +97 -23
- flock/core/mixin/dspy_integration.py +360 -158
- flock/core/serialization/__init__.py +7 -1
- flock/core/serialization/callable_registry.py +52 -0
- flock/core/serialization/serializable.py +259 -37
- flock/core/serialization/serialization_utils.py +184 -0
- flock/workflow/activities.py +2 -2
- {flock_core-0.3.23.dist-info → flock_core-0.3.30.dist-info}/METADATA +6 -3
- {flock_core-0.3.23.dist-info → flock_core-0.3.30.dist-info}/RECORD +24 -15
- flock/core/flock_api.py +0 -214
- flock/core/registry/agent_registry.py +0 -120
- {flock_core-0.3.23.dist-info → flock_core-0.3.30.dist-info}/WHEEL +0 -0
- {flock_core-0.3.23.dist-info → flock_core-0.3.30.dist-info}/entry_points.txt +0 -0
- {flock_core-0.3.23.dist-info → flock_core-0.3.30.dist-info}/licenses/LICENSE +0 -0
flock/core/logging/logging.py
CHANGED
|
@@ -46,50 +46,110 @@ def get_current_trace_id() -> str:
|
|
|
46
46
|
return "no-trace"
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
# ---------------------------------------------------------------------
|
|
50
|
-
# 2. A color map for different logger names
|
|
51
|
-
# You can add or change entries as you like.
|
|
52
|
-
# ---------------------------------------------------------------------
|
|
53
49
|
COLOR_MAP = {
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
50
|
+
# Core & Orchestration
|
|
51
|
+
"flock": "magenta", # Color only
|
|
52
|
+
"agent": "blue", # Color only
|
|
53
|
+
"workflow": "cyan", # Color only
|
|
54
|
+
"activities": "cyan",
|
|
58
55
|
"context": "green",
|
|
59
|
-
|
|
56
|
+
# Components & Mechanisms
|
|
57
|
+
"registry": "yellow", # Color only
|
|
58
|
+
"serialization": "yellow",
|
|
59
|
+
"serialization.utils": "light-yellow",
|
|
60
|
+
"evaluator": "light-blue",
|
|
61
|
+
"module": "light-green",
|
|
62
|
+
"router": "light-magenta",
|
|
63
|
+
"mixin.dspy": "yellow",
|
|
64
|
+
# Specific Modules (Examples)
|
|
65
|
+
"memory": "yellow",
|
|
66
|
+
"module.output": "green",
|
|
67
|
+
"module.metrics": "blue",
|
|
68
|
+
"module.zep": "red",
|
|
69
|
+
"module.hierarchical": "light-green",
|
|
70
|
+
# Tools & Execution
|
|
60
71
|
"tools": "light-black",
|
|
61
|
-
"
|
|
72
|
+
"interpreter": "light-yellow",
|
|
73
|
+
# API Components
|
|
74
|
+
"api": "white", # Color only
|
|
75
|
+
"api.main": "white",
|
|
76
|
+
"api.endpoints": "light-black",
|
|
77
|
+
"api.run_store": "light-black",
|
|
78
|
+
"api.ui": "light-blue", # Color only
|
|
79
|
+
"api.ui.routes": "light-blue",
|
|
80
|
+
"api.ui.utils": "cyan",
|
|
81
|
+
# Default/Unknown
|
|
82
|
+
"unknown": "light-black",
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
LOGGERS = [
|
|
86
|
+
"flock", # Core Flock orchestration
|
|
87
|
+
"agent", # General agent operations
|
|
88
|
+
"context", # Context management
|
|
89
|
+
"registry", # Unified registry operations (new)
|
|
90
|
+
"serialization", # General serialization (new - can be base for others)
|
|
91
|
+
"serialization.utils", # Serialization helpers (new, more specific)
|
|
92
|
+
"evaluator", # Base evaluator category (new/optional)
|
|
93
|
+
"module", # Base module category (new/optional)
|
|
94
|
+
"router", # Base router category (new/optional)
|
|
95
|
+
"mixin.dspy", # DSPy integration specifics (new)
|
|
96
|
+
"memory", # Memory module specifics
|
|
97
|
+
"module.output", # Output module specifics (example specific module)
|
|
98
|
+
"module.metrics", # Metrics module specifics (example specific module)
|
|
99
|
+
"module.zep", # Zep module specifics (example specific module)
|
|
100
|
+
"module.hierarchical", # Hierarchical memory specifics (example specific module)
|
|
101
|
+
"interpreter", # Code interpreter (if still used)
|
|
102
|
+
"activities", # Temporal activities
|
|
103
|
+
"workflow", # Temporal workflow logic
|
|
104
|
+
"tools", # Tool execution/registration
|
|
105
|
+
"api", # General API server (new)
|
|
106
|
+
"api.main", # API main setup (new)
|
|
107
|
+
"api.endpoints", # API endpoints (new)
|
|
108
|
+
"api.run_store", # API run state management (new)
|
|
109
|
+
"api.ui", # UI general (new)
|
|
110
|
+
"api.ui.routes", # UI routes (new)
|
|
111
|
+
"api.ui.utils", # UI utils (new)
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
BOLD_CATEGORIES = [
|
|
65
115
|
"flock",
|
|
66
|
-
"interpreter",
|
|
67
|
-
"memory",
|
|
68
|
-
"activities",
|
|
69
|
-
"context",
|
|
70
|
-
"registry",
|
|
71
|
-
"tools",
|
|
72
116
|
"agent",
|
|
117
|
+
"workflow",
|
|
118
|
+
"registry",
|
|
119
|
+
"api",
|
|
120
|
+
"api.ui",
|
|
73
121
|
]
|
|
74
122
|
|
|
75
123
|
|
|
76
124
|
def color_for_category(category: str) -> str:
|
|
77
|
-
"""Return the
|
|
78
|
-
|
|
125
|
+
"""Return the Rich markup color code name for the given category."""
|
|
126
|
+
# Handle potentially nested names like 'serialization.utils'
|
|
127
|
+
# Try exact match first, then go up the hierarchy
|
|
128
|
+
if category in COLOR_MAP:
|
|
129
|
+
return COLOR_MAP[category]
|
|
130
|
+
parts = category.split(".")
|
|
131
|
+
for i in range(len(parts) - 1, 0, -1):
|
|
132
|
+
parent_category = ".".join(parts[:i])
|
|
133
|
+
if parent_category in COLOR_MAP:
|
|
134
|
+
return COLOR_MAP[parent_category]
|
|
135
|
+
# Fallback to default 'unknown' color
|
|
136
|
+
return COLOR_MAP.get("unknown", "light-black") # Final fallback
|
|
79
137
|
|
|
80
138
|
|
|
81
139
|
def custom_format(record):
|
|
82
|
-
"""A formatter that applies truncation
|
|
140
|
+
"""A formatter that applies truncation and sequential styling tags."""
|
|
83
141
|
t = record["time"].strftime("%Y-%m-%d %H:%M:%S")
|
|
84
142
|
level_name = record["level"].name
|
|
85
143
|
category = record["extra"].get("category", "unknown")
|
|
86
144
|
trace_id = record["extra"].get("trace_id", "no-trace")
|
|
87
|
-
|
|
145
|
+
color_tag = color_for_category(
|
|
146
|
+
category
|
|
147
|
+
) # Get the color tag name (e.g., "yellow")
|
|
88
148
|
|
|
89
|
-
# Get the formatted message (already includes args)
|
|
90
149
|
message = record["message"]
|
|
150
|
+
message = message.replace("{", "{{").replace("}", "}}")
|
|
91
151
|
|
|
92
|
-
#
|
|
152
|
+
# MAX_LENGTH = 500 # Example value
|
|
93
153
|
if len(message) > MAX_LENGTH:
|
|
94
154
|
truncated_chars = len(message) - MAX_LENGTH
|
|
95
155
|
message = (
|
|
@@ -97,10 +157,24 @@ def custom_format(record):
|
|
|
97
157
|
+ f"<yellow>...+({truncated_chars} chars)</yellow>"
|
|
98
158
|
)
|
|
99
159
|
|
|
160
|
+
# Determine if category needs bolding (can refine this logic)
|
|
161
|
+
needs_bold = category in BOLD_CATEGORIES
|
|
162
|
+
|
|
163
|
+
# Apply tags sequentially
|
|
164
|
+
category_styled = f"[{category}]" # Start with the plain category name
|
|
165
|
+
category_styled = (
|
|
166
|
+
f"<{color_tag}>{category_styled}</{color_tag}>" # Wrap with color
|
|
167
|
+
)
|
|
168
|
+
if needs_bold:
|
|
169
|
+
category_styled = (
|
|
170
|
+
f"<bold>{category_styled}</bold>" # Wrap with bold if needed
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Final format string using sequential tags for category
|
|
100
174
|
return (
|
|
101
175
|
f"<green>{t}</green> | <level>{level_name: <8}</level> | "
|
|
102
176
|
f"<cyan>[trace_id: {trace_id}]</cyan> | "
|
|
103
|
-
f"
|
|
177
|
+
f"{category_styled} | {message}\n" # Apply the sequentially styled category
|
|
104
178
|
)
|
|
105
179
|
|
|
106
180
|
|