Skip to main content

Overview

This example demonstrates how to run Arklex User Simulator with a shopping assistant agent for an e-commerce use case. You can follow this example to evaluate your own agent. This example includes two agent options:
  • Option 1: OpenAI agent that directly uses the OpenAI API to interact with the user simulator
  • Option 2: Customized in-house agent exposed through a Chat Completions-compatible interface to interact with the user simulator

Data Preparation

This example already includes a data folder in this directory (./examples/e-commerce/data). You can freely add, remove, or update knowledge files (.md, .pdf, .doc, etc.) in that folder to match your own use case.

Option 1: OpenAI Agent

1

Rename agent configuration file

Rename agent_config_openai.json to agent_config.json. If agent_config.json already exists, first rename the original file to another name to avoid overwriting it.
2

Configure runtime settings

Configure config.yaml for this example.
3

Run the simulator

Choose how you want to run the simulator:
Set the environment variablesIn a new terminal:
export OPENAI_API_KEY="<YOUR_OPENAI_API_KEY>"
Run the simulatorFrom the root folder:
./run_arksim.sh run ./examples/e-commerce/config.yaml

Option 2: In-house Agent

1

Rename agent configuration file

Rename agent_config_chat_completion.json to agent_config.json. If agent_config.json already exists, first rename the original file to another name to avoid overwriting it.
2

Start the agent

The user simulator expects agent responses in the Chat Completions format. You can either use the sample agent provided in the ./examples/e-commerce/chat_completion_server folder, or integrate your own agent.
In the ./examples/e-commerce/chat_completion_server folder, we provide a RAG-based agent implemented with LangGraph in agent_server.py.Install dependenciesCreate a virtual environment (Python 3.11 recommended) and install dependencies:
# Create and activate the environment
conda create -n ecommerce_venv python=3.11 -y
conda activate ecommerce_venv

# Install required packages for the sample agent
pip install -r ./examples/e-commerce/chat_completion_server/requirements.txt
Set environment variables
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
Start the agent serverFrom the root directory of the folder, start the chat completion wrapper. This starts the agent on port 8080:
python -m examples.e-commerce.chat_completion_server.chat_completion_wrapper
Verify the server is running
lsof -i -P -n | grep 8080
You should see output similar to:
python3.11  <process_id> <username>   10u  IPv4 0x6eaae5951a5c469b      0t0  TCP 127.0.0.1:8080 (LISTEN)
3

Configure runtime settings

Configure config.yaml for this example.
4

Run the simulator

In a new terminal:Set the environment variables
export OPENAI_API_KEY="<YOUR_OPENAI_API_KEY>"
Run the simulatorFrom the root folder:
./run_arksim.sh run ./examples/e-commerce/config.yaml