Search
Code168
- **Supabase** with PGVector for vector search- **OpenAI/Mistral** for AI responses- **Hugging Face** for embeddings### Database Schema```sql-- Medical content chunks with embeddingsCREATE TABLE medical_content ( id SERIAL PRIMARY KEY,- Supabase project with PGVector extension- OpenAI or Mistral API key- Hugging Face API key (optional for server-side embeddings)### Environment Variables│ ├── routes/│ │ ├── chat.ts # Chat API endpoints│ │ ├── embeddings.ts # Embedding generation│ │ └── static.ts # Static file serving│ └── index.ts # Main API entry point try { // Get embedding const embResponse = await fetch("https://api.openai.com/v1/embeddings", { method: "POST", headers: { async getEmbedding(text: string, apiKey: string) { const response = await fetch("https://api.openai.com/v1/embeddings", { method: "POST", headers: { }, body: JSON.stringify({ model: "text-embedding-3-small", // IMPORTANT: Match your Pinecone embeddings input: text, }), try { // Get embedding const embResponse = await fetch("https://api.openai.com/v1/embeddings", { method: "POST", headers: {import { Pinecone } from "https://esm.sh/@pinecone-database/pinecone@2.0.0";// Use OpenAI client only for embeddingsconst openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY"), // Get embedding for query const embeddingResponse = await openai.embeddings.create({ model: "text-embedding-3-small", input: query, "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", // Get embedding for query const embeddingResponse = await openai.embeddings.create({ model: "text-embedding-3-small", input: query, "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",Users
No users found
No docs found