Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion adapters_examples/langgraph/langgraph_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
from langchain_openai import ChatOpenAI
from langgraph.graph import END, START, StateGraph
from langgraph.prebuilt import ToolNode
from langgraph_agentspec_adapter.agentspecexporter import AgentSpecExporter
from pydantic import SecretStr

from pyagentspec.adapters.langgraph import AgentSpecExporter


class MessagesState(TypedDict):
messages: list[Any]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/pyagentspec/source/_templates/navbar-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<li class="nav-item {% if pagename == 'changelog' %} current active{% endif %}">
<a class="nav-link nav-internal" href="{{ pathto("changelog") }}">Release Notes</a>
</li>
<li class="nav-item {% if pagename == 'misc/reference_sheet' %} current active{% endif %}">
<a class="nav-link nav-internal" href="{{ pathto("misc/reference_sheet") }}">Reference Sheet</a>
<li class="nav-item {% if pagename == 'adapters/langgraph' %} current active{% endif %}">
<a class="nav-link nav-internal" href="{{ pathto("adapters/langgraph") }}">Adapters</a>
</li>
<li class="nav-item {% if pagename == 'ecosystem/integrations' %} current active{% endif %}">
<a class="nav-link nav-internal" href="{{ pathto("ecosystem/integrations") }}">Ecosystem</a>
Expand Down
61 changes: 61 additions & 0 deletions docs/pyagentspec/source/adapters/autogen.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. _autogenadapter:

=============================
Agent Spec Adapters - AutoGen
=============================


.. figure:: ../_static/icons/autogen-adapter.jpg
:align: center
:scale: 20%
:alt: Agent Spec adapter for AutoGen

↑ With the **Agent Spec adapter for AutoGen**, you can easily import agents from external frameworks using Agent Spec and run them with AutoGen.


*Microsoft AutoGen supports the development of multi-agent conversational systems,
allowing agents to communicate and collaborate to solve tasks.*


Get started
===========

To get started, set up your Python environment (Python 3.10 to 3.12 required),
and then install the PyAgentSpec package with the AutoGen extension.


.. code-block:: bash

python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install "pyagentspec[autogen]"


You are now ready to use the adapter:

- Run Agent Spec configurations with AutoGen (see more details :ref:`below <spectoautogen>`)
- Convert AutoGen agents to Agent Spec (see more details :ref:`below <autogentospec>`)



.. _spectoautogen:

Run Agent Spec configurations with AutoGen
==========================================


.. literalinclude:: ../code_examples/adapter_autogen_quickstart.py
:language: python
:start-after: .. start-agentspec_to_runtime
:end-before: .. end-agentspec_to_runtime


.. _autogentospec:

Convert AutoGen agents to Agent Spec
====================================

.. literalinclude:: ../code_examples/adapter_autogen_quickstart.py
:language: python
:start-after: .. start-runtime_to_agentspec
:end-before: .. end-runtime_to_agentspec
60 changes: 60 additions & 0 deletions docs/pyagentspec/source/adapters/crewai.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. _crewaiadapter:

============================
Agent Spec Adapters - CrewAI
============================


.. figure:: ../_static/icons/crewai-adapter.jpg
:align: center
:scale: 18%
:alt: Agent Spec adapter for CrewAI

↑ With the **Agent Spec adapter for CrewAI**, you can easily import agents from external frameworks using Agent Spec and run them with CrewAI.

*CrewAI enables the design of collaborative AI agents and workflows, incorporating guardrails, memory,
and observability for production-ready multi-agent systems.*


Get started
===========

To get started, set up your Python environment (Python 3.10 to 3.13 required),
and then install the PyAgentSpec package with the CrewAI extension.


.. code-block:: bash

python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install "pyagentspec[crewai]"


You are now ready to use the adapter:

- Run Agent Spec configurations with CrewAI (see more details :ref:`below <spectocrewai>`)
- Convert CrewAI agents to Agent Spec (see more details :ref:`below <crewaitospec>`)



.. _spectocrewai:

Run Agent Spec configurations with CrewAI
=========================================


.. literalinclude:: ../code_examples/adapter_crewai_quickstart.py
:language: python
:start-after: .. start-agentspec_to_runtime
:end-before: .. end-agentspec_to_runtime


.. _crewaitospec:

Convert CrewAI agents to Agent Spec
===================================

.. literalinclude:: ../code_examples/adapter_crewai_quickstart.py
:language: python
:start-after: .. start-runtime_to_agentspec
:end-before: .. end-runtime_to_agentspec
60 changes: 60 additions & 0 deletions docs/pyagentspec/source/adapters/langgraph.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. _langgraphadapter:

===============================
Agent Spec Adapters - LangGraph
===============================


.. figure:: ../_static/icons/langgraph-adapter.jpg
:align: center
:scale: 18%
:alt: Agent Spec adapter for LangGraph

↑ With the **Agent Spec adapter for LangGraph**, you can easily import agents from external frameworks using Agent Spec and run them with LangGraph.


*LangGraph facilitates the creation and management of long-running, stateful agents
with durable execution and human-in-the-loop capabilities.*


Get started
===========

To get started, set up your Python environment (Python 3.10 or newer required),
and then install the PyAgentSpec package with the LangGraph extension.


.. code-block:: bash

python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install "pyagentspec[langgraph]"


You are now ready to use the adapter:

- Run Agent Spec configurations with LangGraph (see more details :ref:`below <spectolanggraph>`)
- Convert LangGraph agents to Agent Spec (see more details :ref:`below <langgraphtospec>`)


.. _spectolanggraph:

Run Agent Spec configurations with LangGraph
============================================


.. literalinclude:: ../code_examples/adapter_langgraph_quickstart.py
:language: python
:start-after: .. start-agentspec_to_runtime
:end-before: .. end-agentspec_to_runtime


.. _langgraphtospec:

Convert LangGraph agents to Agent Spec
======================================

.. literalinclude:: ../code_examples/adapter_langgraph_quickstart.py
:language: python
:start-after: .. start-runtime_to_agentspec
:end-before: .. end-runtime_to_agentspec
61 changes: 61 additions & 0 deletions docs/pyagentspec/source/adapters/wayflow.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. _wayflowadapter:

=============================
Agent Spec Adapters - WayFlow
=============================


.. figure:: ../_static/icons/wayflow-adapter.jpg
:align: center
:scale: 18%
:alt: Agent Spec adapter for WayFlow

↑ With the **Agent Spec adapter for WayFlow**, you can easily import agents from external frameworks using Agent Spec and run them with WayFlow.


*WayFlow is the reference framework for Agent Spec, provides modular components for developing AI-powered assistants,
supporting both workflow-based and agent-style applications.*


Get started
===========

To get started, set up your Python environment (Python 3.10 or newer required),
and then install the PyAgentSpec package as well as WayFlowCore.


.. code-block:: bash

python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install pyagentspec wayflowcore


You are now ready to use the adapter:

- Run Agent Spec configurations with WayFlow (see more details :ref:`below <spectowayflow>`)
- Convert WayFlow agents to Agent Spec (see more details :ref:`below <wayflowtospec>`)



.. _spectowayflow:

Run Agent Spec configurations with WayFlow
==========================================


.. literalinclude:: ../code_examples/adapter_wayflow_quickstart.py
:language: python
:start-after: .. start-agentspec_to_runtime
:end-before: .. end-agentspec_to_runtime


.. _wayflowtospec:

Convert WayFlow agents to Agent Spec
====================================

.. literalinclude:: ../code_examples/adapter_wayflow_quickstart.py
:language: python
:start-after: .. start-runtime_to_agentspec
:end-before: .. end-runtime_to_agentspec
4 changes: 2 additions & 2 deletions docs/pyagentspec/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ New features

* **Sensitive Fields Support:**

New fields have been added to Agent Spec components that may carry sensitive data (e.g. the field `api_key` on :ref:`OpenAICompatibleModel <openaicompatiblemodel>`). To provide this functionality securely, we also introduced the annotation `SensitiveField` such that the sensitive fields are automatically excluded when exporting a Component to its JSON or yaml configuration.
New fields have been added to Agent Spec components that may carry sensitive data (e.g. the field `api_key` on :ref:`OpenAiCompatibleConfig <openaicompatibleconfig>`). To provide this functionality securely, we also introduced the annotation `SensitiveField` such that the sensitive fields are automatically excluded when exporting a Component to its JSON or yaml configuration.

For more information read the :ref:`latest specification <agentspecsensitivefield_nightly>`.

* **OpenAI Responses API Support:**

:ref:`OpenAICompatibleModel <openaicompatiblemodel>` and :ref:`OpenAIModel <openaiconfig>` now support the OpenAI Responses API, which can be configured
:ref:`OpenAiCompatibleConfig <openaicompatibleconfig>` and :ref:`OpenAIModel <openaiconfig>` now support the OpenAI Responses API, which can be configured
using the ``api_type`` parameter, which accepts values from :ref:`OpenAIAPIType <openaiapitype>`.

This enhancement allows recent OpenAI models to better leverage advanced reasoning capabilities, resulting in significant performance improvements in workflows.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright © 2025 Oracle and/or its affiliates.
#
# This software is under the Apache License 2.0
# (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or Universal Permissive License
# (UPL) 1.0 (LICENSE-UPL or https://oss.oracle.com/licenses/upl), at your option.

# isort:skip_file
# fmt: off
# mypy: ignore-errors

# .. start-agentspec_to_runtime
# Create a Agent Spec agent
from pyagentspec.agent import Agent
from pyagentspec.llms.openaicompatibleconfig import OpenAiCompatibleConfig
from pyagentspec.property import FloatProperty
from pyagentspec.tools import ServerTool

subtraction_tool = ServerTool(
name="subtraction-tool",
description="subtract two numbers together",
inputs=[FloatProperty(title="a"), FloatProperty(title="b")],
outputs=[FloatProperty(title="difference")],
)

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

agentspec_agent = Agent(
name="agentspec_tools_test",
description="agentspec_tools_test",
llm_config=agentspec_llm_config,
system_prompt="Perform subtraction with the given tool.",
tools=[subtraction_tool],
)

# Export the Agent Spec configuration
from pyagentspec.serialization import AgentSpecSerializer

agentspec_config = AgentSpecSerializer().to_json(agentspec_agent)

# Load and run the Agent Spec configuration with AutoGen
from pyagentspec.adapters.autogen import AgentSpecLoader

def subtract(a: float, b: float) -> float:
return a - b

async def main() -> None:
converter = AgentSpecLoader(tool_registry={"subtraction-tool": subtract})
component = converter.load_json(agentspec_config)
while True:
input_cmd = input("USER >> ")
if input_cmd == "q":
break
result = await component.run(task=input_cmd)
print(f"AGENT >> {result.messages[-1].content}")
await component._model_client.close()

# anyio.run(main)
# USER >> Compute 987654321-123456789
# AGENT >> The result of the subtraction is 864197532.
# .. end-agentspec_to_runtime
# .. start-runtime_to_agentspec
# Create an AutoGen Agent
import os
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient

async def add_tool(a: int, b: int) -> int:
"""Adds a to b and returns the result"""
return a + b

autogen_tools = {"add_tool": add_tool}

model_client = OpenAIChatCompletionClient(
model="gpt-4.1",
)

autogen_agent = AssistantAgent(
name="assistant",
model_client=model_client,
tools=list(autogen_tools.values()),
system_message="Use tools to solve tasks, and reformulate the answers that you get.",
reflect_on_tool_use=True,
)

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

agentspec_config = AgentSpecExporter().to_json(autogen_agent)
# .. end-runtime_to_agentspec
Loading