This document describes the core framework abstractions and the AWEL (Agentic Workflow Expression Language) workflow engine that form the foundational layer of DB-GPT. The core framework, located in packages/dbgpt-core, provides reusable interfaces for storage, resource management, and serialization that are used throughout the system. AWEL provides a declarative, DAG-based workflow execution engine for orchestrating complex agentic workflows.
For information about the overall system architecture and package organization, see Package Structure and Dependencies. For details on multi-agent systems that leverage AWEL, see Multi-Agents and AWEL Workflows.
The core framework in packages/dbgpt-core provides foundational abstractions that enable modularity and extensibility throughout DB-GPT. This package defines interfaces and base implementations that other packages depend on, establishing contracts for storage, serialization, and resource management.
Core Framework Components and Dependencies
Sources: README.md1-363 packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py1-140
The core framework defines generic storage interfaces that enable different persistence backends. The primary abstractions are:
| Interface/Class | Purpose | Location |
|---|---|---|
StorageInterface[T, D] | Generic storage contract with CRUD operations | dbgpt.core.interface.storage |
ResourceIdentifier | Unique identifier for stored resources | dbgpt.core.interface.storage |
QuerySpec | Query specification with conditions, limits, offsets | dbgpt.core.interface.storage |
StorageItemAdapter[T, D] | Converts between domain objects (T) and storage format (D) | dbgpt.core.interface.storage |
Serializer | Serialization/deserialization of objects | dbgpt.core |
The StorageInterface provides methods for:
save(data: T) - Persist a new itemupdate(data: T) - Modify an existing itemsave_or_update(data: T) - Upsert operationload(resource_id: ResourceIdentifier, cls: Type[T]) - Retrieve by IDdelete(resource_id: ResourceIdentifier) - Remove an itemquery(spec: QuerySpec, cls: Type[T]) - Query with conditionscount(spec: QuerySpec, cls: Type[T]) - Count matching itemsSources: packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py10-16
The framework provides SQLAlchemyStorage, a concrete implementation of StorageInterface backed by relational databases via SQLAlchemy. This enables metadata storage in SQLite, MySQL, PostgreSQL, and other SQL databases.
SQLAlchemy Storage Implementation Flow
The SQLAlchemyStorage class manages database interactions:
DatabaseManager instanceStorageItemAdapter to convert between domain objects and SQLAlchemy modelsKey implementation details from packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py31-140:
The adapter pattern (StorageItemAdapter) enables clean separation between domain models and persistence models. The adapter must implement:
to_storage_format(item: T) -> D - Convert domain object to ORM modelfrom_storage_format(item: D) -> T - Convert ORM model to domain objectget_query_for_identifier(model_class, resource_id, session) - Build query for ID lookupSources: packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py31-140
AWEL is a declarative workflow engine that enables developers to define complex, multi-step processes as Directed Acyclic Graphs (DAGs). It provides the orchestration layer for agents, data processing pipelines, and service integration throughout DB-GPT.
AWEL System Architecture and Integration
AWEL workflows are composed of:
Sources: README.md55-57 README.zh.md55-58
AWEL workflows are defined as DAGs where:
The DAG structure ensures:
Example AWEL Workflow DAG
Key characteristics:
Sources: README.md55-57
AWEL provides a library of reusable operators for common workflow patterns:
| Operator Type | Purpose | Example Use Case |
|---|---|---|
MapOperator | Transform data 1:1 | Parse JSON, call LLM, format output |
JoinOperator | Combine multiple inputs | Merge retrieval results from multiple sources |
BranchOperator | Conditional routing | Route to different agents based on query type |
ReduceOperator | Aggregate multiple items | Combine scores from multiple retrievers |
FilterOperator | Select items by predicate | Filter documents by relevance threshold |
Operators support:
Sources: README.md55-57
Triggers define how workflows are initiated:
HTTP Trigger
/api/v1/awel/trigger/<workflow_id>Schedule Trigger
Event Trigger
Sources: README.md153-154
AWEL serves as the orchestration backbone for multi-agent systems. Agents can be invoked as workflow operators, enabling:
Example workflow: A user query triggers a workflow that:
This integration is covered in detail in Multi-Agents and AWEL Workflows.
Sources: README.md76-77
Beyond storage, the core framework provides additional abstractions used throughout DB-GPT.
The ResourceIdentifier abstraction provides a universal way to reference stored items:
This enables:
The QuerySpec class encapsulates query parameters:
This abstraction allows storage implementations to optimize queries based on backend capabilities (e.g., database indexes, vector similarity search).
Sources: packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py112-132
The Serializer interface enables pluggable serialization strategies:
Serializers are used by storage implementations to persist complex objects that don't map directly to database columns.
Sources: packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py9
The core framework abstractions are used extensively throughout DB-GPT:
Core Framework Usage Across Packages
RAG Service (RAG and Knowledge Services) uses:
SQLAlchemyStorage for document and chunk metadataEvaluation Service (Evaluation and Benchmark Services) uses:
SQLAlchemyStorage for benchmark results and dataset metadataKnowledge Service uses:
Vector Store Extensions (packages/dbgpt-ext) implement:
Sources: README.md68-81 packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py1-140
The core framework is organized in packages/dbgpt-core with the following key modules:
packages/dbgpt-core/
├── src/dbgpt/
│ ├── core/
│ │ ├── interface/
│ │ │ └── storage.py # Storage interfaces
│ │ └── serializer.py # Serialization utilities
│ ├── storage/
│ │ └── metadata/
│ │ ├── db_storage.py # SQLAlchemy implementation
│ │ └── db_manager.py # Database manager
│ └── awel/ # AWEL workflow engine (implied)
└── pyproject.toml # Package metadata
Dependencies are managed through pyproject.toml, allowing selective installation. The core package has minimal dependencies, while optional extras enable specific features (database drivers, serialization formats).
For more details on the complete package structure and dependency management, see Package Structure and Dependencies.
Sources: README.md122-127 packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py1-4
Refresh this wiki