An AI-powered token classification tool for the DUAL platform. Automatically classifies tokens using OpenAI's GPT-4o-mini model, extracting category, tags, sentiment, and summary information.
The DUAL AI Token Classifier is a production-ready Node.js application that streamlines the classification and tagging of tokens on the DUAL platform. It leverages OpenAI's language models to intelligently categorize tokens and extract relevant metadata.
- Automatic Classification: Use AI to classify tokens into predefined categories
- Batch Processing: Process multiple tokens efficiently in configurable batches
- Dry-Run Mode: Preview classifications without making changes to DUAL API
- Error Handling: Robust error handling with detailed logging
- Rate Limiting: Built-in delays to prevent API rate limiting
- Template Filtering: Optionally classify tokens from specific templates only
- Progress Tracking: Real-time statistics on classification progress
┌─────────────────┐
│ DUAL API │
│ (Fetch Objects)│
└────────┬────────┘
│
▼
┌─────────────────┐
│ Token Objects │
│ (Untagged) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Classifier │
│ (LLM Engine) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Classification │
│ Results │
└────────┬────────┘
│
▼
┌─────────────────┐
│ DUAL API │
│ (Tag Objects) │
└─────────────────┘
- Node.js 18.0.0 or higher
- DUAL API token
- OpenAI API key
- Clone the repository:
git clone https://github.com/dual-network/dual-ai-classifier.git
cd dual-ai-classifier- Install dependencies:
npm install- Configure environment variables:
cp .env.example .env
# Edit .env with your API tokens- Run the classifier:
npm run classifyAll configuration is managed through environment variables. Create a .env file based on .env.example:
| Variable | Default | Description |
|---|---|---|
DUAL_TOKEN |
(required) | DUAL API authentication token |
OPENAI_API_KEY |
(required) | OpenAI API key for GPT access |
DUAL_API_BASE |
https://blockv-labs.io |
DUAL API base URL |
OPENAI_MODEL |
gpt-4o-mini |
OpenAI model to use |
BATCH_SIZE |
10 |
Number of objects per classification batch |
DRY_RUN |
false |
Enable dry-run mode (preview only) |
TEMPLATE_ID |
(optional) | Filter by specific template ID |
LIMIT |
0 |
Max objects to process (0 = no limit) |
LOG_LEVEL |
info |
Logging level (info, warn, error) |
Run the classifier on all untagged objects:
npm run classifyPreview classifications without writing to DUAL API:
npm run dry-runOr with command-line flag:
npm run classify -- --dry-runOnly classify tokens from a particular template:
npm run classify -- --template-id my-template-idProcess a limited number of objects:
npm run classify -- --limit 50npm run classify -- --template-id loyalty-tokens --limit 25 --dry-runThe classifier uses OpenAI's GPT-4o-mini model to analyze token properties and generate classifications. Here's the process:
Tokens are classified into one of six categories:
- loyalty: Loyalty programs, reward points, membership tokens
- collectible: NFTs, digital collectibles, unique items
- access-pass: Access tickets, passes, event entries
- certificate: Certificates, credentials, achievements
- coupon: Discount codes, promotional offers, redemption vouchers
- identity: Identity documents, profiles, KYC tokens
For each token, the classifier produces:
- category: The primary classification (one of the six above)
- tags: Relevant tags extracted from the token properties
- sentiment: Positive, neutral, or negative sentiment
- summary: A brief one-line description of the token
Input Token:
{
"id": "token-123",
"name": "VIP Access Pass",
"description": "Exclusive event entry",
"properties": {
"event": "tech-conference-2026",
"validity": "2026-04-01"
}
}
Classification Result:
{
"category": "access-pass",
"tags": ["event", "exclusive", "conference"],
"sentiment": "positive",
"summary": "Exclusive VIP access ticket for tech conference"
}
DUAL API client for authentication and communication.
Methods:
fetchObjects(params)- Fetch objects from DUAL APIsearchObjects(query, limit, offset)- Search objectspatchObject(id, updates)- Update a single objectbatchPatchObjects(patches)- Update multiple objects
AI-powered classification engine using OpenAI.
Methods:
classify(tokenObject)- Classify a single tokenclassifyBatch(tokenObjects)- Classify multiple tokensgetValidCategories()- Get list of valid categories
Main orchestration pipeline.
Methods:
fetchUntaggedObjects()- Retrieve untagged objects from APIclassifyBatch(objects)- Run classification on a batchtagObjects(classifications)- Write results back to DUAL APIrun()- Execute complete pipeline
To add new categories, modify the VALID_CATEGORIES array in src/classifier.js:
const VALID_CATEGORIES = [
'loyalty',
'collectible',
'access-pass',
'certificate',
'coupon',
'identity',
'your-new-category', // Add here
];Then update the system prompt in buildSystemPrompt() to include documentation for the new category.
To use a different LLM provider:
- Replace the OpenAI client initialization in
Classifier.constructor() - Update the message format in the
classify()andclassifyBatch()methods - Ensure output is valid JSON matching the expected format
Example template for Anthropic Claude:
// Replace OpenAI import
import Anthropic from '@anthropic-ai/sdk';
// Initialize different client
this.client = new Anthropic({ apiKey });
// Adapt message format for new providerMake sure your .env file includes a valid DUAL token:
echo "DUAL_TOKEN=your-token-here" >> .envEnsure your OpenAI API key is configured:
echo "OPENAI_API_KEY=sk-..." >> .envIf you encounter rate limit errors:
- Reduce
BATCH_SIZEin your configuration - Use the
--limitflag to process fewer objects per run - The pipeline automatically adds 500ms delays between batches
- Verify your DUAL_TOKEN is valid and has API access
- Check that OPENAI_API_KEY is a valid OpenAI API key
- Ensure neither token has expired
- Check that you have untagged objects in your DUAL instance
- Verify the
--template-idfilter matches actual templates - Try running with
--dry-runto see what would be processed
- DUAL Platform Documentation
- DUAL AI Token Classifier Tutorial
- OpenAI API Documentation
- Node.js Documentation
MIT License - Copyright (c) 2026 DUAL Network. See LICENSE file for details.
For issues, questions, or contributions, please refer to the DUAL documentation or contact the DUAL Network team.