Skip to main content

Parlant

The parlant-alice package registers Alice as the moderation service in a Parlant server. Customer messages are evaluated before the agent sees them, agent replies before the customer does. Blocked customer messages arrive as "censored" so a guideline can respond politely.

Status: Generally available · Evaluates: Prompts, Responses · Vendor: Emcie

Customer messages and generated agent messages, evaluated against the policies assigned to your application.

Setup​

pip install "parlant-alice>=0.2.0"

Configuration: ALICE_API_KEY, ALICE_APP_ID, ALICE_BLOCKED_MESSAGE

ALICE_APP_ID is the ID of the application in the Application Inventory; parlant-alice refuses to start without it.

Example​

"""Parlant server with Alice moderating customer messages and agent replies.

Reads ALICE_API_KEY and ALICE_APP_ID from the environment, or pass api_key= and app_id= to Alice().
"""

import asyncio

import parlant.sdk as p
from parlant.contrib.alice import Alice


async def main() -> None:
async with p.Server(configure_container=Alice().configure_container) as server:
agent = await server.create_agent(
name="Otto Carmen",
description="You work at a computer parts store",
)
print(agent.id)

await agent.create_guideline(
condition="the customer's last message is censored",
action="respond with a polite refusal to answer the question, mention that the message was censored based on guardrails analysis",
)


asyncio.run(main())

Good to know​

Clients must create customer events with moderation="auto", otherwise prompt analysis does not run. Blocked agent replies are replaced by ALICE_BLOCKED_MESSAGE.

Every evaluation carries the Parlant session ID as the session ID and the session's customer ID as the user ID, so a customer's messages and the agent's replies to them share one session and one user. Sessions created without a customer belong to Parlant's shared guest customer and all report the same user; create a Parlant customer per end user to tell them apart.

Versions before 0.2.0 call the deprecated v1 API and do not work with WonderFence SDK 3.x. When upgrading, set ALICE_APP_ID and remove ALICE_APP_NAME.