Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "flock-core"
version = "0.4.519"
version = "0.4.525"
description = "Declarative LLM Orchestration at Scale"
readme = "README.md"
authors = [
Expand Down Expand Up @@ -45,7 +45,7 @@ dependencies = [
"thefuzz>=0.22.1",
"tiktoken>=0.8.0",
"toml>=0.10.2",
"tqdm>=4.67.1",
"tqdm>=4.60.1",
"uvicorn>=0.34.0",
"aiosqlite>=0.21.0",
"markdown2>=2.5.3",
Expand All @@ -54,15 +54,15 @@ dependencies = [
"opik>=1.7.26",
"azure-data-tables>=12.7.0",
"croniter>=6.0.0",

]

[project.optional-dependencies]
basic-tools = [
"docling>=2.18.0",
"docling>=2.34.0",
"tavily-python>=0.5.0",
"markdownify>=0.14.1",
"duckduckgo-search>=7.3.2",

]
azure-tools = [
"azure-identity>=1.23.0",
Expand All @@ -83,7 +83,7 @@ evaluation = [
"sentence-transformers>=3.4.1",
]
all-tools = [
"docling>=2.18.0",
"docling>=2.34.0",
"tavily-python>=0.5.0",
"markdownify>=0.14.1",
"duckduckgo-search>=7.3.2",
Expand All @@ -94,7 +94,7 @@ all-tools = [
"docker>=7.1.0",
]
all = [
"docling>=2.18.0",
"docling>=2.34.0",
"tavily-python>=0.5.0",
"markdownify>=0.14.1",
"duckduckgo-search>=7.3.2",
Expand Down Expand Up @@ -214,3 +214,11 @@ docs = ["_docs-build", "_docs-serve"]

[tool.poe.tasks.clean]
script = "poethepoet.scripts:rm('dist', 'htmlcov', 'logs','metrics','.mypy_cache', '.pytest_cache', './**/__pycache__')"

[tool.uv.sources]
torch = { index = "pytorch" }

[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
2 changes: 2 additions & 0 deletions src/flock/core/flock_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def create_default_agent(
write_to_file: bool = False,
stream: bool = False,
include_thought_process: bool = False,
include_reasoning: bool = False,
temporal_activity_config: TemporalActivityConfig | None = None,
) -> FlockAgent:
"""Creates a default FlockAgent.
Expand All @@ -433,6 +434,7 @@ def create_default_agent(
max_retries=max_retries,
stream=stream,
include_thought_process=include_thought_process,
include_reasoning=include_reasoning,
)

evaluator = DeclarativeEvaluator(name="default", config=eval_config)
Expand Down
25 changes: 24 additions & 1 deletion src/flock/evaluators/declarative/declarative_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class DeclarativeEvaluatorConfig(FlockEvaluatorConfig):
default=False,
description="Include the thought process in the output.",
)
include_reasoning: bool = Field(
default=False,
description="Include the reasoning in the output.",
)
kwargs: dict[str, Any] = Field(default_factory=dict)


Expand Down Expand Up @@ -154,6 +158,9 @@ async def evaluate(
self._lm_history = lm_history

console.print("\n")
result_dict = self.filter_reasoning(
result_dict, self.config.include_reasoning
)
return self.filter_thought_process(
result_dict, self.config.include_thought_process
)
Expand All @@ -170,6 +177,9 @@ async def evaluate(
)
self._cost = cost
self._lm_history = lm_history
result_dict = self.filter_reasoning(
result_dict, self.config.include_reasoning
)
return self.filter_thought_process(
result_dict, self.config.include_thought_process
)
Expand All @@ -190,5 +200,18 @@ def filter_thought_process(
return {
k: v
for k, v in result_dict.items()
if not (k.startswith("reasoning") or k.startswith("trajectory"))
if not (k.startswith("trajectory"))
}

def filter_reasoning(
self, result_dict: dict[str, Any], include_reasoning: bool
) -> dict[str, Any]:
"""Filter out reasoning from the result dictionary."""
if include_reasoning:
return result_dict
else:
return {
k: v
for k, v in result_dict.items()
if not (k.startswith("reasoning"))
}
4 changes: 4 additions & 0 deletions src/flock/routers/conditional/conditional_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ class ConditionalRouterConfig(FlockRouterConfig):
default="flock.assertion_feedback", # Useful if paired with AssertionCheckerModule
description="Optional context key containing feedback message to potentially include when retrying.",
)
feedback_on_failure: str | None = Field(
default=None,
description="Default feedback message to use when condition evaluation fails.",
)
retry_count_context_key_prefix: str = Field(
default="flock.conditional_retry_count_",
description="Internal prefix for context key storing retry attempts per agent.",
Expand Down
15 changes: 13 additions & 2 deletions src/flock/webapp/app/api/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Form,
Request,
)
from fastapi.encoders import jsonable_encoder
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates

Expand Down Expand Up @@ -151,7 +152,13 @@ async def htmx_run_flock(
return HTMLResponse(f"<p class='error'>Error processing inputs for {start_agent_name}: {e_parse}</p>")

result_data = await run_current_flock_service(start_agent_name, inputs, request.app.state)
raw_json_for_template = json.dumps(result_data, indent=2)


raw_json_for_template = json.dumps(
jsonable_encoder(result_data), # ← converts every nested BaseModel, datetime, etc.
indent=2,
ensure_ascii=False
)
# Unescape newlines for proper display in HTML <pre> tag
result_data_raw_json_str = raw_json_for_template.replace('\\n', '\n')
root_path = request.scope.get("root_path", "")
Expand Down Expand Up @@ -215,7 +222,11 @@ async def htmx_run_shared_flock(

shared_logger.info(f"HTMX Run Shared: Executing agent '{start_agent_name}' in pre-loaded Flock '{temp_flock.name}'. Inputs: {list(inputs.keys())}")
result_data = await temp_flock.run_async(start_agent=start_agent_name, input=inputs, box_result=False)
raw_json_for_template = json.dumps(result_data, indent=2)
raw_json_for_template = json.dumps(
jsonable_encoder(result_data), # ← converts every nested BaseModel, datetime, etc.
indent=2,
ensure_ascii=False
)
# Unescape newlines for proper display in HTML <pre> tag
result_data_raw_json_str = raw_json_for_template.replace('\\n', '\n')
shared_logger.info(f"HTMX Run Shared: Agent '{start_agent_name}' executed. Result keys: {list(result_data.keys()) if isinstance(result_data, dict) else 'N/A'}")
Expand Down
Loading
Loading