# UiPath LlamaIndex Python SDK

[![PyPI - Version](https://img.shields.io/pypi/v/uipath-llamaindex)](https://pypi.org/project/uipath-llamaindex/)
[![PyPI downloads](https://img.shields.io/pypi/dm/uipath-llamaindex.svg)](https://pypi.org/project/uipath-llamaindex/)
[![Python versions](https://img.shields.io/pypi/pyversions/uipath-llamaindex.svg)](https://pypi.org/project/uipath-llamaindex/)

A Python SDK that enables developers to build and deploy LlamaIndex agents to the UiPath Cloud Platform. It provides programmatic interaction with UiPath Cloud Platform services and human-in-the-loop (HITL) semantics through Action Center integration.

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-llamaindex-python/tree/main/samples) to see the SDK in action.

## Requirements

-   Python 3.11 or higher
-   UiPath Automation Cloud account

## Installation

```bash
pip install uipath-llamaindex
```

using `uv`:

```bash
uv add uipath-llamaindex
```

## 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 LlamaIndex Agents:

### Initialize a Project

```bash
uipath init
```

Running `uipath init` will process the workflow definitions in the `llama_index.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).

### Authentication

```bash
uipath auth
```

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

### Debug a Project

```bash
uipath run WORKFLOW [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:

-   A `pyproject.toml` file with project metadata
-   A `llama_index.json` file with your workflow definitions (e.g., `"workflows": {"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

## Development

### Developer Tools

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.

### Setting Up a Development Environment

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

### Special Thanks

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

- [LlamaIndex](https://github.com/run-llama/llama_index) for providing a powerful framework for building stateful LLM applications.
- [OpenInference](https://github.com/Arize-ai/openinference) for observability and instrumentation support.
- [Pydantic](https://github.com/pydantic/pydantic) for reliable, typed configuration and validation.
