Cold Start
Import Contracts
Bulk import contracts and documents into a knowledge base.
Usage
npx tsx scripts/import-contracts.ts
What It Does
- Scans a directory for contract files (PDF, DOCX, TXT).
- Creates a knowledge base if none exists.
- Uploads each file with metadata.
- Enqueues ingestion jobs.
Workflow
import-contracts.ts → [ingestion pipeline processes files] → knowledge base ready
Monitor document status:
GET /api/v1/knowledge/documents?status=processing
Analyze Chats
Analyze chat exports to discover intent patterns for seeding the intent classifier.
Usage
npx tsx scripts/analyze-chats.ts
What It Does
- Parses WhatsApp or Telegram chat exports.
- Clusters similar messages by content.
- Finds recurring question patterns.
- Builds an intent taxonomy.
- Writes JSON that
seed-intents.tsconsumes.
Workflow
First step in the cold-start pipeline:
analyze-chats.ts → [produces intent JSON] → seed-intents.ts → intent examples ready
Output
Intent records with:
intentName— discovered intent identifierphrases— example phrases for each intentcount— frequency in the chat history
Seed Intents
Bulk seed intent examples with embeddings from analysis output.
Usage
npx tsx scripts/seed-intents.ts --input ./analysis.json --namespace legal
Arguments
| Flag | Required | Description |
|---|---|---|
--input | yes | Path to JSON file with intent records |
--namespace | yes | Target namespace name |
Input Format
[
{
"intentName": "leave_policy",
"phrases": ["How many vacation days do I have?", "What is the leave policy?"]
}
]
What It Does
- Reads the JSON file with intent records.
- Deduplicates by
(intentName, phrase)— skips existing examples. - Generates embeddings for each phrase (batch size 32).
- Upserts
IntentExamplerows with embedding vectors. - Shows a progress bar while running.
Workflow
Second step in the cold-start pipeline:
analyze-chats.ts → [produces intent JSON] → seed-intents.ts → intent classification ready
After seeding, the intent classifier uses these examples for vector-based classification of incoming messages.