Skip to main content

LLM Python SDK Installation

The AI Agent Observability Python SDK is installed via pip install whatap-python[llm] and applied by adding whatap-start-agent before your application's run command. This document guides you through the entire installation process, from activating a virtual environment to verifying the service.

Pre-installation checklist​

Before installing the agent, verify the following:

Activate virtual environment​

If your application uses virtualenv, run the bin/activate file to activate the virtual environment.

Download agent​

After issuing an access key, go to the Download agent section. Run the following command to install the agent.

pip install whatap-python[llm]
Tip

If you cannot install via the pip command, download the installation file from the pypi WhaTap page. Extract the downloaded file and proceed with installation.

tar xzvf whatap_python-2.x.x.tar.gz
cd whatap_python-2.X.Y.Z
python setup.py install
Note

The whatap-python[llm] package requires the external libraries datasketches>=5.2.0 and genai-prices. Missing dependencies may cause some data collection to be skipped. Include these dependencies even when installing manually.

SDK configuration files​

The Python SDK files consist of a tracer that extracts information required for application monitoring and sends it to the WhaTap collection server, along with supporting elements. See the following for the agent file structure.

Configure agent​

Set WHATAP_HOME path​

Specify the $WHATAP_HOME path for log and configuration file paths. Creating a new whatap directory is recommended.

$ export WHATAP_HOME=[PATH]

Set access key and collection server IP​

Run the whatap-llm-setting-config command to set the access key and collection server IP.

$ whatap-llm-setting-config \
--host [ COLLECTION_SERVER_IP ] \
--license [ ACCESS_KEY ] \
--app_name [ USER_DEFINED_AGENT_NAME ] \
--app_process_name [ APPLICATION_PROCESS_NAME(uwsgi, gunicorn etc..) ]

Verify configuration​

The whatap.conf file is created and configured at the path specified in $WHATAP_HOME. Run the following command to verify the whatap.conf file was created.

$ cat $WHATAP_HOME/whatap.conf
whatap.conf
llm_license=[ACCESS_KEY]
llm.whatap.server.host=[COLLECTION_SERVER_IP]

llm_enabled=true

# application name
app_name=[ USER_DEFINED_AGENT_NAME ]

# middleware process name ex)uwsgi, gunicorn ..
app_process_name=[ APPLICATION_PROCESS_NAME(uwsgi, gunicorn etc..) ]

Install the LLM-only module​

To use Python AI Agent Observability, you must additionally install the Go module that WhaTap developed for LLM.

cd $WHATAP_HOME

curl -fsSL -O https://repo.whatap.io/python/llm/whatap-python-llm.tar.gz

tar -xzf whatap-python-llm.tar.gz

The whatap-python-llm directory created by extracting the archive must be located under the $WHATAP_HOME path you set earlier.

Note

If permission issues occur

  • Read and write permissions for the $WHATAP_HOME/whatap.conf file for WhaTap configuration

  • Read and write permissions for the $WHATAP_HOME/logs path and its sub-files for WhaTap logs

If permission issues occur for the $WHATAP_HOME path, run the following command to grant permissions.

echo `sudo chmod -R 777 $WHATAP_HOME`

Configuring the SDK on Windows​

The Python SDK can also be installed on Windows 10 and Windows Server 2016 or later. On Windows, use the following PowerShell commands to configure everything from the WHATAP_HOME path to the LLM module installation.

  1. Set the path for logs and configuration files in the WHATAP_HOME environment variable.

    $env:WHATAP_HOME=[PATH]
  2. Run the whatap-llm-setting-config command to create the whatap.conf file in the $env:WHATAP_HOME path. In PowerShell, a backtick (`) at the end of a line continues the command on the next line.

    whatap-llm-setting-config `
    --host [ COLLECTION_SERVER_IP ] `
    --license [ ACCESS_KEY ] `
    --app_name [ USER_DEFINED_AGENT_NAME ] `
    --app_process_name [ APPLICATION_PROCESS_NAME(uwsgi, gunicorn etc..) ]
  3. Install the LLM module. Windows Server 2016 does not include curl.exe and tar by default, so download and extract the file with Python. Windows PowerShell 5.1 does not support the && operator, so run the commands one line at a time.

    cd $env:WHATAP_HOME
    python -c "import urllib.request; urllib.request.urlretrieve('https://repo.whatap.io/python/llm/whatap-python-llm.tar.gz', 'whatap-python-llm.tar.gz')"
    python -c "import tarfile; t = tarfile.open('whatap-python-llm.tar.gz'); t.extractall('.', [m for m in t.getmembers() if m.name.startswith('windows/')])"

    The windows folder created by extraction must be under the $env:WHATAP_HOME path.

  4. If there are no read and write permissions for the $env:WHATAP_HOME\whatap.conf file and the $env:WHATAP_HOME\logs path, grant permissions with the following command.

    icacls $env:WHATAP_HOME /grant Everyone:F /T

Apply per server environment​

Select the method that matches your server environment.

In a Command environment, add the whatap-start-agent command before the application start command as follows.

BASH
# $ whatap-start-agent [Application start command]
$ whatap-start-agent python manage.py runserver

Once you start the application server, the agent begins collecting monitoring data.

Verify service execution​

Run the following command to verify the WhaTap Python service is running properly.

ps -ef | grep whatap_python