fix: brainstorm infinite loop, ghost cursor, embedding ::vector cast, semantic search, billing stats, usage meter accordion
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 5s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 5s
- Fix useBrainstormSocket: stable guestId via useRef, remove setState in cleanup - Fix GhostCursor: direct DOM manipulation via refs, no useState re-renders - Fix all SQL embedding queries: add ::vector cast on text columns - Fix embedding truncation to 15000 chars (under 8192 token limit) - Fix NoteEmbedding INSERT: remove non-existent updatedAt column - Fix billing page: show all quota stats in grid instead of single metric - Fix usage meter: accordion expand/collapse, per-feature detail - Fix semantic search: rebuild 103 note embeddings, ::vector cast on vectorSearch - Fix brainstorm expand/manual-idea/create: ::vector cast on embedding SQL
This commit is contained in:
@@ -15,16 +15,24 @@ export interface EmbeddingResult {
|
||||
|
||||
export class EmbeddingService {
|
||||
private readonly EMBEDDING_DIMENSION = 1536
|
||||
private readonly MAX_CHARS = 15000
|
||||
|
||||
private truncateForEmbedding(text: string): string {
|
||||
if (text.length <= this.MAX_CHARS) return text
|
||||
return text.slice(0, this.MAX_CHARS)
|
||||
}
|
||||
|
||||
async generateEmbedding(text: string): Promise<EmbeddingResult> {
|
||||
if (!text || text.trim().length === 0) {
|
||||
throw new Error('Cannot generate embedding for empty text')
|
||||
}
|
||||
|
||||
const truncated = this.truncateForEmbedding(text)
|
||||
|
||||
try {
|
||||
const config = await getSystemConfig()
|
||||
const embedding = await withAiProviderFallback('embedding', config, (provider) =>
|
||||
provider.getEmbeddings(text)
|
||||
provider.getEmbeddings(truncated)
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -41,7 +49,7 @@ export class EmbeddingService {
|
||||
async generateBatchEmbeddings(texts: string[]): Promise<EmbeddingResult[]> {
|
||||
if (!texts || texts.length === 0) return []
|
||||
|
||||
const validTexts = texts.filter(t => t && t.trim().length > 0)
|
||||
const validTexts = texts.filter(t => t && t.trim().length > 0).map(t => this.truncateForEmbedding(t))
|
||||
if (validTexts.length === 0) return []
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user