Skip to content
Open
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
16 changes: 8 additions & 8 deletions src/oss/python/integrations/providers/all_providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2049,14 +2049,6 @@ Browse the complete collection of integrations available for Python. LangChain P
Operating LLMs in production environment.
</Card>

<Card
title="Open Agent Spec (PyAgentSpec)"
href="https://oracle.github.io/agent-spec/adapters/langgraph.html"
icon="link"
>
Framework-agnostic declarative language by Oracle for defining agentic systems. Define agents and workflows in a portable JSON/YAML format that can be executed across different runtimes.
</Card>

<Card
title="OpenSearch"
href="/oss/integrations/providers/opensearch"
Expand All @@ -2073,6 +2065,14 @@ Browse the complete collection of integrations available for Python. LangChain P
Weather data and forecasting API.
</Card>

<Card
title="Open Agent Spec"
href="/oss/integrations/providers/open_agent_spec"
icon="link"
>
Framework-agnostic language for portable agent definitions.
</Card>

<Card
title="Oracle AI"
href="/oss/integrations/providers/oracleai"
Expand Down
84 changes: 84 additions & 0 deletions src/oss/python/integrations/providers/open_agent_spec.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: Open Agent Spec
---

This page covers all LangChain integrations with [Open Agent Specification](https://oracle.github.io/agent-spec).

Open Agent Spec is a framework-agnostic declarative language from Oracle for defining agentic systems. It allows to define agents and workflows in a portable JSON/YAML format that can be executed across different runtimes.

## Installation and setup

You can refer to the [installation guide](https://oracle.github.io/agent-spec/installation.html) to install `pyagentspec`.

You can subsequently install the LangGraph Adapter through its extra dependency:
```bash
pip install "pyagentspec[langgraph]"
```

## LangGraph Adapter
The **LangGraph Adapter** allows for instantiation and execution of Open Agent Spec configurations using LangGraph.
The `AgentSpecLoader` class is responsible for loading Agent Spec configurations (in JSON or YAML format) and instantiating them as runnable agents within the LangGraph environment. It also includes support for mapping of declared tools to corresponding Python functions.

The following example shows the creation of a simple Agent Spec Agent and its conversion into a LangGraph assistant.
Starting from the Agent Spec Agent creation:

```python
# 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],
)
```

The Agent can be subsequently exported to JSON:
```python
# Export the Agent Spec configuration
from pyagentspec.serialization import AgentSpecSerializer

agentspec_config = AgentSpecSerializer().to_json(agentspec_agent)
```

And converted into a LangGraph assistant using `AgentSpecLoader`.
The example also showcases the mapping of the tool and the execution of a conversation.

```python
# Load and run the Agent Spec configuration with LangGraph
from pyagentspec.adapters.langgraph import AgentSpecLoader

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

async def main():
loader = AgentSpecLoader(tool_registry={"subtraction-tool": subtract})
assistant = loader.load_json(agentspec_config)

while True:
user_input = input("USER >> ")
if user_input == "exit":
break
result = await assistant.ainvoke(
input={"messages": [{"role": "user", "content": user_input}]},
)
print(f"AGENT >> {result['messages'][-1].content}")
```