fawn-memory 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +183 -0
- package/dist/index.js.map +1 -0
- package/dist/knowpro/answerContextSchema.d.ts +20 -0
- package/dist/knowpro/answerContextSchema.d.ts.map +1 -0
- package/dist/knowpro/answerContextSchema.js +4 -0
- package/dist/knowpro/answerContextSchema.js.map +1 -0
- package/dist/knowpro/answerResponseSchema.d.ts +7 -0
- package/dist/knowpro/answerResponseSchema.d.ts.map +1 -0
- package/dist/knowpro/answerResponseSchema.js +4 -0
- package/dist/knowpro/answerResponseSchema.js.map +1 -0
- package/dist/knowpro/answerTranslator.d.ts +5 -0
- package/dist/knowpro/answerTranslator.d.ts.map +1 -0
- package/dist/knowpro/answerTranslator.js +10 -0
- package/dist/knowpro/answerTranslator.js.map +1 -0
- package/dist/knowpro/collections.d.ts +14 -0
- package/dist/knowpro/collections.d.ts.map +1 -0
- package/dist/knowpro/collections.js +52 -0
- package/dist/knowpro/collections.js.map +1 -0
- package/dist/knowpro/conversation.d.ts +63 -0
- package/dist/knowpro/conversation.d.ts.map +1 -0
- package/dist/knowpro/conversation.js +247 -0
- package/dist/knowpro/conversation.js.map +1 -0
- package/dist/knowpro/dateTimeSchema.d.ts +19 -0
- package/dist/knowpro/dateTimeSchema.d.ts.map +1 -0
- package/dist/knowpro/dateTimeSchema.js +4 -0
- package/dist/knowpro/dateTimeSchema.js.map +1 -0
- package/dist/knowpro/entities.d.ts +9 -0
- package/dist/knowpro/entities.d.ts.map +1 -0
- package/dist/knowpro/entities.js +63 -0
- package/dist/knowpro/entities.js.map +1 -0
- package/dist/knowpro/interfaces.d.ts +637 -0
- package/dist/knowpro/interfaces.d.ts.map +1 -0
- package/dist/knowpro/interfaces.js +4 -0
- package/dist/knowpro/interfaces.js.map +1 -0
- package/dist/knowpro/knowledge.d.ts +19 -0
- package/dist/knowpro/knowledge.d.ts.map +1 -0
- package/dist/knowpro/knowledge.js +97 -0
- package/dist/knowpro/knowledge.js.map +1 -0
- package/dist/knowpro/knowledgeSchema.d.ts +39 -0
- package/dist/knowpro/knowledgeSchema.d.ts.map +1 -0
- package/dist/knowpro/knowledgeSchema.js +2 -0
- package/dist/knowpro/knowledgeSchema.js.map +1 -0
- package/dist/knowpro/llmProvider.d.ts +17 -0
- package/dist/knowpro/llmProvider.d.ts.map +1 -0
- package/dist/knowpro/llmProvider.js +105 -0
- package/dist/knowpro/llmProvider.js.map +1 -0
- package/dist/knowpro/relatedTermsSchema.d.ts +24 -0
- package/dist/knowpro/relatedTermsSchema.d.ts.map +1 -0
- package/dist/knowpro/relatedTermsSchema.js +6 -0
- package/dist/knowpro/relatedTermsSchema.js.map +1 -0
- package/dist/knowpro/schema.d.ts +24 -0
- package/dist/knowpro/schema.d.ts.map +1 -0
- package/dist/knowpro/schema.js +55 -0
- package/dist/knowpro/schema.js.map +1 -0
- package/dist/knowpro/search.d.ts +8 -0
- package/dist/knowpro/search.d.ts.map +1 -0
- package/dist/knowpro/search.js +448 -0
- package/dist/knowpro/search.js.map +1 -0
- package/dist/knowpro/searchQuerySchema.d.ts +40 -0
- package/dist/knowpro/searchQuerySchema.d.ts.map +1 -0
- package/dist/knowpro/searchQuerySchema.js +4 -0
- package/dist/knowpro/searchQuerySchema.js.map +1 -0
- package/dist/knowpro/searchQueryTranslator.d.ts +33 -0
- package/dist/knowpro/searchQueryTranslator.d.ts.map +1 -0
- package/dist/knowpro/searchQueryTranslator.js +47 -0
- package/dist/knowpro/searchQueryTranslator.js.map +1 -0
- package/dist/knowpro/semanticRef.d.ts +4 -0
- package/dist/knowpro/semanticRef.d.ts.map +1 -0
- package/dist/knowpro/semanticRef.js +62 -0
- package/dist/knowpro/semanticRef.js.map +1 -0
- package/dist/knowpro/semanticRefIndex.d.ts +48 -0
- package/dist/knowpro/semanticRefIndex.d.ts.map +1 -0
- package/dist/knowpro/semanticRefIndex.js +388 -0
- package/dist/knowpro/semanticRefIndex.js.map +1 -0
- package/dist/knowpro/storageProvider.d.ts +7 -0
- package/dist/knowpro/storageProvider.d.ts.map +1 -0
- package/dist/knowpro/storageProvider.js +61 -0
- package/dist/knowpro/storageProvider.js.map +1 -0
- package/dist/knowpro/timestampIndex.d.ts +43 -0
- package/dist/knowpro/timestampIndex.d.ts.map +1 -0
- package/dist/knowpro/timestampIndex.js +324 -0
- package/dist/knowpro/timestampIndex.js.map +1 -0
- package/dist/rag/chunking.d.ts +6 -0
- package/dist/rag/chunking.d.ts.map +1 -0
- package/dist/rag/chunking.js +83 -0
- package/dist/rag/chunking.js.map +1 -0
- package/dist/rag/embeddingProvider.d.ts +34 -0
- package/dist/rag/embeddingProvider.d.ts.map +1 -0
- package/dist/rag/embeddingProvider.js +95 -0
- package/dist/rag/embeddingProvider.js.map +1 -0
- package/dist/rag/index.d.ts +8 -0
- package/dist/rag/index.d.ts.map +1 -0
- package/dist/rag/index.js +7 -0
- package/dist/rag/index.js.map +1 -0
- package/dist/rag/knowproAdapter.d.ts +44 -0
- package/dist/rag/knowproAdapter.d.ts.map +1 -0
- package/dist/rag/knowproAdapter.js +66 -0
- package/dist/rag/knowproAdapter.js.map +1 -0
- package/dist/rag/ragIndex.d.ts +101 -0
- package/dist/rag/ragIndex.d.ts.map +1 -0
- package/dist/rag/ragIndex.js +305 -0
- package/dist/rag/ragIndex.js.map +1 -0
- package/dist/rag/similarity.d.ts +15 -0
- package/dist/rag/similarity.d.ts.map +1 -0
- package/dist/rag/similarity.js +47 -0
- package/dist/rag/similarity.js.map +1 -0
- package/dist/rag/types.d.ts +61 -0
- package/dist/rag/types.d.ts.map +1 -0
- package/dist/rag/types.js +2 -0
- package/dist/rag/types.js.map +1 -0
- package/dist/rag/vectorIndex.d.ts +102 -0
- package/dist/rag/vectorIndex.d.ts.map +1 -0
- package/dist/rag/vectorIndex.js +236 -0
- package/dist/rag/vectorIndex.js.map +1 -0
- package/dist/utils/async.d.ts +25 -0
- package/dist/utils/async.d.ts.map +1 -0
- package/dist/utils/async.js +55 -0
- package/dist/utils/async.js.map +1 -0
- package/dist/utils/string.d.ts +3 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +15 -0
- package/dist/utils/string.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import type { Result, TypeChatJsonTranslator } from "typechat";
|
|
2
|
+
import type { KnowledgeResponse, ConcreteEntity, Action } from "./knowledgeSchema.js";
|
|
3
|
+
/**
|
|
4
|
+
* A Knowledge Source is any object that returns knowledge
|
|
5
|
+
* Knowledge is returned in the form of a KnowledgeResponse {@link KnowledgeResponse}
|
|
6
|
+
*/
|
|
7
|
+
export interface IKnowledgeSource {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves knowledge from the source.
|
|
10
|
+
* @returns {KnowledgeResponse | undefined} The knowledge response or undefined if no knowledge is available.
|
|
11
|
+
*/
|
|
12
|
+
getKnowledge(): KnowledgeResponse | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Messages are referenced by their sequential ordinal numbers
|
|
16
|
+
*/
|
|
17
|
+
export type MessageOrdinal = number;
|
|
18
|
+
/**
|
|
19
|
+
* Metadata associated with a message.
|
|
20
|
+
*/
|
|
21
|
+
export interface IMessageMetadata {
|
|
22
|
+
/**
|
|
23
|
+
* The source ("sender/s") of the message
|
|
24
|
+
*/
|
|
25
|
+
readonly source?: string | string[] | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The dest ("recipients") of the message
|
|
28
|
+
*/
|
|
29
|
+
readonly dest?: string | string[] | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A message in a conversation
|
|
33
|
+
* A Message contains one or more text chunks
|
|
34
|
+
*/
|
|
35
|
+
export interface IMessage extends IKnowledgeSource {
|
|
36
|
+
/**
|
|
37
|
+
* The text of the message, split into chunks
|
|
38
|
+
*/
|
|
39
|
+
textChunks: string[];
|
|
40
|
+
/**
|
|
41
|
+
* The (optional) timestamp of the message.
|
|
42
|
+
*/
|
|
43
|
+
timestamp?: string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* (Optional) tags associated with the message
|
|
46
|
+
*/
|
|
47
|
+
tags: MessageTag[];
|
|
48
|
+
/**
|
|
49
|
+
* (Future) Information about the deletion of the message.
|
|
50
|
+
*/
|
|
51
|
+
deletionInfo?: DeletionInfo | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Metadata associated with the message such as its source.
|
|
54
|
+
*/
|
|
55
|
+
metadata?: IMessageMetadata | undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Represents a message ordinal with an associated score.
|
|
59
|
+
*/
|
|
60
|
+
export type ScoredMessageOrdinal = {
|
|
61
|
+
/**
|
|
62
|
+
* The ordinal number of the message.
|
|
63
|
+
* Use this ordinal to get the message frm the conversation's message collection {@link IMessageCollection}
|
|
64
|
+
* @see {@link IConversation.messages}
|
|
65
|
+
*/
|
|
66
|
+
messageOrdinal: MessageOrdinal;
|
|
67
|
+
/**
|
|
68
|
+
* The score associated with the message.
|
|
69
|
+
*/
|
|
70
|
+
score: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* (Future)
|
|
74
|
+
*/
|
|
75
|
+
export interface DeletionInfo {
|
|
76
|
+
timestamp: string;
|
|
77
|
+
reason?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Types of knowledge objects {@link Knowledge}
|
|
81
|
+
*/
|
|
82
|
+
export type KnowledgeType = "entity" | "action" | "topic" | "tag" | "sTag";
|
|
83
|
+
/**
|
|
84
|
+
* Knowledge objects
|
|
85
|
+
*/
|
|
86
|
+
export type Knowledge = ConcreteEntity | Action | Topic | Tag | StructuredTag;
|
|
87
|
+
/**
|
|
88
|
+
* Semantic Refs are referenced by their sequential ordinal numbers
|
|
89
|
+
*/
|
|
90
|
+
export type SemanticRefOrdinal = number;
|
|
91
|
+
/**
|
|
92
|
+
* A semantic reference represents semantic knowledge that was extracted
|
|
93
|
+
* from a source text range
|
|
94
|
+
*/
|
|
95
|
+
export interface SemanticRef {
|
|
96
|
+
semanticRefOrdinal: SemanticRefOrdinal;
|
|
97
|
+
/**
|
|
98
|
+
* Range of text where this semantic reference was found/extracted.
|
|
99
|
+
*/
|
|
100
|
+
range: TextRange;
|
|
101
|
+
/**
|
|
102
|
+
* Type of knowledge the reference points to.
|
|
103
|
+
*/
|
|
104
|
+
knowledgeType: KnowledgeType;
|
|
105
|
+
/**
|
|
106
|
+
* The actual knowledge object.
|
|
107
|
+
*/
|
|
108
|
+
knowledge: Knowledge;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Knowledge of type "topic"
|
|
112
|
+
*/
|
|
113
|
+
export interface Topic {
|
|
114
|
+
/**
|
|
115
|
+
* Text of the topic.
|
|
116
|
+
*/
|
|
117
|
+
text: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Tags
|
|
121
|
+
*/
|
|
122
|
+
export interface Tag {
|
|
123
|
+
/**
|
|
124
|
+
* Text of the tag.
|
|
125
|
+
*/
|
|
126
|
+
text: string;
|
|
127
|
+
}
|
|
128
|
+
export type StructuredTag = ConcreteEntity;
|
|
129
|
+
export type MessageTag = string | StructuredTag;
|
|
130
|
+
/**
|
|
131
|
+
* A conversation is a sequence of messages
|
|
132
|
+
* The conversation can also store semantic refs {@link SemanticRef} that was found
|
|
133
|
+
* in the source text of the messages.
|
|
134
|
+
*
|
|
135
|
+
* Messages and semantic refs are indexed for retrieval.
|
|
136
|
+
*
|
|
137
|
+
* @template TMessage - Type of the message in the conversation.
|
|
138
|
+
*/
|
|
139
|
+
export interface IConversation<TMessage extends IMessage = IMessage> {
|
|
140
|
+
/**
|
|
141
|
+
* Name tag for the conversation.
|
|
142
|
+
*/
|
|
143
|
+
nameTag: string;
|
|
144
|
+
/**
|
|
145
|
+
* Array of tags associated with the conversation.
|
|
146
|
+
*/
|
|
147
|
+
tags: string[];
|
|
148
|
+
/**
|
|
149
|
+
* Collection of messages in the conversation.
|
|
150
|
+
*/
|
|
151
|
+
messages: IMessageCollection<TMessage>;
|
|
152
|
+
/**
|
|
153
|
+
* Collection of semantic references, if any.
|
|
154
|
+
*/
|
|
155
|
+
semanticRefs: ISemanticRefCollection | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Index mapping terms to semantic references.
|
|
158
|
+
*/
|
|
159
|
+
semanticRefIndex?: ITermToSemanticRefIndex | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Secondary indexes for the conversation.
|
|
162
|
+
*/
|
|
163
|
+
secondaryIndexes?: IConversationSecondaryIndexes | undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Represents a scored semantic reference ordinal.
|
|
167
|
+
*/
|
|
168
|
+
export type ScoredSemanticRefOrdinal = {
|
|
169
|
+
/**
|
|
170
|
+
* Ordinal number for the SemanticRef {@link SemanticRef}.
|
|
171
|
+
* Use this ordinal to resolve the SemanticRef from the conversation's semantic refs collection {@link ISemanticRefCollection}
|
|
172
|
+
* @see {@link IConversation.semanticRefs}
|
|
173
|
+
*/
|
|
174
|
+
semanticRefOrdinal: SemanticRefOrdinal;
|
|
175
|
+
/**
|
|
176
|
+
* Score associated with the semantic reference.
|
|
177
|
+
*/
|
|
178
|
+
score: number;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Inverted Index from term to Semantic Refs {@link SemanticRef}
|
|
182
|
+
*/
|
|
183
|
+
export interface ITermToSemanticRefIndex {
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves all terms in the index.
|
|
186
|
+
*
|
|
187
|
+
* @returns An array of terms.
|
|
188
|
+
*/
|
|
189
|
+
getTerms(): string[];
|
|
190
|
+
/**
|
|
191
|
+
* Adds a term with its associated semantic reference ordinal.
|
|
192
|
+
*
|
|
193
|
+
* @param term - The term to add.
|
|
194
|
+
* @param semanticRefOrdinal - The semantic reference ordinal or scored semantic reference ordinal.
|
|
195
|
+
* @returns The added term.
|
|
196
|
+
*/
|
|
197
|
+
addTerm(term: string, semanticRefOrdinal: SemanticRefOrdinal | ScoredSemanticRefOrdinal): string;
|
|
198
|
+
/**
|
|
199
|
+
* Removes a term with its associated semantic reference ordinal.
|
|
200
|
+
*
|
|
201
|
+
* @param term - The term to remove.
|
|
202
|
+
* @param semanticRefOrdinal - The semantic reference ordinal.
|
|
203
|
+
*/
|
|
204
|
+
removeTerm(term: string, semanticRefOrdinal: SemanticRefOrdinal): void;
|
|
205
|
+
/**
|
|
206
|
+
* Looks up a term and retrieves its associated scored semantic reference ordinals.
|
|
207
|
+
*
|
|
208
|
+
* @param term - The term to look up.
|
|
209
|
+
* @returns An array of scored semantic reference ordinals or undefined if the term is not found.
|
|
210
|
+
*/
|
|
211
|
+
lookupTerm(term: string): ScoredSemanticRefOrdinal[] | undefined;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Represents a specific location of within a text {@link IMessage}.
|
|
215
|
+
* A message can contain one or more text chunks
|
|
216
|
+
*/
|
|
217
|
+
export interface TextLocation {
|
|
218
|
+
/**
|
|
219
|
+
* The ordinal of the message.
|
|
220
|
+
*/
|
|
221
|
+
messageOrdinal: MessageOrdinal;
|
|
222
|
+
/**
|
|
223
|
+
* [Optional] The ordinal index of the chunk within the message.
|
|
224
|
+
*/
|
|
225
|
+
chunkOrdinal?: number;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A text range within a conversation
|
|
229
|
+
* TextRange can represent both a text range and a point location
|
|
230
|
+
* If 'end' is undefined, the text range represents a point location, identified by 'start'
|
|
231
|
+
*/
|
|
232
|
+
export interface TextRange {
|
|
233
|
+
/**
|
|
234
|
+
* The start of the range.
|
|
235
|
+
*/
|
|
236
|
+
start: TextLocation;
|
|
237
|
+
/**
|
|
238
|
+
* The (optional) end of the range (exclusive).
|
|
239
|
+
*/
|
|
240
|
+
end?: TextLocation | undefined;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Represents a date range.
|
|
244
|
+
*/
|
|
245
|
+
export type DateRange = {
|
|
246
|
+
/**
|
|
247
|
+
* The start date of the range (inclusive).
|
|
248
|
+
*/
|
|
249
|
+
start: Date;
|
|
250
|
+
/**
|
|
251
|
+
* The (optional) end date of the range (inclusive).
|
|
252
|
+
*/
|
|
253
|
+
end?: Date | undefined;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Represents a term with optional weighting.
|
|
257
|
+
*/
|
|
258
|
+
export type Term = {
|
|
259
|
+
/**
|
|
260
|
+
* The text of the term.
|
|
261
|
+
*/
|
|
262
|
+
text: string;
|
|
263
|
+
/**
|
|
264
|
+
* Optional weighting for any matches for this term
|
|
265
|
+
*/
|
|
266
|
+
weight?: number | undefined;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Represents scored knowledge.
|
|
270
|
+
* Scored knowledge is typically returned by search APIs
|
|
271
|
+
*/
|
|
272
|
+
export type ScoredKnowledge = {
|
|
273
|
+
/**
|
|
274
|
+
* Type of knowledge.
|
|
275
|
+
*/
|
|
276
|
+
knowledgeType: KnowledgeType;
|
|
277
|
+
/**
|
|
278
|
+
* The actual knowledge object.
|
|
279
|
+
*/
|
|
280
|
+
knowledge: Knowledge;
|
|
281
|
+
/**
|
|
282
|
+
* Score associated with the knowledge.
|
|
283
|
+
*/
|
|
284
|
+
score: number;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Interface for conversation secondary indexes.
|
|
288
|
+
* {@link IConversation}
|
|
289
|
+
*/
|
|
290
|
+
export interface IConversationSecondaryIndexes {
|
|
291
|
+
/**
|
|
292
|
+
* Index mapping properties to semantic references.
|
|
293
|
+
*/
|
|
294
|
+
propertyToSemanticRefIndex?: IPropertyToSemanticRefIndex | undefined;
|
|
295
|
+
/**
|
|
296
|
+
* Index mapping timestamps to text ranges.
|
|
297
|
+
*/
|
|
298
|
+
timestampIndex?: ITimestampToTextRangeIndex | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* Index mapping terms to related terms.
|
|
301
|
+
*/
|
|
302
|
+
termToRelatedTermsIndex?: ITermToRelatedTermsIndex | undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Optional threads in the conversation.
|
|
305
|
+
*/
|
|
306
|
+
threads?: IConversationThreads | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Optional index for message text.
|
|
309
|
+
*/
|
|
310
|
+
messageIndex?: IMessageTextIndex | undefined;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Allows for faster retrieval of name, value properties
|
|
314
|
+
*/
|
|
315
|
+
export interface IPropertyToSemanticRefIndex {
|
|
316
|
+
/**
|
|
317
|
+
* All property values
|
|
318
|
+
*/
|
|
319
|
+
getValues(): string[];
|
|
320
|
+
/**
|
|
321
|
+
* Adds a property name, value and the ordinal of the semantic ref this
|
|
322
|
+
* property was found in (associated with)
|
|
323
|
+
*
|
|
324
|
+
* @param propertyName - The name of the property.
|
|
325
|
+
* @param value - The value of the property.
|
|
326
|
+
* @param semanticRefOrdinal - The semantic reference ordinal or scored semantic reference ordinal.
|
|
327
|
+
*/
|
|
328
|
+
addProperty(propertyName: string, value: string, semanticRefOrdinal: SemanticRefOrdinal | ScoredSemanticRefOrdinal): void;
|
|
329
|
+
/**
|
|
330
|
+
* Looks up a property (name, value) returning the associated scored semantic reference ordinals.
|
|
331
|
+
*
|
|
332
|
+
* @param propertyName - The name of the property.
|
|
333
|
+
* @param value - The value of the property.
|
|
334
|
+
* @returns An array of scored semantic reference ordinals or undefined if the property is not found.
|
|
335
|
+
*/
|
|
336
|
+
lookupProperty(propertyName: string, value: string): ScoredSemanticRefOrdinal[] | undefined;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Represents a timestamped text range.
|
|
340
|
+
*/
|
|
341
|
+
export type TimestampedTextRange = {
|
|
342
|
+
/**
|
|
343
|
+
* The timestamp associated with the text range.
|
|
344
|
+
*/
|
|
345
|
+
timestamp: string;
|
|
346
|
+
/**
|
|
347
|
+
* The text range.
|
|
348
|
+
*/
|
|
349
|
+
range: TextRange;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Interface for timestamp to text range index.
|
|
353
|
+
* Allows for retrieval of text ranges within a given date range.
|
|
354
|
+
*/
|
|
355
|
+
export interface ITimestampToTextRangeIndex {
|
|
356
|
+
/**
|
|
357
|
+
* Adds a message ordinal with the given timestamp
|
|
358
|
+
* The message ordinal represents a {@link TextLocation} {messageOrdinal}
|
|
359
|
+
* @param messageOrdinal - The ordinal of the message.
|
|
360
|
+
* @param timestamp - The timestamp to add.
|
|
361
|
+
* @returns True if the timestamp was added successfully, false otherwise.
|
|
362
|
+
*/
|
|
363
|
+
addTimestamp(messageOrdinal: MessageOrdinal, timestamp: string): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Add multiple {messageOrdinal, timestamp} pairs
|
|
366
|
+
* @param messageTimestamps
|
|
367
|
+
*/
|
|
368
|
+
addTimestamps(messageTimestamps: [MessageOrdinal, string][]): ListIndexingResult;
|
|
369
|
+
/**
|
|
370
|
+
* Looks up text ranges within a given date range.
|
|
371
|
+
*
|
|
372
|
+
* @param dateRange - The date range to look up.
|
|
373
|
+
* @returns An array of timestamped text ranges.
|
|
374
|
+
*/
|
|
375
|
+
lookupRange(dateRange: DateRange): TimestampedTextRange[];
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Returns related terms for a given term
|
|
379
|
+
* This is ideal for local synonym and other tables
|
|
380
|
+
*/
|
|
381
|
+
export interface ITermToRelatedTerms {
|
|
382
|
+
/**
|
|
383
|
+
* Lookup terms related to the given term text
|
|
384
|
+
* @param text
|
|
385
|
+
*/
|
|
386
|
+
lookupTerm(text: string): Term[] | undefined;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* An index that maintains fuzzy (approximate) relationships between terms
|
|
390
|
+
* The fuzzy relationship may be determined dynamically
|
|
391
|
+
* Given a term, can return terms approximately related to it.
|
|
392
|
+
*/
|
|
393
|
+
export interface ITermToRelatedTermsFuzzy {
|
|
394
|
+
/**
|
|
395
|
+
* Add a term to the index.
|
|
396
|
+
* @param terms
|
|
397
|
+
* @param eventHandler
|
|
398
|
+
*/
|
|
399
|
+
addTerms(terms: string[], eventHandler?: IndexingEventHandlers): Promise<ListIndexingResult>;
|
|
400
|
+
/**
|
|
401
|
+
* Looks up a term and retrieves related terms
|
|
402
|
+
*
|
|
403
|
+
* @param text - The text of the term to look up.
|
|
404
|
+
* @param maxMatches - Optional maximum number of matches to retrieve.
|
|
405
|
+
* @param thresholdScore - Optional threshold similarity score for matches.
|
|
406
|
+
* @returns A promise that resolves to an array of related terms.
|
|
407
|
+
*/
|
|
408
|
+
lookupTerm(text: string, maxMatches?: number, thresholdScore?: number): Promise<Term[]>;
|
|
409
|
+
/**
|
|
410
|
+
* Looks up terms in a batch
|
|
411
|
+
* @param textArray
|
|
412
|
+
* @param maxMatches
|
|
413
|
+
* @param thresholdScore
|
|
414
|
+
*/
|
|
415
|
+
lookupTerms(textArray: string[], maxMatches?: number, thresholdScore?: number): Promise<Term[][]>;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Interface for term to related terms index.
|
|
419
|
+
*/
|
|
420
|
+
export interface ITermToRelatedTermsIndex {
|
|
421
|
+
/**
|
|
422
|
+
* Return the alias index, if available
|
|
423
|
+
*/
|
|
424
|
+
get aliases(): ITermToRelatedTerms | undefined;
|
|
425
|
+
/**
|
|
426
|
+
* Return a fuzzy index, if available
|
|
427
|
+
*/
|
|
428
|
+
get fuzzyIndex(): ITermToRelatedTermsFuzzy | undefined;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* A Thread is a set of text ranges in a conversation
|
|
432
|
+
*/
|
|
433
|
+
export type Thread = {
|
|
434
|
+
description: string;
|
|
435
|
+
ranges: TextRange[];
|
|
436
|
+
};
|
|
437
|
+
export type ThreadOrdinal = number;
|
|
438
|
+
export type ScoredThreadOrdinal = {
|
|
439
|
+
threadOrdinal: ThreadOrdinal;
|
|
440
|
+
score: number;
|
|
441
|
+
};
|
|
442
|
+
export interface IConversationThreads {
|
|
443
|
+
readonly threads: Thread[];
|
|
444
|
+
addThread(thread: Thread): Promise<void>;
|
|
445
|
+
lookupThread(threadDescription: string, maxMatches?: number, thresholdScore?: number): Promise<ScoredThreadOrdinal[] | undefined>;
|
|
446
|
+
removeThread(threadOrdinal: ThreadOrdinal): void;
|
|
447
|
+
}
|
|
448
|
+
export interface IMessageTextIndex {
|
|
449
|
+
addMessages(messages: IMessage[], eventHandler?: IndexingEventHandlers): Promise<ListIndexingResult>;
|
|
450
|
+
lookupMessages(messageText: string, maxMatches?: number, thresholdScore?: number): Promise<ScoredMessageOrdinal[]>;
|
|
451
|
+
lookupMessagesInSubset(messageText: string, ordinalsToSearch: MessageOrdinal[], maxMatches?: number, thresholdScore?: number): Promise<ScoredMessageOrdinal[]>;
|
|
452
|
+
}
|
|
453
|
+
export interface SearchTerm {
|
|
454
|
+
/**
|
|
455
|
+
* Term being searched for
|
|
456
|
+
*/
|
|
457
|
+
term: Term;
|
|
458
|
+
/**
|
|
459
|
+
* Additional terms related to term.
|
|
460
|
+
* These can be supplied from synonym tables and so on.
|
|
461
|
+
* - Zero length array: no related matches for this term. That will force an exact match
|
|
462
|
+
* - undefined array: the search processor may try to resolve related terms from any {@link IConversationSecondaryIndexes}
|
|
463
|
+
* related term {@link ITermToRelatedTermsIndex} indexes available to it
|
|
464
|
+
*/
|
|
465
|
+
relatedTerms?: Term[] | undefined;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Well known knowledge properties
|
|
469
|
+
*/
|
|
470
|
+
export type KnowledgePropertyName = "name" | "type" | "verb" | "subject" | "object" | "indirectObject" | "tag" | "topic";
|
|
471
|
+
export type PropertySearchTerm = {
|
|
472
|
+
/**
|
|
473
|
+
* PropertySearch terms let you match named property, values
|
|
474
|
+
* - You can match a well known property name (name("Bach") type("book"))
|
|
475
|
+
* - Or you can provide a SearchTerm as a propertyName.
|
|
476
|
+
* E.g. to match hue(red)
|
|
477
|
+
* - propertyName as SearchTerm, set to 'hue'
|
|
478
|
+
* - propertyValue as SearchTerm, set to 'red'
|
|
479
|
+
* We also want hue(red) to match any facets called color(red)
|
|
480
|
+
* SearchTerms can included related terms
|
|
481
|
+
* E.g you could include "color" as a related term for the propertyName "hue". Or 'crimson' for red.
|
|
482
|
+
*
|
|
483
|
+
* See {@link KnowledgePropertyName} for well known property names
|
|
484
|
+
*
|
|
485
|
+
* The the query processor can also related terms using a related terms secondary index, if one is available
|
|
486
|
+
*/
|
|
487
|
+
propertyName: KnowledgePropertyName | SearchTerm;
|
|
488
|
+
propertyValue: SearchTerm;
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* Terms in a SearchTermGroup can of these types
|
|
492
|
+
*/
|
|
493
|
+
export type SearchTermGroupTypes = SearchTerm | PropertySearchTerm | SearchTermGroup;
|
|
494
|
+
/**
|
|
495
|
+
* A Group of search terms
|
|
496
|
+
*/
|
|
497
|
+
export type SearchTermGroup = {
|
|
498
|
+
booleanOp: "and" | "or" | "or_max";
|
|
499
|
+
terms: SearchTermGroupTypes[];
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* An expression used to select contents structured contents of the conversation
|
|
503
|
+
*/
|
|
504
|
+
export type SearchSelectExpr = {
|
|
505
|
+
/**
|
|
506
|
+
* A Term group that matches information
|
|
507
|
+
*/
|
|
508
|
+
searchTermGroup: SearchTermGroup;
|
|
509
|
+
/**
|
|
510
|
+
* A filter that scopes what information to match
|
|
511
|
+
*/
|
|
512
|
+
when?: WhenFilter | undefined;
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
515
|
+
* A WhenFilter provides additional constraints on when a SemanticRef that matches a term.. is actually considered a match
|
|
516
|
+
* when the following optional conditions are met:
|
|
517
|
+
* knowledgeType matches. E.g. knowledgeType == 'entity'
|
|
518
|
+
* dateRange matches...E.g. (Jan 3rd to Jan 10th)
|
|
519
|
+
* Semantic Refs are within supplied SCOPE.. i.e. only Semantic Refs from a 'scoping' set of text ranges will match
|
|
520
|
+
*/
|
|
521
|
+
export type WhenFilter = {
|
|
522
|
+
/**
|
|
523
|
+
* Match SemanticRefs of this knowledge type
|
|
524
|
+
*/
|
|
525
|
+
knowledgeType?: KnowledgeType | undefined;
|
|
526
|
+
/**
|
|
527
|
+
* Match only in this date range
|
|
528
|
+
*/
|
|
529
|
+
dateRange?: DateRange | undefined;
|
|
530
|
+
/**
|
|
531
|
+
* If a thread index is available, match in a thread closest to ths description
|
|
532
|
+
*/
|
|
533
|
+
threadDescription?: string | undefined;
|
|
534
|
+
/**
|
|
535
|
+
* Scope matches to only those text ranges matching tags
|
|
536
|
+
*/
|
|
537
|
+
tags?: string[] | undefined;
|
|
538
|
+
tagMatchingTerms?: SearchTermGroup | undefined;
|
|
539
|
+
/**
|
|
540
|
+
* Use this SearchTermGroup as a sub-query to find matching text ranges
|
|
541
|
+
* Match SemanticRefs the scope for this query
|
|
542
|
+
*/
|
|
543
|
+
scopeDefiningTerms?: SearchTermGroup | undefined;
|
|
544
|
+
/**
|
|
545
|
+
* Additional scoping ranges separately computed by caller
|
|
546
|
+
*/
|
|
547
|
+
textRangesInScope?: TextRange[] | undefined;
|
|
548
|
+
};
|
|
549
|
+
export type SemanticRefSearchResult = {
|
|
550
|
+
/**
|
|
551
|
+
* The search terms that caused these semantic refs to match
|
|
552
|
+
*/
|
|
553
|
+
termMatches: Set<string>;
|
|
554
|
+
/**
|
|
555
|
+
* Scored semantic ref matches
|
|
556
|
+
*/
|
|
557
|
+
semanticRefMatches: ScoredSemanticRefOrdinal[];
|
|
558
|
+
};
|
|
559
|
+
export interface IConversationData<TMessage = unknown> {
|
|
560
|
+
nameTag: string;
|
|
561
|
+
messages: TMessage[];
|
|
562
|
+
tags: string[];
|
|
563
|
+
semanticRefs: SemanticRef[];
|
|
564
|
+
semanticIndexData?: ITermToSemanticRefIndexData | undefined;
|
|
565
|
+
}
|
|
566
|
+
export interface ITermToSemanticRefIndexData {
|
|
567
|
+
items: ITermToSemanticRefIndexItem[];
|
|
568
|
+
}
|
|
569
|
+
export interface ITermToSemanticRefIndexItem {
|
|
570
|
+
term: string;
|
|
571
|
+
semanticRefOrdinals: ScoredSemanticRefOrdinal[];
|
|
572
|
+
}
|
|
573
|
+
export interface IndexingEventHandlers {
|
|
574
|
+
onKnowledgeExtracted?: (chunk: TextLocation, knowledgeResult: KnowledgeResponse) => boolean;
|
|
575
|
+
onEmbeddingsCreated?: (sourceTexts: string[], batch: string[], batchStartAt: number) => boolean;
|
|
576
|
+
onTextIndexed?: (textAndLocations: [string, TextLocation][], batch: [string, TextLocation][], batchStartAt: number) => boolean;
|
|
577
|
+
}
|
|
578
|
+
export type IndexingResults = {
|
|
579
|
+
semanticRefs?: TextIndexingResult | undefined;
|
|
580
|
+
secondaryIndexResults?: SecondaryIndexingResults | undefined;
|
|
581
|
+
};
|
|
582
|
+
export type SecondaryIndexingResults = {
|
|
583
|
+
properties?: ListIndexingResult | undefined;
|
|
584
|
+
timestamps?: ListIndexingResult | undefined;
|
|
585
|
+
relatedTerms?: ListIndexingResult | undefined;
|
|
586
|
+
message?: ListIndexingResult | undefined;
|
|
587
|
+
};
|
|
588
|
+
export type TextIndexingResult = {
|
|
589
|
+
completedUpto?: TextLocation | undefined;
|
|
590
|
+
error?: string | undefined;
|
|
591
|
+
};
|
|
592
|
+
export type ListIndexingResult = {
|
|
593
|
+
numberCompleted: number;
|
|
594
|
+
error?: string | undefined;
|
|
595
|
+
};
|
|
596
|
+
export interface IReadonlyCollection<T, TOrdinal = number> extends Iterable<T> {
|
|
597
|
+
readonly length: number;
|
|
598
|
+
get(ordinal: TOrdinal): T;
|
|
599
|
+
getMultiple(ordinals: TOrdinal[]): T[];
|
|
600
|
+
getSlice(start: TOrdinal, end: TOrdinal): T[];
|
|
601
|
+
getAll(): T[];
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* ICollection is an APPEND ONLY collection
|
|
605
|
+
*/
|
|
606
|
+
export interface ICollection<T, TOrdinal = number> extends IReadonlyCollection<T, TOrdinal> {
|
|
607
|
+
readonly isPersistent: boolean;
|
|
608
|
+
append(...items: T[]): void;
|
|
609
|
+
}
|
|
610
|
+
export interface IMessageCollection<TMessage extends IMessage = IMessage> extends ICollection<TMessage, MessageOrdinal> {
|
|
611
|
+
}
|
|
612
|
+
export interface ISemanticRefCollection extends ICollection<SemanticRef, SemanticRefOrdinal> {
|
|
613
|
+
}
|
|
614
|
+
export interface IStorageProvider {
|
|
615
|
+
createMessageCollection<TMessage extends IMessage = IMessage>(serializer?: JsonSerializer<TMessage>): IMessageCollection<TMessage>;
|
|
616
|
+
createSemanticRefCollection(): ISemanticRefCollection;
|
|
617
|
+
close(): void;
|
|
618
|
+
}
|
|
619
|
+
export interface JsonSerializer<T> {
|
|
620
|
+
serialize(value: T): string;
|
|
621
|
+
deserialize(json: string): T;
|
|
622
|
+
}
|
|
623
|
+
export type KnowledgeExtractorSettings = {
|
|
624
|
+
maxContextLength: number;
|
|
625
|
+
mergeActionKnowledge?: boolean;
|
|
626
|
+
mergeEntityFacets?: boolean;
|
|
627
|
+
};
|
|
628
|
+
export interface KnowledgeExtractor {
|
|
629
|
+
readonly settings: KnowledgeExtractorSettings;
|
|
630
|
+
extract(message: string): Promise<KnowledgeResponse | undefined>;
|
|
631
|
+
extractWithRetry(message: string, maxRetries: number): Promise<Result<KnowledgeResponse>>;
|
|
632
|
+
/**
|
|
633
|
+
* Custom translator to use
|
|
634
|
+
*/
|
|
635
|
+
translator?: TypeChatJsonTranslator<KnowledgeResponse> | undefined;
|
|
636
|
+
}
|
|
637
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/knowpro/interfaces.ts"],"names":[],"mappings":"AAGA,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kB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAC9C,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;IACjE,gBAAgB,CACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACtC;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC;CACtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/knowpro/interfaces.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TypeChatJsonTranslator, TypeChatLanguageModel } from "typechat";
|
|
2
|
+
import type { KnowledgeExtractor, KnowledgeExtractorSettings } from "./interfaces.js";
|
|
3
|
+
import type { KnowledgeResponse } from "./knowledgeSchema.js";
|
|
4
|
+
export declare function createKnowledgeTranslator(model: TypeChatLanguageModel): TypeChatJsonTranslator<KnowledgeResponse>;
|
|
5
|
+
/**
|
|
6
|
+
* Return default settings
|
|
7
|
+
* @param maxCharsPerChunk (optional)
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function createKnowledgeExtractorSettings(maxCharsPerChunk?: number): KnowledgeExtractorSettings;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new knowledge extractor
|
|
13
|
+
* @param model
|
|
14
|
+
* @param extractorSettings
|
|
15
|
+
* @param knowledgeTranslator (optional) knowledge translator to use
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function createKnowledgeExtractor(model: TypeChatLanguageModel, extractorSettings?: KnowledgeExtractorSettings | undefined, knowledgeTranslator?: TypeChatJsonTranslator<KnowledgeResponse> | undefined): KnowledgeExtractor;
|
|
19
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/knowpro/knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAO9D,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,qBAAqB,GAC7B,sBAAsB,CAAC,iBAAiB,CAAC,CAuB3C;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC5C,gBAAgB,GAAE,MAAa,GAChC,0BAA0B,CAK5B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,iBAAiB,CAAC,EAAE,0BAA0B,GAAG,SAAS,EAC1D,mBAAmB,CAAC,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,GAAG,SAAS,GAC5E,kBAAkB,CA6EpB"}
|