Convert Microsoft Agent Framework agents to Agent Spec#

This usage example showcases how a Microsoft Agent Framework Agent can be converted into an Agent Spec configuration in JSON format.

# Create an Agent Framework Agent
from agent_framework import ChatAgent, tool
from agent_framework.openai import OpenAIChatClient

@tool()
def get_weather(city: str) -> str:
    """Returns the weather in a specific city.
    Args
    ----
        city: The city to check the weather for

    Returns
    -------
        weather: The weather in that city
    """
    return f"The weather in {city} is sunny."

agent_framework_agent = ChatAgent(
    chat_client=OpenAIChatClient(
        api_key="ollama",
        base_url="url.to.agi.model",
        model_id="agi_ollama_model",
    ),
    name="Weather Agent",
    instructions="You are a weather agent. Use the provided tool to get data related to the weather based on the city mentioned in the user query.",
    tools=get_weather,
)

# Convert to Agent Spec
from pyagentspec.adapters.agent_framework import AgentSpecExporter

agentspec_config = AgentSpecExporter().to_json(agent_framework_agent)