@@ -10,6 +10,36 @@ public Podcast(MemorySettings settings, IStorageProvider<PodcastMessage> provide
1010 {
1111 }
1212
13+ public async ValueTask BuildIndexAsync ( CancellationToken cancellationToken )
14+ {
15+ BeginIndexing ( ) ;
16+ try
17+ {
18+ await this . UpdateIndexAsync (
19+ cancellationToken
20+ ) . ConfigureAwait ( false ) ;
21+
22+ await BuildSecondaryIndexesAsync (
23+ cancellationToken
24+ ) . ConfigureAwait ( false ) ;
25+ }
26+ finally
27+ {
28+ EndIndexing ( ) ;
29+ }
30+ }
31+
32+ public async ValueTask BuildSecondaryIndexesAsync ( CancellationToken cancellationToken = default )
33+ {
34+ await BuildParticipantAliasesAsync (
35+ cancellationToken
36+ ) . ConfigureAwait ( false ) ;
37+
38+ await AddSynonymsAsync (
39+ cancellationToken
40+ ) . ConfigureAwait ( false ) ;
41+ }
42+
1343 public async ValueTask ImportTranscriptAsync (
1444 string filePath ,
1545 string ? name = null ,
@@ -35,6 +65,42 @@ await Messages.AppendAsync(
3565 ) . ConfigureAwait ( false ) ;
3666 }
3767
68+ private async ValueTask AddSynonymsAsync ( CancellationToken cancellationToken )
69+ {
70+ AliasMap aliases = AliasMap . LoadResource (
71+ typeof ( Podcast ) . Assembly ,
72+ "TypeAgent.ConversationMemory.podcastVerbs.json"
73+ ) ;
74+
75+ await SecondaryIndexes . TermToRelatedTermsIndex . Aliases . AddAsync (
76+ aliases ,
77+ cancellationToken
78+ ) . ConfigureAwait ( false ) ;
79+ }
80+
81+ private async ValueTask BuildParticipantAliasesAsync ( CancellationToken cancellationToken = default )
82+ {
83+ var aliases = await CollectParticipantAliasesAsync (
84+ cancellationToken
85+ ) . ConfigureAwait ( false ) ;
86+
87+ await SecondaryIndexes . TermToRelatedTermsIndex . Aliases . AddAsync (
88+ aliases ,
89+ cancellationToken
90+ ) . ConfigureAwait ( false ) ;
91+ }
92+
93+ private async ValueTask < AliasMap > CollectParticipantAliasesAsync ( CancellationToken cancellationToken = default )
94+ {
95+ AliasMap aliases = [ ] ;
96+ await foreach ( var message in Messages )
97+ {
98+ PodcastMessageMeta metadata = message . Metadata ;
99+ metadata . CollectAliases ( aliases ) ;
100+ }
101+ return aliases ;
102+ }
103+
38104 private void AssignMessageListeners ( IList < PodcastMessage > messages , ISet < string > participants )
39105 {
40106 foreach ( var message in messages )
0 commit comments