Skip to content

Commit 803744d

Browse files
yaron2msfussellCasperGN
authored
Add OpenAI integration docs (#4969)
* Add OpenAI integration docs Signed-off-by: yaron2 <schneider.yaron@live.com> * add openai link Signed-off-by: yaron2 <schneider.yaron@live.com> * Update daprdocs/content/en/developing-applications/openai-agents/_index.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-applications/openai-agents/openai-agents-sessions.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-applications/openai-agents/openai-agents-sessions.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-applications/openai-agents/openai-agents-sessions.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-applications/openai-agents/openai-agents-sessions.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-applications/openai-agents/openai-agents-sessions.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * address feedback, move to new AI structure Signed-off-by: yaron2 <schneider.yaron@live.com> * fix links Signed-off-by: yaron2 <schneider.yaron@live.com> * remove old content Signed-off-by: yaron2 <schneider.yaron@live.com> * Update daprdocs/content/en/developing-ai/agent-integrations/_index.md Co-authored-by: Casper Nielsen <casper@diagrid.io> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-ai/agent-integrations/openai-agents/_index.md Co-authored-by: Casper Nielsen <casper@diagrid.io> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-ai/agent-integrations/_index.md Signed-off-by: Mark Fussell <markfussell@gmail.com> * Update daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-why.md Signed-off-by: Mark Fussell <markfussell@gmail.com> * Update daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-why.md Signed-off-by: Mark Fussell <markfussell@gmail.com> * Update daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-introduction.md Signed-off-by: Mark Fussell <markfussell@gmail.com> * Update daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-introduction.md Signed-off-by: Mark Fussell <markfussell@gmail.com> * Update daprdocs/content/en/developing-ai/agent-integrations/_index.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * Update daprdocs/content/en/developing-ai/_index.md Co-authored-by: Casper Nielsen <whopsec@protonmail.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> * change links Signed-off-by: yaron2 <schneider.yaron@live.com> * fix ref Signed-off-by: yaron2 <schneider.yaron@live.com> --------- Signed-off-by: yaron2 <schneider.yaron@live.com> Signed-off-by: Yaron Schneider <schneider.yaron@live.com> Signed-off-by: Mark Fussell <markfussell@gmail.com> Co-authored-by: Mark Fussell <markfussell@gmail.com> Co-authored-by: Casper Nielsen <casper@diagrid.io> Co-authored-by: Casper Nielsen <whopsec@protonmail.com>
1 parent 78c5e4c commit 803744d

File tree

16 files changed

+179
-11
lines changed

16 files changed

+179
-11
lines changed

daprdocs/content/en/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Dapr provides APIs for communication, state, workflow, and agentic AI. The APIs
2828
<img src="/images/homepage/dapr-agents.svg" alt="Dapr Agents" width=40>
2929
<b>Agentic AI</b></h5>
3030
<p class="card-text">Create durable agentic AI applications with Dapr Agents.</p>
31-
<a href="{{% ref "../developing-applications/dapr-agents" %}}" class="stretched-link"></a>
31+
<a href="{{% ref "../developing-ai/dapr-agents" %}}" class="stretched-link"></a>
3232
</div>
3333
</div>
3434
</div>

daprdocs/content/en/concepts/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Dapr can be used from any developer framework. Here are some that have been inte
146146
![Dapr Agents Overview](/images/dapr-agents/concepts-agents-overview.png)
147147

148148

149-
[Dapr Agents]({{% ref "../developing-applications/dapr-agents" %}}) is a Python framework for building intelligent, durable agents powered by LLMs. It provides agent-centric capabilities such as tool calling, memory management, [MCP support](https://modelcontextprotocol.io/) and agent orchestration, while leveraging Dapr for durability, observability, and security, at scale.
149+
[Dapr Agents]({{% ref "../developing-ai/dapr-agents" %}}) is a Python framework for building intelligent, durable agents powered by LLMs. It provides agent-centric capabilities such as tool calling, memory management, [MCP support](https://modelcontextprotocol.io/) and agent orchestration, while leveraging Dapr for durability, observability, and security, at scale.
150150

151151

152152
#### Integrations and extensions

daprdocs/content/en/concepts/terminology.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This page details all of the common terms you may come across in the Dapr docs.
1616
| Configuration | A YAML file declaring all of the settings for Dapr sidecars or the Dapr control plane. This is where you can configure control plane mTLS settings, or the tracing and middleware settings for an application instance. | [Dapr configuration]({{% ref configuration-concept %}})
1717
| Dapr | Distributed Application Runtime. | [Dapr overview]({{% ref overview %}})
1818
| Dapr Actors | A Dapr building block that implements the virtual actor pattern for building stateful, single-threaded objects with identity, lifecycle, and concurrency management. | [Actors overview]({{% ref actors-overview %}})
19-
| Dapr Agents | A developer framework built on top of Dapr Python SDK for creating durable agentic applications powered by LLMs. | [Dapr Agents]({{% ref "../developing-applications/dapr-agents" %}})
19+
| Dapr Agents | A developer framework built on top of Dapr Python SDK for creating durable agentic applications powered by LLMs. | [Dapr Agents]({{% ref "../developing-ai/dapr-agents" %}})
2020
| Dapr control plane | A collection of services that are part of a Dapr installation on a hosting platform such as a Kubernetes cluster. This allows Dapr-enabled applications to run on the platform and handles Dapr capabilities such as actor placement, Dapr sidecar injection, or certificate issuance/rollover. | [Self-hosted overview]({{% ref self-hosted-overview %}})<br />[Kubernetes overview]({{% ref kubernetes-overview %}})
2121
| Dapr Workflows | A Dapr building block for authoring code-first workflows with durable execution that survive crashes, support long-running processes, and enable human-in-the-loop interactions. | [Workflow overview]({{% ref workflow-overview %}})
2222
| HTTPEndpoint | HTTPEndpoint is a Dapr resource use to identify non-Dapr endpoints to invoke via the service invocation API. | [Service invocation API]({{% ref service_invocation_api %}})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
type: docs
3+
title: "Developing AI with Dapr"
4+
linkTitle: "Developing AI"
5+
description: "Information on how to build reliable and secure agentic AI systems with Dapr"
6+
weight: 31
7+
---
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
type: docs
3+
title: "Agent Integrations"
4+
linkTitle: "Agent Integrations"
5+
weight: 25
6+
description: "Information on how to integrate agentic frameworks with Dapr runtime"
7+
---
8+
9+
### What are agent integrations in Dapr?
10+
11+
Dapr augments and enhances other agentic frameworks by providing them with key critical features for running in production:
12+
13+
* Durable execution using [Dapr Workflows]({{% ref workflow-overview %}}) for resilient and long-running AI tasks
14+
* Portable agent context & memory using Dapr's [State Management API]({{% ref "state-management-overview" %}})
15+
* Reliable and secure agent-to-agent communication using [Dapr Pub/Sub]({{% ref "pubsub-overview" %}}) and [Service Invocation
16+
]({{% ref service-invocation-overview %}})
17+
* Secure agent [identity]({{< ref "concepts/security-concept" >}}#application-identity)
18+
19+
{{< button text="Install Dapr" page="getting-started.md" >}}
20+
21+
With Dapr, developers writing AI systems using the framework of their choice enjoy accelerated development via the Dapr APIs and gain confidence taking agentic systems into production.
22+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
type: docs
3+
title: "OpenAI Agents"
4+
linkTitle: "OpenAI Agents"
5+
weight: 25
6+
description: "Dapr first-class integrations for OpenAI Agents"
7+
---
8+
9+
### What is the Dapr OpenAI Agents integration?
10+
11+
Dapr provides OpenAI agents first class integrations that range from agent session management to connecting agents via pub/sub and orchestrating agentic workflows. The Dapr OpenAI integration is an extension in the OpenAI Python SDK that developers can use to augment OpenAI agents with the various Dapr APIs.
12+
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
type: docs
3+
title: "Agent Sessions"
4+
linkTitle: "Agent Sessions"
5+
weight: 20
6+
description: "How to use Dapr to reliably and securely manage agent state"
7+
---
8+
9+
## Overview
10+
11+
By using Dapr to manage the state and [session data for OpenAI agents](https://openai.github.io/openai-agents-python/sessions/), users can store agent state in all databases supported by Dapr, including key/value stores, caches and SQL databases. Developers also get built-in tracing, metrics and resiliency policies that make agent session data operate reliably in production.
12+
13+
## Getting Started
14+
15+
Initialize Dapr locally to set up a self-hosted environment for development. This process fetches and installs the Dapr sidecar binaries, runs essential services as Docker containers, and prepares a default components folder for your application. For detailed steps, see the official [guide on initializing Dapr locally]({{% ref install-dapr-cli.md %}}).
16+
17+
To initialize the Dapr control plane containers and create a default configuration file, run:
18+
19+
```bash
20+
dapr init
21+
```
22+
23+
Verify you have container instances with `daprio/dapr`, `openzipkin/zipkin`, and `redis` images running:
24+
25+
```bash
26+
docker ps
27+
```
28+
29+
### Install Python
30+
31+
{{% alert title="Note" color="info" %}}
32+
Make sure you have Python already installed. `Python >=3.10`. For installation instructions, visit the official [Python installation guide](https://www.python.org/downloads/).
33+
{{% /alert %}}
34+
35+
### Install Dependencies
36+
37+
```bash
38+
pip install openai-agents dapr
39+
```
40+
41+
### Create an OpenAI Agent
42+
43+
Let's create a simple OpenAI agent. Put the following in a file named `openai_agent.py`:
44+
45+
```python
46+
import asyncio
47+
from agents import Agent, Runner
48+
from agents.extensions.memory.dapr_session import DaprSession
49+
50+
async def main():
51+
agent = Agent(
52+
name="Assistant",
53+
instructions="Reply very concisely.",
54+
)
55+
56+
session = DaprSession.from_address(
57+
session_id="123",
58+
state_store_name="statestore"
59+
)
60+
61+
result = await Runner.run(agent, "What city is the Golden Gate Bridge in?", session=session)
62+
print(result.final_output)
63+
64+
result = await Runner.run(agent, "What state is it in?", session=session)
65+
print(result.final_output)
66+
67+
result = await Runner.run(agent, "What's the population?", session=session)
68+
print(result.final_output)
69+
70+
asyncio.run(main())
71+
```
72+
73+
### Set an OpenAI API key
74+
75+
```bash
76+
export OPENAI_API_KEY=sk-...
77+
```
78+
79+
### Create a Python venv
80+
81+
```bash
82+
python -m venv .venv
83+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
84+
```
85+
86+
### Create the database component
87+
88+
The component file is how Dapr connects to your databae. The full list of supported databases can be found [here]({{% ref supported-state-stores %}}). Create a `components` directory and this file in it:
89+
90+
`statestore.yaml`:
91+
92+
```yaml
93+
apiVersion: dapr.io/v1alpha1
94+
kind: Component
95+
metadata:
96+
name: statestore
97+
spec:
98+
type: state.redis
99+
version: v1
100+
metadata:
101+
- name: redisHost
102+
value: localhost:6379
103+
- name: redisPassword
104+
value: ""
105+
```
106+
107+
### Run The Agent
108+
109+
Now run the local Dapr process and your Python script using the Dapr CLI.
110+
111+
```bash
112+
dapr run --app-id openaisessions --dapr-grpc-port 50001 --resources-path ./components -- python3 ./openai_agent.py
113+
```
114+
115+
Open `http://localhost:9411` to view your the traces and dependency graph.
116+
117+
You can see [the session data stored in Redis]({{% ref "getting-started/get-started-api" %}}#step-4-see-how-the-state-is-stored-in-redis) with the following command
118+
119+
```bash
120+
hgetall "123:messages"
121+
```
122+
123+
## Next Steps
124+
125+
Now that you have an OpenAI agent using Dapr to manage the agent sessions, explore more you can do with the [State API]({{% ref "state-management-overview" %}}) and how to enable [resiliency policies]({{% ref resiliency-overview %}}) for enhanced reliability.
126+
127+
Read more about OpenAI agent sessions and Dapr [here](https://openai.github.io/openai-agents-python/sessions/).

daprdocs/content/en/developing-applications/dapr-agents/_index.md renamed to daprdocs/content/en/developing-ai/dapr-agents/_index.md

File renamed without changes.

daprdocs/content/en/developing-applications/dapr-agents/dapr-agents-core-concepts.md renamed to daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-core-concepts.md

File renamed without changes.

daprdocs/content/en/developing-applications/dapr-agents/dapr-agents-getting-started.md renamed to daprdocs/content/en/developing-ai/dapr-agents/dapr-agents-getting-started.md

File renamed without changes.

0 commit comments

Comments
 (0)