-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_contact_link.js
More file actions
60 lines (52 loc) · 1.95 KB
/
add_contact_link.js
File metadata and controls
60 lines (52 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// add_contact_link.js - Just add the contact link to Supabase
import { CohereClient } from "cohere-ai";
import { createClient } from "@supabase/supabase-js";
import dotenv from "dotenv";
dotenv.config();
const supabase = createClient(
process.env.SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_KEY
);
const cohere = new CohereClient({ token: process.env.COHERE_API_KEY });
async function createEmbedding(text) {
try {
const resp = await cohere.embed({
model: "embed-english-v3.0",
texts: [text],
inputType: "search_document"
});
return resp.embeddings[0];
} catch (err) {
console.error("❌ Embedding failed:", err);
throw err;
}
}
async function addContactLink() {
console.log("🔗 Adding Dr. Rameshwar Kumar contact link to Supabase...");
const contactContent = "Dr. Rameshwar Kumar Contact Page: https://drrameshwarkumar.in/contact/ - Official contact form and detailed contact information for Dr. Rameshwar Kumar. Phone: +917992271883, Email: care@drrameshwarkumar.in";
// Create embedding for the contact link
const embedding = await createEmbedding(contactContent);
// Insert into Supabase
const { error } = await supabase.from("kb_vectors").insert([{
content: contactContent,
metadata: {
source: "drRameshwar_kb.json",
title: "Dr. Rameshwar Kumar Contact Page",
url: "https://drrameshwarkumar.in/contact/",
keywords: ["contact", "rameshwar", "phone", "email", "contact page"],
intent: "contact_information",
summary: "Dr. Rameshwar Kumar official contact page link",
path: ["drRameshwar_kb", "contact", "contact_page"],
itemIndex: 0,
chunkIndex: 0
},
source: "Dr. Rameshwar Kumar Contact Page",
embedding
}]);
if (error) {
console.error("❌ Supabase insert error:", error);
} else {
console.log("✅ Successfully added contact link to Supabase!");
}
}
addContactLink().catch(console.error);