feat: implement comprehensive type safety system with BrainyTypes API
Major enhancements for type safety and developer experience: - Add BrainyTypes static API for type management and AI-powered suggestions - Implement strict type validation for all 31 NounType categories - Remove dangerous generic add() method that bypassed type safety - Add intelligent type inference with confidence scoring - Provide helpful error messages with typo suggestions using Levenshtein distance - Update all internal code, examples, and documentation to use typed methods - Enhance CLI with new type management commands (types, suggest, validate) Breaking changes: - Remove deprecated add() method - use addNoun() with explicit type parameter - All addNoun() calls now require explicit type as second parameter This release significantly improves type safety across the entire system while maintaining backward compatibility for properly typed method calls. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d7d2d749b6
commit
6c62bc4e9d
40 changed files with 1704 additions and 497 deletions
|
|
@ -159,7 +159,7 @@ const brain = new BrainyData({
|
|||
|
||||
2. **Verify embedding generation**
|
||||
```typescript
|
||||
const id = await brain.add("test content")
|
||||
const id = await brain.addNoun("test content", 'content')
|
||||
const item = await brain.get(id)
|
||||
console.log('Item:', item) // Should have metadata and vector
|
||||
```
|
||||
|
|
@ -193,7 +193,7 @@ const brain = new BrainyData({
|
|||
3. **Check data quality**
|
||||
```typescript
|
||||
// Ensure consistent, descriptive content
|
||||
await brain.add("Domestic cat - small carnivorous mammal", {
|
||||
await brain.addNoun("Domestic cat - small carnivorous mammal", 'content', {
|
||||
category: "animals",
|
||||
subcategory: "pets"
|
||||
})
|
||||
|
|
@ -250,7 +250,7 @@ const brain = new BrainyData({
|
|||
// Process in batches instead of loading all at once
|
||||
for (let i = 0; i < data.length; i += 100) {
|
||||
const batch = data.slice(i, i + 100)
|
||||
await Promise.all(batch.map(item => brain.add(item)))
|
||||
await Promise.all(batch.map(item => brain.addNoun(item, 'content')))
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ try {
|
|||
const brain = new BrainyData()
|
||||
await brain.init()
|
||||
|
||||
const id = await brain.add("health check")
|
||||
const id = await brain.addNoun("health check", 'content')
|
||||
const results = await brain.search("health")
|
||||
|
||||
console.log('✅ Brainy is working correctly')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue