WIP - semantinc linking working with other fields

This commit is contained in:
Francisco Gaona
2026-04-12 10:48:37 +02:00
parent 385a842ab8
commit 3f9be316ce
2 changed files with 6 additions and 11 deletions

View File

@@ -53,14 +53,10 @@ export class DefaultSemanticProjectionAdapter implements SemanticProjectionAdapt
input.record?.subject || input.record?.subject ||
`${input.objectApiName} ${input.record?.id || ''}`.trim(); `${input.objectApiName} ${input.record?.id || ''}`.trim();
/*
const fieldNarrative = fieldEntries const fieldNarrative = fieldEntries
.map(([key, value]) => `${key}: ${String(value)}`) .map(([key, value]) => `${key}: ${String(value)}`)
.join('\n'); .join('\n');
*/
const fieldNarrative = fieldEntries
.map(([key, value]) => `${String(value)}`)
.join('\n');
const commentNarrative = (input.comments || []) const commentNarrative = (input.comments || [])
.map((comment, index) => `Comment ${index + 1}: ${comment.content}`) .map((comment, index) => `Comment ${index + 1}: ${comment.content}`)
@@ -68,9 +64,10 @@ export class DefaultSemanticProjectionAdapter implements SemanticProjectionAdapt
const narrative = [fieldNarrative, commentNarrative].filter(Boolean).join('\n\n'); const narrative = [fieldNarrative, commentNarrative].filter(Boolean).join('\n\n');
// Temporary: use only the name field for embedding to test pure semantic matching. // Plain values only — no 'key:' prefixes. Comments are handled separately by the chunker.
// Widen this back to all field values once semantic results are validated. const embeddingNarrative = fieldEntries
const embeddingNarrative = String(input.record?.name || title); .map(([, value]) => String(value))
.join('\n');
return { return {
entityType: input.objectApiName, entityType: input.objectApiName,

View File

@@ -72,9 +72,7 @@ export class SemanticOrchestratorService {
}); });
const documentId = await this.upsertSemanticDocument(knex, projection); const documentId = await this.upsertSemanticDocument(knex, projection);
// Temporary: pass empty comments so only embeddingNarrative (name field) is indexed. const chunks = this.chunkerService.chunkText(projection.embeddingNarrative, comments);
// Re-enable by replacing [] with `comments` once semantic matching is validated.
const chunks = this.chunkerService.chunkText(projection.embeddingNarrative, []);
this.logger.log( this.logger.log(
`Semantic refresh chunking: ${objectApiName}:${recordId} chunks=${chunks.length}`, `Semantic refresh chunking: ${objectApiName}:${recordId} chunks=${chunks.length}`,
); );