A fast and lightweight TypeScript/JavaScript sdk for generating text embeddings based on FastAPI and other python tools.
The Semantic Embed SDK is a TypeScript library designed to interface with the Semantic Embed API for generating text embeddings. With this SDK, developers can easily create and manage embeddings for their applications and work with semantic models powered by FastAPI. Whether you're building a recommendation system, semantic search, or performing content similarity analysis, Semantic Embed is your go-to tool for text embeddings.
- TypeScript Ready: Fully written in TypeScript for type safety and developer-friendly experience.
- FastAPI Integration: Seamless integration with the Semantic Embed API built on FastAPI for optimal performance.
- Easy-to-use API: Simple and clean API design to get started with embedding generation effortlessly.
- Environment Config: Supports
.envconfiguration for API keys and other environment variables. - Support for Custom Models: Flexibility to work with different embedding models and configurations such as all-MiniLM-L6-v2 (384 dimensions), all-MiniLM-L12-v2 (384 dimensions), all-mpnet-base-v2 (768 dimensions) and finally e5-large-v2 (1024 dimensions).
Follow these steps to integrate the Semantic Embed SDK into your project:
You can install the SDK via PNPM:
pnpm install semantic-embedusing Npm:
npm add semantic-embedOr using Yarn:
yarn add semantic-embedMake sure you have an API key to access the Semantic Embed API, get one at semantic-embed.uanelacomo.com. You can set it up in a .env file at the root of your project:
SEMANTIC_EMBED_API_KEY=your-api-key-here
After installation, you can easily use the SDK to generate embeddings for your content.
import SemanticEmbed from "semantic-embed";
const semanticEmbed = new SemanticEmbed("your-api-key-if-not-in-env");
// Example text to generate embeddings
const text = "Semantic embedding is the future of search!";
async function generateEmbedding() {
try {
const embedding = await semanticEmbed.generateEmbedding(text);
console.log("Generated Embedding: ", embedding);
} catch (error) {
console.error("Error generating embedding: ", error);
}
}
generateEmbedding();Generates a semantic embedding for the provided text.
Arguments:
text(string): The text content for which you want to generate an embedding.
Returns:
Promise: A promise that resolves to the generated embedding data.
To contribute or build the SDK from source:
git clone https://github.com/uanela/semantic-embed-sdk.git
cd semantic-embedpnpm installpnpm run buildpnpm run devThis project is licensed under the MIT License - see the LICENSE file for details.
For any issues or questions, please open an issue or contact Uanela Como.