Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/media-time-ranges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ontos-ai/knowhere-sdk': minor
---

Type audio/video time-range citations: `TimeRange` and optional `timeRanges` on retrieval sources and referenced chunks, plus transcript chunk metadata (`timeRanges`, `speakers`, `media`, `sourceKind`).
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ result.metadata;
result.source.documentId;
result.source.sourceFileName;
result.source.sectionPath;
result.source.timeRanges; // audio/video only: [{ startMs, endMs }]
```

Agentic references expose the current retrieval citation fields:
Expand All @@ -361,9 +362,13 @@ reference.sectionPath;
reference.filePath;
reference.jobId;
reference.assetUrl;
reference.timeRanges; // audio/video only: [{ startMs, endMs }]
reference.metadata;
```

Audio and video documents are speech transcripts; their citations carry
`timeRanges` in milliseconds so you can seek the recording.

Use `documentId` to update or archive a document:

```typescript
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type {
RetrievalSectionExclusion,
RetrievalQueryParams,
RetrievalSource,
TimeRange,
RetrievalEvidencePart,
RetrievalResult,
RetrievalReferencedChunk,
Expand Down
19 changes: 19 additions & 0 deletions src/lib/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ describe('utils', () => {
});

describe('keysToCamel', () => {
it('should keep audio/video time_ranges citations as timeRanges', () => {
const input = {
referenced_chunks: [
{
chunk_id: 'chunk_1',
time_ranges: [{ start_ms: 723000, end_ms: 860000 }],
},
],
};
expect(keysToCamel(input)).toEqual({
referencedChunks: [
{
chunkId: 'chunk_1',
timeRanges: [{ startMs: 723000, endMs: 860000 }],
},
],
});
});

it('should convert object keys from snake_case to camelCase', () => {
const input = {
first_name: 'John',
Expand Down
10 changes: 10 additions & 0 deletions src/types/result.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { TimeRange } from './retrieval.js';

/**
* Statistics about the parsed document
*/
Expand Down Expand Up @@ -155,6 +157,14 @@ export interface ChunkMetadata {
originalName?: string;
tableType?: string;
documentTopSummary?: string;
/** Audio/video transcript time spans */
timeRanges?: TimeRange[];
/** Speaker labels in an audio/video transcript chunk, e.g. S1 */
speakers?: string[];
/** Audio/video source facts: kind (audio or video) and durationMs */
media?: { kind?: string; durationMs?: number | null };
/** How the chunk text was produced, e.g. asr */
sourceKind?: string;
/** Allow forward-compatible access to unknown fields. */
[key: string]: unknown;
}
Expand Down
12 changes: 12 additions & 0 deletions src/types/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export interface RetrievalQueryParams {
llmConfig?: LlmConfig;
}

/**
* Audio/video time span in milliseconds from the start of the recording.
*/
export interface TimeRange {
startMs: number;
endMs: number;
}

/**
* Caller-facing source reference attached to a retrieval result.
*/
Expand All @@ -86,6 +94,8 @@ export interface RetrievalSource {
pageNums?: number[];
/** Original ingestion revision, shared by its baseline and final snapshots. */
jobResultId?: string | null;
/** Audio/video transcript time spans */
timeRanges?: TimeRange[] | null;
}

/**
Expand Down Expand Up @@ -154,6 +164,8 @@ export interface RetrievalReferencedChunk {
pageNums?: number[];
/** Presigned asset URL for media chunks when available */
assetUrl?: string | null;
/** Audio/video transcript time spans */
timeRanges?: TimeRange[] | null;
/** Chunk metadata returned by the API */
metadata?: Record<string, unknown>;
}
Expand Down
Loading