NorthStar SDK makes it easy to add AI capabilities to your applications. In this tutorial, we'll build a semantic search feature for a documentation site.
Installation
npm install @strug-city/northstar
# or
pip install northstar-sdkCore Concepts
NorthStar provides three main abstractions:
Embeddings - Convert text to vectors
VectorStore - Store and search vectors
Agents - Orchestrate AI workflows
Building Semantic Search
search.ts
import { NorthStar, VectorStore } from '@strug-city/northstar';
const ns = new NorthStar({
apiKey: process.env.NORTHSTAR_API_KEY,
});
// Create embeddings from documents
const docs = await ns.embeddings.create({
input: documentTexts,
model: 'text-embedding-3',
});
// Store in vector database
const store = new VectorStore('docs');
await store.add(docs);
// Search semantically
const results = await store.search({
query: 'How do I deploy my app?',
limit: 5,
});
console.log(results);Adding Hybrid Search
Combine semantic and keyword search for better results:
const results = await store.search({
query: 'deployment configuration',
limit: 5,
hybrid: {
semantic: 0.7, // 70% semantic
keyword: 0.3, // 30% keyword
},
});That's it! You've built a semantic search feature in less than 30 lines of code. Check out our full documentation for advanced features like multi-language support, custom embeddings, and agent orchestration.