FEAT-nonblocking-backend-io-imporvements #1
@@ -7,7 +7,7 @@ import { batch } from '../lib/streams.js';
|
|||||||
const SELECT_NOTES = 'SELECT id, text, x, y, author, color FROM notes ORDER BY id';
|
const SELECT_NOTES = 'SELECT id, text, x, y, author, color FROM notes ORDER BY id';
|
||||||
|
|
||||||
// Postgres caps a statement at 65535 bind parameters; six columns per note
|
// Postgres caps a statement at 65535 bind parameters; six columns per note
|
||||||
// leaves 10922 as the hard ceiling, so stay well under it.
|
// leaves 10922 as the hard ceiling.
|
||||||
const INSERT_BATCH_SIZE = 1000;
|
const INSERT_BATCH_SIZE = 1000;
|
||||||
|
|
||||||
export const getAllNotes = async () => {
|
export const getAllNotes = async () => {
|
||||||
@@ -16,9 +16,8 @@ export const getAllNotes = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Streams every note as an object-mode Readable. The pooled client is checked
|
* Streams every note as an object-mode Readable. The pooled client is released on end, error, or
|
||||||
* out for the life of the stream and released once it ends, errors, or is
|
* destruction by consumer.
|
||||||
* destroyed early by a consumer.
|
|
||||||
*
|
*
|
||||||
* @returns {Promise<import('node:stream').Readable>}
|
* @returns {Promise<import('node:stream').Readable>}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ const client = new VoyageAIClient({
|
|||||||
apiKey: process.env.VOYAGEAI_API_KEY,
|
apiKey: process.env.VOYAGEAI_API_KEY,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Well under Voyage's per-request input and token ceilings.
|
|
||||||
const EMBED_BATCH_SIZE = 128;
|
const EMBED_BATCH_SIZE = 128;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Structural validation: confirms the LLM output is well-formed
|
* Structural validation for LLM output
|
||||||
* before it reaches the frontend.
|
|
||||||
*
|
*
|
||||||
* @param {Array<{label: string, noteIds: string[]}>} clusters
|
* @param {Array<{label: string, noteIds: string[]}>} clusters
|
||||||
* @param {string[]} inputNoteIds - the original note IDs that were sent to the LLM
|
* @param {string[]} inputNoteIds - the original note IDs that were sent to the LLM
|
||||||
@@ -62,7 +61,7 @@ const cosineSimilarity = (a, b) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes a silhouette-style cohesion score for the clustering.
|
* Computes silhouette-style cohesion score for the clustering.
|
||||||
*
|
*
|
||||||
* For each note, measures how much more similar it is to its own cluster
|
* For each note, measures how much more similar it is to its own cluster
|
||||||
* versus the nearest neighboring cluster. Returns a score in [-1, 1]
|
* versus the nearest neighboring cluster. Returns a score in [-1, 1]
|
||||||
|
|||||||
Reference in New Issue
Block a user