Search
Code127
"slug": "val-vibes", "link": "/blog/val-vibes", "description": "How to build semantic search with embeddings for Val Town within Val Town itself", "pubDate": "Tue, 18 Jun 2024 00:00:00 GMT", "author": "JP Posma",
"slug": "val-vibes", "link": "/blog/val-vibes", "description": "How to build semantic search with embeddings for Val Town within Val Town itself", "pubDate": "Tue, 18 Jun 2024 00:00:00 GMT", "author": "JP Posma",
* Initialize the embedding model */async function initEmbeddings(modelId = EMBEDDING_MODELS.fast) { if (embedder && embedder.model?.config?.name_or_path === modelId) { return embedder;async function processAllFeeds() { await initDatabase(); await initEmbeddings(); let totalProcessed = 0;
"slug": "val-vibes", "link": "/blog/val-vibes", "description": "How to build semantic search with embeddings for Val Town within Val Town itself", "pubDate": "Tue, 18 Jun 2024 00:00:00 GMT", "author": "JP Posma",
const {model, modelToken} = this.options; const response = await axios.post( "https://api.openai.com/v1/embeddings", {model, input: text }, {
"link": "/blog/val-vibes", "description": "How to build semantic search with embeddings for Val Town within Val Town itself", "pubDate": "Tue, 18 Jun 2024 00:00:00 GMT", "author": "JP Posma",
```async function calculateEmbeddings(text) { const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`; return data; } catch (error) { console.error('Error calculating embeddings:', error); return null; }
// Embedding endpoints async generateEmbedding(request: EmbeddingRequest): Promise<ApiResponse<EmbeddingResponse>> { return this.request<EmbeddingResponse>('/embeddings/generate', { method: 'POST', body: JSON.stringify(request), threshold?: number; }): Promise<ApiResponse<any>> { return this.request('/embeddings/search', { method: 'POST', body: JSON.stringify(query), } async embeddingsHealthCheck(): Promise<ApiResponse<any>> { return this.request('/embeddings/health'); }
const API_CACHE_PATTERNS = [ /\/api\/health/, /\/api\/embeddings\/health/, /\/api\/chat\/health/];
import { initializeDatabase } from './services/supabase.ts';import chatRoutes from './routes/chat.ts';import embeddingRoutes from './routes/embeddings.ts';const app = new Hono();// API Routesapp.route('/api/chat', chatRoutes);app.route('/api/embeddings', embeddingRoutes);// Health check