Convert WayFlow agents to Agent Spec#

This usage example shows how a WayFlow Agent can be converted into an Agent Spec JSON format.

# Create a WayFlow Agent
from wayflowcore.agent import Agent
from wayflowcore.models import OpenAICompatibleModel
from wayflowcore.tools import tool

@tool("subtraction-tool", description_mode="only_docstring")
def subtraction_tool(a: float, b: float) -> float:
    """subtract two numbers together"""
    return a - b

llm = OpenAICompatibleModel(
    name="llama-3.3-70b-instruct",
    model_id="/storage/models/Llama-3.3-70B-Instruct",
    base_url="url.to.my.llm",
)

wayflow_agent = Agent(
    name="wayflow_agent",
    description="Simple agent with a tool.",
    llm=llm,
    custom_instruction="Perform subtraction with the given tool.",
    tools=[subtraction_tool],
)

# Convert to Agent Spec
from wayflowcore.agentspec import AgentSpecExporter

agentspec_config = AgentSpecExporter().to_json(wayflow_agent)