Skip to content

Commit

Permalink
KnowledgeProcessor: Tags, Bug fixes (#521)
Browse files Browse the repository at this point in the history
* Tag Index (experimental) for Threads, Knowledge
* Transcript improvements
* Sundry bug fixes and improvements

---------

Co-authored-by: robgruen <robgruen@microsoft.com>
  • Loading branch information
umeshma and robgruen authored Jan 7, 2025
1 parent 62a28c8 commit eba05d0
Show file tree
Hide file tree
Showing 28 changed files with 1,396 additions and 175 deletions.
4 changes: 3 additions & 1 deletion ts/examples/chat/src/memory/chatMemory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ export async function createChatMemoryContext(
models,
storePath,
conversationSettings,
false,
true,
false,
false,
),
};
context.searchMemory = await createSearchMemory(context);
Expand Down Expand Up @@ -1159,6 +1159,7 @@ export async function runChatMemory(): Promise<void> {
def.options.skipEntities = argBool("Skip entity matching", false);
def.options.skipActions = argBool("Skip action matching", false);
def.options.skipTopics = argBool("Skip topics matching", false);
def.options.skipMessages = argBool("Skip loading messages", false);
def.options.threads = argBool("Use most likely thread", false);
return def;
}
Expand Down Expand Up @@ -1368,6 +1369,7 @@ export async function runChatMemory(): Promise<void> {
searchOptions.skipEntitySearch = namedArgs.skipEntities;
searchOptions.skipActionSearch = namedArgs.skipActions;
searchOptions.skipTopicSearch = namedArgs.skipTopics;
searchOptions.skipMessages = namedArgs.skipMessages;
result = await searcher.searchTermsV2(
query,
undefined,
Expand Down
31 changes: 22 additions & 9 deletions ts/examples/chat/src/memory/chatMemoryPrinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,28 @@ export class ChatMemoryPrinter extends ChatPrinter {
}

public writeExtractedEntities(
entities?: (conversation.ExtractedEntity | undefined)[],
entities?:
| conversation.ExtractedEntity
| (conversation.ExtractedEntity | undefined)[]
| undefined,
): void {
if (entities && entities.length > 0) {
this.writeTitle("Entities");
for (const entity of entities) {
if (entity) {
this.writeCompositeEntity(
conversation.toCompositeEntity(entity.value),
);
this.writeLine();
if (entities) {
if (Array.isArray(entities)) {
if (entities.length > 0) {
this.writeTitle("Entities");
for (const entity of entities) {
if (entity) {
this.writeCompositeEntity(
conversation.toCompositeEntity(entity.value),
);
this.writeLine();
}
}
}
} else {
this.writeCompositeEntity(
conversation.toCompositeEntity(entities.value),
);
}
}
}
Expand All @@ -160,6 +171,8 @@ export class ChatMemoryPrinter extends ChatPrinter {
entities: (conversation.CompositeEntity | undefined)[],
): void {
if (entities && entities.length > 0) {
entities = knowLib.sets.removeUndefined(entities);
entities.sort((x, y) => x!.name.localeCompare(y!.name));
this.writeTitle("Entities");
for (const entity of entities) {
this.writeCompositeEntity(entity);
Expand Down
23 changes: 23 additions & 0 deletions ts/examples/chat/src/memory/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SourceTextBlock,
} from "knowledge-processor";
import { asyncArray, ChatUserInterface, dateTime } from "typeagent";
import { ChatMemoryPrinter } from "./chatMemoryPrinter.js";

export async function pause(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
Expand Down Expand Up @@ -194,3 +195,25 @@ export function getSearchQuestion(
}
return undefined;
}

export async function manageConversationAlias(
cm: conversation.ConversationManager,
printer: ChatMemoryPrinter,
name: string | undefined,
alias: string | undefined,
) {
const aliases = (await cm.conversation.getEntityIndex()).nameAliases;
if (name && alias) {
await aliases.addAlias(alias, name);
} else if (alias) {
const names = await aliases.getByAlias(alias);
if (names) {
printer.writeLines(names);
}
} else {
for await (const entry of aliases.entries()) {
printer.writeLine(entry.name);
printer.writeList(entry.value, { type: "ul" });
}
}
}
Loading

0 comments on commit eba05d0

Please sign in to comment.