-
Notifications
You must be signed in to change notification settings - Fork 3
Add LLM workflow planner / builder and field mapping #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
…nd update related agent logic - Introduced a new field `report` in `LitSearchAgentOutputSchema` to store synthesized research reports. - Updated `DeepLitSearchAgent` to pass the `research_report` to the new `report` field. - Modified `agent_registry.json` to include the new `report` field in the agent configuration. - Refactored test cases in `deep_search_test.py` to reflect changes in the output schema and ensure proper validation of the report field.
- define classes for building workflow definitions in the AKD framework. - Implement `WorkflowField`, `WorkflowNodeIO`, `WorkflowNode`, `WorkflowEdge`, and `WorkflowFormat` classes for structured workflow representation. - Added methods for custom serialization, JSON export, and file saving for workflow definitions. - Included functions to create and load workflows from dictionaries and JSON files, respectively.
- Introduced `WorkflowBuilder` class to construct `WorkflowFormat` from `WorkflowPlan` with runtime data flow. - Implemented a three-tier field mapping strategy: explicit mappings, exact name matches, and LLM-generated mappings. - Added methods for building nodes and edges, validating agent existence, and identifying unmapped fields for LLM generation. - Integrated logging for better traceability of mapping processes and warnings for missing agents or fields.
a278d60 to
91e5b08
Compare
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
NISH1001
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments: Some are nitpick. Some are improvements.
|
REsolving some of these comments myself. |
- ALos use pydantic-v2 style model config `model_config` intead of `class Config`
- Bugfix `report` field access
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
- FieldMappingRegistry: Three-tier mapping resolution (explicit, exact match, LLM) - FieldMappingGenerator: LLM-based semantic field mapper - Required by WorkflowBuilder for intelligent field mapping between agents
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
… auto-set ready_to_generate based on workflow_plan existence, and rename plan_workflow to init_planner_session for clarity in LLMWorkflowPlanner class. Enhance workflow validation logging in InteractivePlannerSession.
…r.py for improved readability. Update method calls to use init_planner_session for clarity and ensure consistent string formatting throughout the file.
…_format.py to ensure proper detection of invalid node references, JSONPath formats, orphaned nodes, and edge cases. Enhance coverage for both strict and non-strict validation scenarios.
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
- `conversation_history: list[dict[str, str]]` is added to INteractivePlannerSession - So, that externally we can inject the history for resuming
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
akd.utils.get_akd_root
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
- `LLMMappingEntry.generated_at` now uses default factory
|
❌ Tests failed (exit code: 1) 📊 Test Results
Branch: 📋 Full coverage report and logs are available in the workflow run. |
Overview
This PR adds a LLM-based workflow planner that converts natural language research requests into executable workflows (compatible with AKD Backend) with automatic data routing between agents.
Problem
When workflows need multiple agent interactions (which are composed by LLM) - and when chaining agents in a workflow (e.g., deep_search → gap_analysis), we need to:
results→search_results)Solution
LLM Workflow Planner
Interactive conversational planner that:
7-Phase Conversation Flow:
Workflow Builder
Transforms high-level plans into executable workflows:
Field Mapping System
Three-tier strategy for mapping fields:
Why JSONPath?
Problem: At runtime, how does gap_analysis get deep_search's results?
Without JSONPath (hardcoded):
With JSONPath (declarative):
{ "type": "gap_analysis", "io_map": { "search_results": "$.deep_search.outputs.results" } }The executor reads the JSONPath and fetches data from the runtime state - no custom code needed per agent pair.
Implementation
Core Components
LLM Planner (NEW):
llm_planner.py: Conversational workflow planningLLMWorkflowPlanner: Main planner class using LiteLLMInstructorBaseAgent (multi-provider support)InteractivePlannerSession: Manages conversation stateWorkflow Builder:
format_builder.py: Data models (WorkflowFormat, WorkflowNode, etc.)workflow_builder.py: Workflow generation with auto-generated io_mapstructures.py: Shared data structures (WorkflowPlan, AgentSuggestion)Field Mapping:
field_mapping_registry.py: Mapping storage and resolutionfield_mapping_generator.py: LLM-based semantic mappingDocumentation (NEW):
akd/planner/README.md: Comprehensive documentationDemo (NEW):
scripts/demo_planner.py: Interactive CLI demoValidation System
WorkflowFormat Validation (format_builder.py):
validate_io_map(): Validates JSONPath references (format, node existence)validate_edges(): Validates graph structure (START/END, orphaned nodes)validate(): Validation with categorized resultsget_node_summary(): Workflow statistics (nodes, edges, io_map entries)Conversation Control (llm_planner.py):
ready_to_generatevalidator prevents infinite loopsEnum Normalization:
io_map Generation Example
Tests
79 tests
Test Coverage:
Files Changed
Added:
Modified:
Usage
Quick Start - LLM Planner
Interactive Planning (NEW)
Backend Integration Example
scripts/minimal_planner.pydemonstrates backend/frontend integration:python3 scripts/minimal_planner.py "Find papers on AlphaFold and identify research gaps"Direct WorkflowBuilder Usage
Interactive Demo
Try the interactive CLI:
Documentation
See comprehensive documentation at
akd/planner/README.md.Enabled Workflows