LlamaIndex Workflows adapter for Azure AI Agent Server
Project description
LlamaIndex Agent Server Adapter
An adapter for hosting LlamaIndex Workflows as Azure AI Agent Server endpoints.
Installation
pip install llamaindex-agentserver-adapter
With OpenAI support:
pip install llamaindex-agentserver-adapter[openai]
With Azure OpenAI support:
pip install llamaindex-agentserver-adapter[azure-openai]
Quick Start
from workflows import Workflow, step
from workflows.events import StartEvent, StopEvent
from llamaindex_agentserver import from_workflow
class MyWorkflow(Workflow):
@step
async def process(self, ev: StartEvent) -> StopEvent:
user_input = ev.input
return StopEvent(result=f"Processed: {user_input}")
# Create and run the adapter
workflow = MyWorkflow(timeout=60)
adapter = from_workflow(workflow)
adapter.run(port=8088)
Features
- HTTP Endpoints: Exposes your workflow via
/runsand/responsesendpoints - Streaming Support: Full support for streaming responses using Server-Sent Events
- Human-in-the-Loop: Support for
InputRequiredEventandHumanResponseEventpatterns - Tracing: Integration with Azure Application Insights and OpenTelemetry
- Health Checks: Built-in
/livenessand/readinessendpoints
API Reference
from_workflow(workflow, state_converter=None, timeout=None)
Creates an adapter for a LlamaIndex Workflow.
Parameters:
workflow: The LlamaIndex Workflow instance to adaptstate_converter: Optional custom state converter for non-standard input/output formatstimeout: Optional timeout override for workflow execution
Returns: A LlamaIndexWorkflowAdapter instance
Request Format
The adapter accepts requests in the OpenAI Responses API format:
{
"input": "Hello, world!",
"instructions": "You are a helpful assistant.",
"stream": false,
"metadata": {}
}
Or with structured messages:
{
"input": [
{"type": "message", "role": "user", "content": "Hello!"},
{"type": "message", "role": "assistant", "content": "Hi there!"},
{"type": "message", "role": "user", "content": "How are you?"}
],
"stream": true
}
Testing Your Server
# Non-streaming request
curl -X POST http://localhost:8088/runs \
-H "Content-Type: application/json" \
-d '{"input": "Hello, how are you?"}'
# Streaming request
curl -X POST http://localhost:8088/runs \
-H "Content-Type: application/json" \
-d '{"input": "Tell me a story", "stream": true}'
# Health check
curl http://localhost:8088/liveness
Custom State Converter
For workflows with custom input/output requirements, implement a custom state converter:
from llamaindex_agentserver.models import LlamaIndexWorkflowStateConverter
class MyStateConverter(LlamaIndexWorkflowStateConverter):
def supports_streaming(self, context):
return True
def request_to_workflow_input(self, context):
# Convert request to your workflow's expected input format
return {"custom_input": context.request.get("input")}
def result_to_response(self, result, context):
# Convert workflow result to Response object
...
async def stream_to_response_stream(self, event_stream, context):
# Convert streaming events to response stream events
...
adapter = from_workflow(workflow, state_converter=MyStateConverter())
Environment Variables
| Variable | Description |
|---|---|
DEFAULT_AD_PORT |
Default server port (default: 8088) |
_AGENT_RUNTIME_APP_INSIGHTS_CONNECTION_STRING |
Application Insights connection string |
OTEL_EXPORTER_ENDPOINT |
OpenTelemetry exporter endpoint |
AGENT_DEBUG_ERRORS |
Set to "true" to include full error details |
AGENT_LOG_LEVEL |
Logging level (default: INFO) |
Examples
See the examples/ directory:
simple_workflow.py- Basic chat workflow with LLMhitl_workflow.py- Human-in-the-loop approval workflow
Requirements
- Python 3.10+
azure-ai-agentserver-core(Azure AI Agent Server core library)llama-index-coreandllama-index-workflows
Development
# Clone the repository
git clone https://github.com/yourusername/llamaindex-agentserver-adapter.git
cd llamaindex-agentserver-adapter
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
ruff format .
# Lint
ruff check .
License
MIT License - See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llamaindex_agentserver_adapter-0.1.0.tar.gz.
File metadata
- Download URL: llamaindex_agentserver_adapter-0.1.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90fcebf854b153a89c2da8ff187e1749400bc7daff641c6dc95f5f64beffdaab
|
|
| MD5 |
44c5f9f7c17ce8e4273e5bc9beb0be88
|
|
| BLAKE2b-256 |
1f02f8dd8088283ab6ebd23e8f77b88a65c2095032b763fb16dd6d33917f9219
|
File details
Details for the file llamaindex_agentserver_adapter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llamaindex_agentserver_adapter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed0842a60230c7fd5c8a1e2fdbc763cf3e83ea18127dde16a8a542d612648a4a
|
|
| MD5 |
6892508fbc44f68c5d2133ac2f7898c2
|
|
| BLAKE2b-256 |
c774e71053ea869ec5c72e489ddcee96d950b37e5c180419c5ae786a2bdfdc87
|