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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All packages are extensions to the [UiPath Python SDK](https://github.com/UiPath

Build agents using the [LlamaIndex SDK](https://www.llamaindex.ai/):

- [README](packages/uipath-llamaindex/README.md)
- [Docs](https://uipath.github.io/uipath-python/llamaindex/quick_start/)
- [Samples](packages/uipath-llamaindex/samples/)

Expand All @@ -23,6 +24,7 @@ Build agents using the [LlamaIndex SDK](https://www.llamaindex.ai/):

Build agents using the [OpenAI Agents SDK](https://github.com/openai/openai-agents-python):

- [README](packages/uipath-openai-agents/README.md)
- [Docs](https://uipath.github.io/uipath-python/openai-agents/quick_start/)
- [Samples](packages/uipath-openai-agents/samples/)

Expand Down
123 changes: 108 additions & 15 deletions packages/uipath-openai-agents/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,125 @@
# UiPath OpenAI Agents SDK
# UiPath OpenAI Agents Python SDK

Build intelligent AI agents with OpenAI's Agents framework and UiPath.
[![PyPI - Version](https://img.shields.io/pypi/v/uipath-openai-agents)](https://pypi.org/project/uipath-openai-agents/)
[![PyPI downloads](https://img.shields.io/pypi/dm/uipath-openai-agents.svg)](https://pypi.org/project/uipath-openai-agents/)
[![Python versions](https://img.shields.io/pypi/pyversions/uipath-openai-agents.svg)](https://pypi.org/project/uipath-openai-agents/)

A Python SDK that enables developers to build and deploy OpenAI Agents to the UiPath Cloud Platform. It provides programmatic interaction with UiPath Cloud Platform services.

This package is an extension to the [UiPath Python SDK](https://github.com/UiPath/uipath-python) and implements the [UiPath Runtime Protocol](https://github.com/UiPath/uipath-runtime-python).

Check out these [sample projects](https://github.com/UiPath/uipath-integrations-python/tree/main/packages/uipath-openai-agents/samples) to see the SDK in action.

## Requirements

- Python 3.11 or higher
- UiPath Automation Cloud account

## Installation

```bash
pip install uipath-openai-agents
```

## Quick Start
using `uv`:

```bash
uv add uipath-openai-agents
```

## Configuration

### Environment Variables

Create a `.env` file in your project root with the following variables:

```
UIPATH_URL=https://cloud.uipath.com/ACCOUNT_NAME/TENANT_NAME
UIPATH_ACCESS_TOKEN=YOUR_TOKEN_HERE
```

## Command Line Interface (CLI)

The SDK provides a command-line interface for creating, packaging, and deploying OpenAI Agents:

### Authentication

```bash
uipath auth
```

This command opens a browser for authentication and creates/updates your `.env` file with the proper credentials.

### Initialize a Project

```bash
uipath init
```

Running `uipath init` will process the agent definitions in the `openai_agents.json` file and create the corresponding `entry-points.json` file needed for deployment.

For more details on the configuration format, see the [UiPath configuration specifications](https://github.com/UiPath/uipath-python/blob/main/specs/README.md).

### Debug a Project

```bash
uipath run AGENT [INPUT]
```

Executes the agent with the provided JSON input arguments.

### Package a Project

```bash
uipath pack
```

Packages your project into a `.nupkg` file that can be deployed to UiPath.

**Note:** Your `pyproject.toml` must include:

- A description field (avoid characters: &, <, >, ", ', ;)
- Author information

Example:

```toml
description = "Your package description"
authors = [{name = "Your Name", email = "your.email@example.com"}]
```

### Publish a Package

```bash
uipath publish
```

Publishes the most recently created package to your UiPath Orchestrator.

## Project Structure

To properly use the CLI for packaging and publishing, your project should include:

See the [main repository documentation](../../docs/) for getting started guides and examples.
- A `pyproject.toml` file with project metadata
- A `openai_agents.json` file with your agent definitions (e.g., `"agents": {"agent": "main.py:agent"}`)
- A `entry-points.json` file (generated by `uipath init`)
- A `bindings.json` file (generated by `uipath init`) to configure resource overrides
- Any Python files needed for your automation

## Features
## Development

- **OpenAI Agents Integration**: Build agents using OpenAI's native Agents framework
- **Agent Orchestration**: Multi-agent coordination and communication
- **State Management**: Persistent agent state with SQLite sessions
- **UiPath Integration**: Seamless integration with UiPath runtime and tooling
### Developer Tools

## Status
Check out [uipath-dev](https://github.com/uipath/uipath-dev-python) - an interactive terminal application for building, testing, and debugging UiPath Python runtimes, agents, and automation scripts.

⚠️ **Early Development**: This package is in early development (v0.1.0). APIs may change as the OpenAI Agents framework evolves.
### Setting Up a Development Environment

## Documentation
Please read our [contribution guidelines](https://github.com/UiPath/uipath-integrations-python/packages/uipath-openai-agents/blob/main/CONTRIBUTING.md) before submitting a pull request.

Full documentation is available in the [main repository](https://github.com/UiPath/uipath-llamaindex-python).
### Special Thanks

## License
A huge thank-you to the open-source community and the maintainers of the libraries that make this project possible:

See [LICENSE](../../LICENSE) in the repository root.
- [OpenAI](https://github.com/openai/openai-python) for providing a powerful framework for building AI agents.
- [OpenInference](https://github.com/Arize-ai/openinference) for observability and instrumentation support.
- [Pydantic](https://github.com/pydantic/pydantic) for reliable, typed configuration and validation.
14 changes: 7 additions & 7 deletions packages/uipath-openai-agents/docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Generate your first UiPath OpenAI agent:
✓ Created 'pyproject.toml' file.
🔧 Please ensure to define OPENAI_API_KEY in your .env file.
💡 Initialize project: uipath init
💡 Run agent: uipath run agent '{"message": "Hello"}'
💡 Run agent: uipath run agent '{"messages": "Hello"}'
```

This command creates the following files:
Expand Down Expand Up @@ -173,7 +173,7 @@ Execute the agent with a sample input:
<!-- termynal -->

```shell
> uipath run agent '{"message": "Hello"}'
> uipath run agent '{"messages": "Hello"}'
{'response': 'Hello! How can I help you today?', 'agent_used': 'main'}
✓ Successful execution.
```
Expand All @@ -185,19 +185,19 @@ Depending on the shell you are using, it may be necessary to escape the input js

/// tab | Bash/ZSH/PowerShell
```console
uipath run agent '{"message": "Hello"}'
uipath run agent '{"messages": "Hello"}'
```
///

/// tab | Windows CMD
```console
uipath run agent "{""message"": ""Hello""}"
uipath run agent "{""messages"": ""Hello""}"
```
///

/// tab | Windows PowerShell
```console
uipath run agent '{\"message\":\"Hello\"}'
uipath run agent '{\"messages\":\"Hello\"}'
```
///

Expand All @@ -215,7 +215,7 @@ The `run` command can also take a .json file as an input. You can create a file

```json
{
"message": "Hello"
"messages": "Hello"
}
```

Expand Down Expand Up @@ -275,7 +275,7 @@ Set the environment variables using the provided link.
<!-- termynal -->

```shell
> uipath invoke agent '{"message": "Hello"}'
> uipath invoke agent '{"messages": "Hello"}'
â ´ Loading configuration ...
â ´ Starting job ...
✨ Job started successfully!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"message": "Tell me a joke"
"messages": "Tell me a joke"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"input": {
"type": "object",
"properties": {
"message": {
"messages": {
"anyOf": [
{
"type": "string"
Expand All @@ -21,12 +21,12 @@
}
}
],
"title": "Message",
"description": "User message(s) to send to the agent"
"title": "Messages",
"description": "User messages to send to the agent"
}
},
"required": [
"message"
"messages"
]
},
"output": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"message": "Who is the best ai llm?"
"messages": "Who is the best ai llm?"
}
10 changes: 5 additions & 5 deletions packages/uipath-openai-agents/samples/triage-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ In this pattern:

```bash
# Spanish message
uipath run main '{"message": "Hola, ¿cómo estás?"}'
uipath run main '{"messages": "Hola, ¿cómo estás?"}'

# French message
uipath run main '{"message": "Bonjour, comment allez-vous?"}'
uipath run main '{"messages": "Bonjour, comment allez-vous?"}'

# English message
uipath run main '{"message": "Hello, how are you?"}'
uipath run main '{"messages": "Hello, how are you?"}'
```

### Configure in openai_agents.json
Expand All @@ -53,7 +53,7 @@ uipath run main '{"message": "Hello, how are you?"}'
### Input
```python
class Input(BaseModel):
message: str # User message in any language
messages: str # User message in any language
```

### Output
Expand All @@ -66,7 +66,7 @@ class Output(BaseModel):
## Example Execution

```bash
$ uipath run main '{"message": "Hola, ¿cómo estás?"}'
$ uipath run main '{"messages": "Hola, ¿cómo estás?"}'

Processing message: Hola, ¿cómo estás?
¡Hola! Estoy muy bien, gracias. ¿Y tú, cómo estás?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"input": {
"type": "object",
"properties": {
"message": {
"messages": {
"anyOf": [
{
"type": "string"
Expand All @@ -21,12 +21,12 @@
}
}
],
"title": "Message",
"description": "User message(s) to send to the agent"
"title": "Messages",
"description": "User messages to send to the agent"
}
},
"required": [
"message"
"messages"
]
},
"output": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"message": "une blague."
"messages": "une blague."
}
27 changes: 24 additions & 3 deletions packages/uipath-openai-agents/src/uipath_openai_agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
"""UiPath OpenAI Agents SDK."""
"""
UiPath OpenAI Agents SDK.

NOTE: This module uses lazy imports via __getattr__ to avoid loading heavy
dependencies (openai SDK) at import time. This significantly improves CLI
startup performance.

Do NOT add eager imports like:
from .chat import UiPathChatOpenAI # BAD - loads openai SDK immediately

Instead, all exports are loaded on-demand when first accessed.
"""


def __getattr__(name):
if name == "UiPathChatOpenAI":
from .chat import UiPathChatOpenAI

return UiPathChatOpenAI
if name == "register_middleware":
from .middlewares import register_middleware

return register_middleware
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

from .chat import UiPathChatOpenAI
from .middlewares import register_middleware

__version__ = "0.1.0"
__all__ = ["register_middleware", "UiPathChatOpenAI"]
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ This documentation is split into multiple files for efficient context loading. L

3. **@.agent/CLI_REFERENCE.md** - CLI commands documentation
- **When to load:** Working with `uipath init`, `uipath run agent`, or deployment commands
- **Contains:** Command syntax for OpenAI agents, options, input formats (`{"message": "..."}` or `{"messages": [...]}`), debug mode, usage examples
- **Contains:** Command syntax for OpenAI agents, options, input formats (`{"messages": "..."}` or `{"messages": [...]}`), debug mode, usage examples
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from agents import Agent
from openai import OpenAI
from agents import Agent, function_tool
from agents.models import _openai_shared

from uipath_openai_agents.chat import UiPathChatOpenAI
from uipath_openai_agents.chat.supported_models import OpenAIModels


@function_tool
def get_weather(location: str) -> str:
"""Get the current weather for a location.

Expand All @@ -12,17 +16,19 @@ def get_weather(location: str) -> str:
Weather information for the location
"""
# This is a mock implementation
return f"The weather in {location} is sunny and 72°F"
return f"The weather in {location} is sunny and 32 degrees Celsius."


MODEL = OpenAIModels.gpt_5_2_2025_12_11

# Initialize the OpenAI client
client = OpenAI()
# Initialize the UiPath OpenAI client
uipath_openai_client = UiPathChatOpenAI(model_name=MODEL)
_openai_shared.set_default_openai_client(uipath_openai_client.async_client)

# Create an agent with tools
agent = Agent(
name="weather_agent",
instructions="You are a helpful weather assistant. Use the get_weather tool to provide weather information.",
model="gpt-4o-mini",
model=MODEL,
tools=[get_weather],
client=client,
)
Loading
Loading