Skip to content

Commit

Permalink
knowpro: Timestamp Scope (#643)
Browse files Browse the repository at this point in the history
Experiments:
* Timestamp index
* Scope queries using date ranges
  • Loading branch information
umeshma authored Jan 31, 2025
1 parent 79814e7 commit c9f7502
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 339 deletions.
35 changes: 29 additions & 6 deletions ts/examples/chat/src/memory/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,37 @@ export function argChunkSize(defaultValue?: number | undefined): ArgDef {
};
}

export function argToDate(value: string | undefined): Date | undefined {
return value ? dateTime.stringToDate(value) : undefined;
export function recordFromArgs(
args: NamedArgs,
metadata?: CommandMetadata,
): Record<string, string> {
const record: Record<string, string> = {};
const keys = Object.keys(args);
for (const key of keys) {
const value = args[key];
if (typeof value !== "function") {
record[key] = value;
}
}
if (metadata !== undefined) {
if (metadata.args) {
removeKeysFromRecord(record, Object.keys(metadata.args));
}
if (metadata.options) {
removeKeysFromRecord(record, Object.keys(metadata.options));
}
}
return record;
}

function removeKeysFromRecord(record: Record<string, string>, keys: string[]) {
for (const key of keys) {
delete record[key];
}
}

export function addMinutesToDate(date: Date, minutes: number): Date {
const time = date.getTime();
const offsetMs = minutes * 60 * 1000;
return new Date(time + offsetMs);
export function argToDate(value: string | undefined): Date | undefined {
return value ? dateTime.stringToDate(value) : undefined;
}

export function parseFreeAndNamedArguments(
Expand Down
Loading

0 comments on commit c9f7502

Please sign in to comment.