This guide demonstrates how to use JamAI Base TypeScript SDK to upload and embed files into Knowledge Tables for AI-powered document processing and retrieval.
What are Knowledge Tables?
Knowledge Tables are specialized tables in JamAI Base that provide hybrid-search capabilities through both full-text search (FTS) and vector embeddings:
Search Capabilities:
Full-Text Search (FTS): Traditional keyword-based search for exact and partial matches
Semantic Search: Vector embedding-based search for meaning and context
Document Processing:
Automatically chunks documents into manageable segments
Generates vector embeddings for semantic understanding
Indexes content for full-text search
Preserves document structure (tables, layouts, etc) and metadata
Use Cases:
Document retrieval using both keywords and semantic meaning
Question-answering agent
Content recommendation
Knowledge base search and discovery
Supported File Types
The following file formats are supported:
Text files: .txt, .md, .csv, .tsv
Documents: .doc, .docx, .pdf
Presentations: .ppt, .pptx
Spreadsheets: .xls, .xlsx
Markup/Data: .xml, .html, .json, .jsonl
Prerequisites
Before starting, you'll need:
Node.js 16.x or higher
Project ID and Personal Access Token (PAT)
Documents to process
2. Installation and Setup
Installing Required Packages
Basic Configuration
3. Creating Your Knowledge Table
1
Create a new table
Navigate to your JamAI Base knowledge tables tab and create a new knowledge table.
2
Note table ID
After creating the table, note down the table ID for later use.
4. Implementation
4.1 Complete Document Uploader Class
5. Complete Standalone Script
Save this as knowledge_uploader.ts:
6. Usage Examples
6.1 Single File Upload
6.2 Batch Folder Upload
6.3 Custom Chunk Settings
7. Best Practices
7.1 Chunking Strategy
Recommended Settings by Document Type:
Document Type
Chunk Size
Overlap
Reasoning
PDFs
1500
300
Preserves paragraph context
Text Files
1000
200
Balanced for general text
Spreadsheets
800
150
Smaller for structured data
JSON/JSONL
800
150
Maintains object boundaries
7.2 Error Handling
7.3 Batch Processing with Rate Limiting
8. Running the Script
Using Environment Variables
Create .env file:
Run the script:
Using Command Line (modify script to accept args)
9. Troubleshooting
Common Issues
File not found error
Verify file path is correct
Use absolute paths for reliability
Unsupported file format
Check file extension against supported types
Verify file is not corrupted
Upload timeout
Check internet connection
For large files, consider increasing timeout settings