Search

115 code results for embeddings

Code
115

Generates OpenAI embeddings for all public vals, and stores them in [Neon](https://neon.tech/),
- Create the `vals_embeddings` table in Neon if it doesn't already exist.
- Get all val names from the [database of public vals](https://www.val.town/v/sqlite/db), made b
- Get all val names from the `vals_embeddings` table and compute the difference (which ones are
Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the res
- Can now be searched using [janpaul123/semanticSearchNeon](https://www.val.town/v/janpaul123/se
const openai = new OpenAI();
const queryEmbedding = (await openai.embeddings.create({
model: "text-embedding-3-small",
const embedding = await openai.embeddings.create({
model: "text-embedding-3-small",
const queryEmbeddingVal = (await openai.embeddings.create({
model: "text-embedding-3-small",
Migrated from folder: semanticSearchPrototype/debugValEmbeddings
export default async function semanticSearchPublicVals(query) {
const allValsBlobEmbeddingsMeta = (await blob.getJSON("allValsBlobEmbeddingsMeta")) ?? {};
allBatchDataIndexes = _.uniq(Object.values(allValsBlobEmbeddingsMeta).map(item => item.batchDat
const embeddingsBatches = [];
const allBatchDataIndexesPromises = [];
for (const batchDataIndex of allBatchDataIndexes) {
const embeddingsBatchBlobName = `allValsBlobEmbeddingsData_${batchDataIndex}`;
const promise = blob.get(embeddingsBatchBlobName).then((response) => response.arrayBuffer())
promise.then((data) => {
embeddingsBatches[batchDataIndex as any] = data;
console.log(`Loaded ${embeddingsBatchBlobName} (${data.byteLength} bytes)`);
});
for (const id in allValsBlobEmbeddingsMeta) {
const meta = allValsBlobEmbeddingsMeta[id];
const embedding =
(new Float32Array(embeddingsBatches[meta.batchDataIndex], 256 * 4 * meta.valIndex, 256 * 4
db.add({ id, embedding, metadata: {} });
const openai = new OpenAI();
const embedding = await openai.embeddings.create({
model: "text-embedding-3-small",
Generates OpenAI embeddings for all public vals, and stores them in Val Town's [blob storage](h
- Get all val names from the [database of public vals](https://www.val.town/v/sqlite/db), made b
mes in batches. Vals in the same batch will have their embeddings stored in the same blob, at di
through all each batch, get code for all the vals, get embeddings from OpenAI, and store the res
- When finished, save the metadata JSON to its own blob.
const sqlite = createClient({
url: "libsql://valsembeddings-jpvaltown.turso.io",
authToken: Deno.env.get("TURSO_AUTH_TOKEN_VALSEMBEDDINGS"),
});
sqlite.execute("CREATE TABLE IF NOT EXISTS vals_embeddings (id TEXT NOT NULL, embedding BLOB N
e.execute("CREATE VIRTUAL TABLE IF NOT EXISTS vss_vals_embeddings USING vss0(embedding(256))");
const existingEmbeddingsIds = new Set(
(await sqlite.execute("SELECT id FROM vals_embeddings")).rows.map((row) => row[0]),
);
const id = idForVal(val);
if (!existingEmbeddingsIds.has(id)) {
newVals.push(val);
const embedding = await openai.embeddings.create({
model: "text-embedding-3-small",
sqlite.execute({
sql: "INSERT INTO vals_embeddings (id, embedding) VALUES (:id, :embeddingBinary)",
args: { id, embeddingBinary },
sqlite.execute(
"INSERT INTO vss_vals_embeddings (rowid, embedding) SELECT rowid, embedding FROM vals_embedd
);
Generates OpenAI embeddings for all public vals, and stores them in [Turso](https://turso.tech/)
- Create the `vals_embeddings` and `vss_vals_embeddings` tables in Turso if they don't already e
- Get all val names from the [database of public vals](https://www.val.town/v/sqlite/db), made b
- Get all val names from the `vals_embeddings` table and compute the difference (which ones are
Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the res
- When finished, update the `vss_vals_embeddings` table so we can efficiently query them with th
- This is blocked by a [bug in Turso](https://discord.com/channels/933071162680958986/12453785
const { ChatOpenAI } = await import("npm:langchain/chat_models");
const { OpenAIEmbeddings } = await import("npm:langchain/embeddings");
const { createClient } = await import(
const vectorStore = await SupabaseVectorStore.fromExistingIndex(
new OpenAIEmbeddings({
openAIApiKey: process.env.OPEN_API_KEY,
export let generateEmbeddings = async (
req: express.Request,
}
const { OpenAIEmbeddings } = await import("npm:langchain/embeddings");
const { createClient } = await import(
splittedDocs,
new OpenAIEmbeddings({
openAIApiKey: process.env.OPEN_API_KEY,
Migrated from folder: linkedin_seeder/generateEmbeddings
8
Next