Skip to content

Instantly share code, notes, and snippets.

View TejasBaid's full-sized avatar
👾

Tejas Baid TejasBaid

👾
  • India
View GitHub Profile
@TejasBaid
TejasBaid / embeddingUtils.ts
Created February 11, 2026 17:46
Contextual RAG Embedding Utilities
import { GEMINI_API_KEY, GEMINI_API_URL, GEMINI_EMBEDDING_MODEL, GEMINI_SAFETY_SETTINGS } from '../api/geminiConfig';
import { generateContextualMetadata } from './metadataUtils';
const MAX_EMBEDDING_CHUNK_SIZE = 8000;
export const getEmbeddings = async (text: string, includeContextualMetadata = true): Promise<number[]> => {
try {
if (text.length > MAX_EMBEDDING_CHUNK_SIZE) {
console.log(`Text length (${text.length}) exceeds max size (${MAX_EMBEDDING_CHUNK_SIZE}), using chunking approach`);