Search
Code127
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",