DaprAgentSpecExporter¶
Class for exporting Dapr Agents configurations to Open Agent Spec (OAS) format.
Class Reference¶
DaprAgentSpecExporter
¶
Exporter for converting Dapr Agents components to OAS specifications.
This class provides methods to export Dapr Agents and workflows to Open Agent Spec (OAS) format in JSON or YAML.
Example
Initialize the exporter.
Source code in src/dapr_agents_oas_adapter/exporter.py
Functions¶
to_dict
¶
Export a Dapr component to OAS dictionary format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Any
|
The Dapr component to export (or object) |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing the OAS specification |
Raises:
| Type | Description |
|---|---|
ConversionError
|
If the component cannot be exported |
Source code in src/dapr_agents_oas_adapter/exporter.py
to_yaml
¶
Export a Dapr component to OAS YAML format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
DaprAgentConfig | WorkflowDefinition
|
The Dapr component to export |
required |
Returns:
| Type | Description |
|---|---|
str
|
YAML string containing the OAS specification |
Raises:
| Type | Description |
|---|---|
ConversionError
|
If the component cannot be exported |
Source code in src/dapr_agents_oas_adapter/exporter.py
to_json
¶
Export a Dapr component to OAS JSON format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
DaprAgentConfig | WorkflowDefinition
|
The Dapr component to export |
required |
indent
|
int
|
JSON indentation level |
2
|
Returns:
| Type | Description |
|---|---|
str
|
JSON string containing the OAS specification |
Raises:
| Type | Description |
|---|---|
ConversionError
|
If the component cannot be exported |
Source code in src/dapr_agents_oas_adapter/exporter.py
Usage Examples¶
Export to Dictionary¶
from dapr_agents_oas_adapter import DaprAgentSpecExporter
from dapr_agents_oas_adapter.types import DaprAgentConfig
exporter = DaprAgentSpecExporter()
config = DaprAgentConfig(
name="my_agent",
role="Assistant",
goal="Help users"
)
oas_dict = exporter.to_dict(config)
# {"component_type": "Agent", "name": "my_agent", ...}
Export to YAML¶
Export to JSON¶
Export Workflow¶
from dapr_agents_oas_adapter.types import (
WorkflowDefinition,
WorkflowTaskDefinition,
WorkflowEdgeDefinition
)
workflow = WorkflowDefinition(
name="my_workflow",
tasks=[
WorkflowTaskDefinition(name="start", task_type="start"),
WorkflowTaskDefinition(name="end", task_type="end")
],
edges=[
WorkflowEdgeDefinition(from_node="start", to_node="end")
],
start_node="start",
end_nodes=["end"]
)
oas = exporter.to_dict(workflow)
Related¶
- DaprAgentSpecLoader - Load OAS specs
- Types - Data models