diff --git a/hindsight-clients/typescript/src/index.ts b/hindsight-clients/typescript/src/index.ts index 37624a4a..dcf52f56 100644 --- a/hindsight-clients/typescript/src/index.ts +++ b/hindsight-clients/typescript/src/index.ts @@ -286,7 +286,7 @@ export class HindsightClient { trace: options?.trace, query_timestamp: options?.queryTimestamp, include: { - entities: options?.includeEntities ? { max_tokens: options?.maxEntityTokens ?? 500 } : undefined, + entities: options?.includeEntities === false ? null : options?.includeEntities ? { max_tokens: options?.maxEntityTokens ?? 500 } : undefined, chunks: options?.includeChunks ? { max_tokens: options?.maxChunkTokens ?? 8192 } : undefined, source_facts: options?.includeSourceFacts ? { max_tokens: options?.maxSourceFactsTokens ?? 4096 } : undefined, }, diff --git a/hindsight-clients/typescript/tests/main_operations.test.ts b/hindsight-clients/typescript/tests/main_operations.test.ts index d88ea51b..61d93a7b 100644 --- a/hindsight-clients/typescript/tests/main_operations.test.ts +++ b/hindsight-clients/typescript/tests/main_operations.test.ts @@ -413,6 +413,48 @@ describe('TestDeleteBank', () => { }); }); +describe('TestRecallIncludeOptions', () => { + let bankId: string; + + beforeAll(async () => { + bankId = randomBankId(); + await client.retainBatch(bankId, [ + { content: 'Alice works at Google as a software engineer' }, + { content: 'Bob is a researcher at OpenAI' }, + ]); + }); + + test('entities included by default', async () => { + const response = await client.recall(bankId, 'Where does Alice work?'); + + expect(response).not.toBeNull(); + expect(response.results!.length).toBeGreaterThan(0); + // entities should be present when includeEntities is not specified (default: true) + expect(response.entities).toBeDefined(); + }); + + test('entities excluded when includeEntities is false', async () => { + const response = await client.recall(bankId, 'Where does Alice work?', { + includeEntities: false, + }); + + expect(response).not.toBeNull(); + expect(response.results!.length).toBeGreaterThan(0); + // entities should be absent when explicitly disabled + expect(response.entities).toBeFalsy(); + }); + + test('entities included when includeEntities is true', async () => { + const response = await client.recall(bankId, 'Where does Alice work?', { + includeEntities: true, + }); + + expect(response).not.toBeNull(); + expect(response.results!.length).toBeGreaterThan(0); + expect(response.entities).toBeDefined(); + }); +}); + describe('TestMission', () => { test('set mission', async () => { const bankId = randomBankId();