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.
Files changed (126) hide show
  1. package/README.md +118 -0
  2. package/dist/index.d.ts +14 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +183 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/knowpro/answerContextSchema.d.ts +20 -0
  7. package/dist/knowpro/answerContextSchema.d.ts.map +1 -0
  8. package/dist/knowpro/answerContextSchema.js +4 -0
  9. package/dist/knowpro/answerContextSchema.js.map +1 -0
  10. package/dist/knowpro/answerResponseSchema.d.ts +7 -0
  11. package/dist/knowpro/answerResponseSchema.d.ts.map +1 -0
  12. package/dist/knowpro/answerResponseSchema.js +4 -0
  13. package/dist/knowpro/answerResponseSchema.js.map +1 -0
  14. package/dist/knowpro/answerTranslator.d.ts +5 -0
  15. package/dist/knowpro/answerTranslator.d.ts.map +1 -0
  16. package/dist/knowpro/answerTranslator.js +10 -0
  17. package/dist/knowpro/answerTranslator.js.map +1 -0
  18. package/dist/knowpro/collections.d.ts +14 -0
  19. package/dist/knowpro/collections.d.ts.map +1 -0
  20. package/dist/knowpro/collections.js +52 -0
  21. package/dist/knowpro/collections.js.map +1 -0
  22. package/dist/knowpro/conversation.d.ts +63 -0
  23. package/dist/knowpro/conversation.d.ts.map +1 -0
  24. package/dist/knowpro/conversation.js +247 -0
  25. package/dist/knowpro/conversation.js.map +1 -0
  26. package/dist/knowpro/dateTimeSchema.d.ts +19 -0
  27. package/dist/knowpro/dateTimeSchema.d.ts.map +1 -0
  28. package/dist/knowpro/dateTimeSchema.js +4 -0
  29. package/dist/knowpro/dateTimeSchema.js.map +1 -0
  30. package/dist/knowpro/entities.d.ts +9 -0
  31. package/dist/knowpro/entities.d.ts.map +1 -0
  32. package/dist/knowpro/entities.js +63 -0
  33. package/dist/knowpro/entities.js.map +1 -0
  34. package/dist/knowpro/interfaces.d.ts +637 -0
  35. package/dist/knowpro/interfaces.d.ts.map +1 -0
  36. package/dist/knowpro/interfaces.js +4 -0
  37. package/dist/knowpro/interfaces.js.map +1 -0
  38. package/dist/knowpro/knowledge.d.ts +19 -0
  39. package/dist/knowpro/knowledge.d.ts.map +1 -0
  40. package/dist/knowpro/knowledge.js +97 -0
  41. package/dist/knowpro/knowledge.js.map +1 -0
  42. package/dist/knowpro/knowledgeSchema.d.ts +39 -0
  43. package/dist/knowpro/knowledgeSchema.d.ts.map +1 -0
  44. package/dist/knowpro/knowledgeSchema.js +2 -0
  45. package/dist/knowpro/knowledgeSchema.js.map +1 -0
  46. package/dist/knowpro/llmProvider.d.ts +17 -0
  47. package/dist/knowpro/llmProvider.d.ts.map +1 -0
  48. package/dist/knowpro/llmProvider.js +105 -0
  49. package/dist/knowpro/llmProvider.js.map +1 -0
  50. package/dist/knowpro/relatedTermsSchema.d.ts +24 -0
  51. package/dist/knowpro/relatedTermsSchema.d.ts.map +1 -0
  52. package/dist/knowpro/relatedTermsSchema.js +6 -0
  53. package/dist/knowpro/relatedTermsSchema.js.map +1 -0
  54. package/dist/knowpro/schema.d.ts +24 -0
  55. package/dist/knowpro/schema.d.ts.map +1 -0
  56. package/dist/knowpro/schema.js +55 -0
  57. package/dist/knowpro/schema.js.map +1 -0
  58. package/dist/knowpro/search.d.ts +8 -0
  59. package/dist/knowpro/search.d.ts.map +1 -0
  60. package/dist/knowpro/search.js +448 -0
  61. package/dist/knowpro/search.js.map +1 -0
  62. package/dist/knowpro/searchQuerySchema.d.ts +40 -0
  63. package/dist/knowpro/searchQuerySchema.d.ts.map +1 -0
  64. package/dist/knowpro/searchQuerySchema.js +4 -0
  65. package/dist/knowpro/searchQuerySchema.js.map +1 -0
  66. package/dist/knowpro/searchQueryTranslator.d.ts +33 -0
  67. package/dist/knowpro/searchQueryTranslator.d.ts.map +1 -0
  68. package/dist/knowpro/searchQueryTranslator.js +47 -0
  69. package/dist/knowpro/searchQueryTranslator.js.map +1 -0
  70. package/dist/knowpro/semanticRef.d.ts +4 -0
  71. package/dist/knowpro/semanticRef.d.ts.map +1 -0
  72. package/dist/knowpro/semanticRef.js +62 -0
  73. package/dist/knowpro/semanticRef.js.map +1 -0
  74. package/dist/knowpro/semanticRefIndex.d.ts +48 -0
  75. package/dist/knowpro/semanticRefIndex.d.ts.map +1 -0
  76. package/dist/knowpro/semanticRefIndex.js +388 -0
  77. package/dist/knowpro/semanticRefIndex.js.map +1 -0
  78. package/dist/knowpro/storageProvider.d.ts +7 -0
  79. package/dist/knowpro/storageProvider.d.ts.map +1 -0
  80. package/dist/knowpro/storageProvider.js +61 -0
  81. package/dist/knowpro/storageProvider.js.map +1 -0
  82. package/dist/knowpro/timestampIndex.d.ts +43 -0
  83. package/dist/knowpro/timestampIndex.d.ts.map +1 -0
  84. package/dist/knowpro/timestampIndex.js +324 -0
  85. package/dist/knowpro/timestampIndex.js.map +1 -0
  86. package/dist/rag/chunking.d.ts +6 -0
  87. package/dist/rag/chunking.d.ts.map +1 -0
  88. package/dist/rag/chunking.js +83 -0
  89. package/dist/rag/chunking.js.map +1 -0
  90. package/dist/rag/embeddingProvider.d.ts +34 -0
  91. package/dist/rag/embeddingProvider.d.ts.map +1 -0
  92. package/dist/rag/embeddingProvider.js +95 -0
  93. package/dist/rag/embeddingProvider.js.map +1 -0
  94. package/dist/rag/index.d.ts +8 -0
  95. package/dist/rag/index.d.ts.map +1 -0
  96. package/dist/rag/index.js +7 -0
  97. package/dist/rag/index.js.map +1 -0
  98. package/dist/rag/knowproAdapter.d.ts +44 -0
  99. package/dist/rag/knowproAdapter.d.ts.map +1 -0
  100. package/dist/rag/knowproAdapter.js +66 -0
  101. package/dist/rag/knowproAdapter.js.map +1 -0
  102. package/dist/rag/ragIndex.d.ts +101 -0
  103. package/dist/rag/ragIndex.d.ts.map +1 -0
  104. package/dist/rag/ragIndex.js +305 -0
  105. package/dist/rag/ragIndex.js.map +1 -0
  106. package/dist/rag/similarity.d.ts +15 -0
  107. package/dist/rag/similarity.d.ts.map +1 -0
  108. package/dist/rag/similarity.js +47 -0
  109. package/dist/rag/similarity.js.map +1 -0
  110. package/dist/rag/types.d.ts +61 -0
  111. package/dist/rag/types.d.ts.map +1 -0
  112. package/dist/rag/types.js +2 -0
  113. package/dist/rag/types.js.map +1 -0
  114. package/dist/rag/vectorIndex.d.ts +102 -0
  115. package/dist/rag/vectorIndex.d.ts.map +1 -0
  116. package/dist/rag/vectorIndex.js +236 -0
  117. package/dist/rag/vectorIndex.js.map +1 -0
  118. package/dist/utils/async.d.ts +25 -0
  119. package/dist/utils/async.d.ts.map +1 -0
  120. package/dist/utils/async.js +55 -0
  121. package/dist/utils/async.js.map +1 -0
  122. package/dist/utils/string.d.ts +3 -0
  123. package/dist/utils/string.d.ts.map +1 -0
  124. package/dist/utils/string.js +15 -0
  125. package/dist/utils/string.js.map +1 -0
  126. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # fawn
2
+
3
+ TypeScript toolkit for extracting structured knowledge from text and querying it with natural language. Built on TypeChat, with an in-memory semantic index and a simple REPL for exploration.
4
+
5
+ ## Features
6
+
7
+ - Extract entities, actions, and topics from messages
8
+ - Build an in-memory semantic reference index
9
+ - Query with natural language or explicit term sets
10
+ - Load pre-extracted knowledge from a file
11
+ - Export index data for visualization
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ pnpm install
17
+ ```
18
+
19
+ ## Quickstart (library)
20
+
21
+ ```ts
22
+ import {
23
+ createConversation,
24
+ createMessage,
25
+ createInMemoryStorageProvider
26
+ } from "fawn";
27
+
28
+ const storage = createInMemoryStorageProvider();
29
+ const messages = storage.createMessageCollection();
30
+
31
+ const conversation = await createConversation(messages, "demo", storage);
32
+
33
+ await conversation.addMessageAsync(
34
+ createMessage("I bought apples and bananas today.", [])
35
+ );
36
+
37
+ const answer = await conversation.query("What did I buy?");
38
+ console.log(answer);
39
+ ```
40
+
41
+ ## REPL mode
42
+
43
+ Run the entrypoint directly to use the interactive shell:
44
+
45
+ ```sh
46
+ pnpm dev
47
+ ```
48
+
49
+ Commands inside the REPL:
50
+
51
+ - `@load <path>`: load a knowledge file into the index
52
+ - `@loadindex <path>`: load a pre-built index JSON file
53
+ - `@export [path]`: export index data to JSON (default: `fawn-index-export.json`)
54
+ - `@lemmatize`: add lemmatized forms to the index
55
+ - `@related [weight] [maxTerms]`: expand index with LLM-generated related terms
56
+ - `@wordnet [weight] [maxTerms]`: expand index with WordNet synonyms
57
+ - `@entity <term>`: print entities matching a term
58
+ - `@action <term>`: print actions matching a term
59
+ - `@topic [term]`: print topics matching a term (omit term to print all topics)
60
+ - `@term <term1> <term2> ...`: query by explicit terms
61
+ - `exit` or `quit`: leave the REPL
62
+
63
+ There is a sample knowledge file at `data/1984ParagraphOutput.txt`.
64
+
65
+ ## Examples
66
+
67
+ ### Memory Service
68
+
69
+ A web-based memory service with REST API and chat UI.
70
+
71
+ ```sh
72
+ cd examples/memory
73
+ pnpm install
74
+ pnpm run dev
75
+ ```
76
+
77
+ Open http://localhost:3000/chat for the interactive UI.
78
+
79
+ ### Index Visualizer
80
+
81
+ Interactive tool for exploring semantic indexes with a relationship graph.
82
+
83
+ ```sh
84
+ cd tools/index-visualizer
85
+ pnpm install
86
+ pnpm run dev
87
+ ```
88
+
89
+ Open http://localhost:3001 to load and visualize index data.
90
+
91
+ ## Environment
92
+
93
+ Configure your LLM provider via environment variables:
94
+
95
+ ```sh
96
+ # Provider selection (default: 'openai')
97
+ LLM_PROVIDER=openai # or 'claude'
98
+
99
+ # API keys (set the one for your chosen provider)
100
+ OPENAI_API_KEY=sk-... # For OpenAI (also supports legacy OPENAI_SDK_KEY)
101
+ ANTHROPIC_API_KEY=sk-ant-... # For Claude
102
+
103
+ # Optional: Override default model
104
+ LLM_MODEL=gpt-4-turbo
105
+ ```
106
+
107
+ `dotenv` is enabled, so a local `.env` file works too.
108
+
109
+ ## Scripts
110
+
111
+ - `pnpm dev`: run the REPL entrypoint with tsx
112
+ - `pnpm lint`: run ESLint
113
+ - `pnpm build`: emit ESM + type declarations to `dist/`
114
+ - `pnpm clean`: remove the `dist/` directory
115
+
116
+ ## Development notes
117
+
118
+ `prepublishOnly` runs a clean rebuild (`pnpm run clean && pnpm run build`).
@@ -0,0 +1,14 @@
1
+ import 'dotenv/config';
2
+ export { createConversation, createMessage, loadConversationFromExport, loadConversationFromExportData } from './knowpro/conversation.js';
3
+ export type { Conversation, Message, ExportedIndex } from './knowpro/conversation.js';
4
+ export { createInMemoryStorageProvider } from './knowpro/storageProvider.js';
5
+ export type { InMemoryStorageProvider } from './knowpro/storageProvider.js';
6
+ export { createKnowledgeExtractor } from './knowpro/knowledge.js';
7
+ export type { KnowledgeExtractor } from './knowpro/interfaces.js';
8
+ export type { InMemorySemanticRefIndex, LemmatizationResult, RelatedTermsExpansionOptions, RelatedTermsExpansionResult, WordNetExpansionOptions } from './knowpro/semanticRefIndex.js';
9
+ export type { DeletionInfo, IMessage, IMessageMetadata, IConversation, MessageTag, SemanticRef, Topic, Knowledge, KnowledgeType, ITermToSemanticRefIndexData, ITermToSemanticRefIndexItem, ScoredSemanticRefOrdinal } from './knowpro/interfaces.js';
10
+ export type { KnowledgeResponse, ConcreteEntity, Action } from './knowpro/knowledgeSchema.js';
11
+ export type { TimestampIndexExtended } from './knowpro/timestampIndex.js';
12
+ export { createTimestampIndex, createTimestampIndexExtended, parseTemporalExpression, hasTemporalReference } from './knowpro/timestampIndex.js';
13
+ export * from './knowpro/llmProvider.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,CAAC;AAOvB,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,0BAA0B,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAC1I,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACvL,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC9F,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAChJ,cAAc,0BAA0B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,183 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { writeFileSync } from 'node:fs';
3
+ import { createConversation, loadConversationFromExport } from './knowpro/conversation.js';
4
+ import { createInMemoryStorageProvider } from './knowpro/storageProvider.js';
5
+ import 'dotenv/config';
6
+ import { createInterface } from 'node:readline/promises';
7
+ import { printAction, printEntity, printTopic } from './knowpro/entities.js';
8
+ // Public exports
9
+ export { createConversation, createMessage, loadConversationFromExport, loadConversationFromExportData } from './knowpro/conversation.js';
10
+ export { createInMemoryStorageProvider } from './knowpro/storageProvider.js';
11
+ export { createKnowledgeExtractor } from './knowpro/knowledge.js';
12
+ export { createTimestampIndex, createTimestampIndexExtended, parseTemporalExpression, hasTemporalReference } from './knowpro/timestampIndex.js';
13
+ export * from './knowpro/llmProvider.js';
14
+ const invokedDirectly = process.argv[1] === fileURLToPath(import.meta.url);
15
+ if (invokedDirectly) {
16
+ const inMemoryStorageProvider = createInMemoryStorageProvider();
17
+ const messages = inMemoryStorageProvider.createMessageCollection();
18
+ let conversation = await createConversation(messages, "test conversation", inMemoryStorageProvider);
19
+ if (!conversation.semanticRefIndex) {
20
+ console.log("No index found");
21
+ process.exit();
22
+ }
23
+ // console.log(conversation.semanticRefIndex.getTerms());
24
+ const readline = createInterface({
25
+ input: process.stdin
26
+ });
27
+ let quit = false;
28
+ console.log("starting repl...");
29
+ while (!quit) {
30
+ process.stdout.write("> ");
31
+ const query = await readline.question("> ");
32
+ if (query.includes("@entity")) {
33
+ const refs = conversation.semanticRefIndex?.lookupTerm(query.split(" ")[1]);
34
+ if (refs) {
35
+ refs.forEach((refOrdinal) => {
36
+ const ref = conversation.semanticRefs?.get(refOrdinal.semanticRefOrdinal);
37
+ if (ref && ref.knowledgeType === "entity") {
38
+ printEntity(ref.knowledge);
39
+ }
40
+ });
41
+ }
42
+ continue;
43
+ }
44
+ if (query.includes("@action")) {
45
+ const refs = conversation.semanticRefIndex?.lookupTerm(query.split(" ")[1]);
46
+ if (refs) {
47
+ refs.forEach((refOrdinal) => {
48
+ const ref = conversation.semanticRefs?.get(refOrdinal.semanticRefOrdinal);
49
+ if (ref && ref.knowledgeType === "action") {
50
+ printAction(ref.knowledge);
51
+ }
52
+ });
53
+ }
54
+ continue;
55
+ }
56
+ if (query.includes("@term")) {
57
+ const terms = query.split(" ").slice(1);
58
+ console.log(await conversation.queryTerms(terms));
59
+ continue;
60
+ }
61
+ if (query.includes("@topic")) {
62
+ const refs = conversation.semanticRefIndex?.lookupTerm(query.split(" ")[1]);
63
+ if (refs) {
64
+ refs.forEach((refOrdinal) => {
65
+ const ref = conversation.semanticRefs?.get(refOrdinal.semanticRefOrdinal);
66
+ if (ref && ref.knowledgeType === "topic") {
67
+ printTopic(ref.knowledge);
68
+ }
69
+ });
70
+ }
71
+ if (!refs) {
72
+ const refs = conversation.getAllTopics();
73
+ refs.forEach((ref) => {
74
+ printTopic(ref.knowledge);
75
+ });
76
+ }
77
+ continue;
78
+ }
79
+ if (query.startsWith("@load ")) {
80
+ const filePath = query.slice("@load ".length).trim();
81
+ if (!filePath) {
82
+ console.log("ERROR: Provide a file path after @load.");
83
+ continue;
84
+ }
85
+ conversation.loadFromFile(filePath);
86
+ console.log(`Loaded: ${filePath}`);
87
+ continue;
88
+ }
89
+ if (query.startsWith("@loadindex ")) {
90
+ const filePath = query.slice("@loadindex ".length).trim();
91
+ if (!filePath) {
92
+ console.log("ERROR: Provide a file path after @loadindex.");
93
+ continue;
94
+ }
95
+ try {
96
+ conversation = loadConversationFromExport(filePath);
97
+ console.log(`Index loaded from: ${filePath}`);
98
+ }
99
+ catch (e) {
100
+ console.log(`ERROR: Failed to load index: ${e}`);
101
+ }
102
+ continue;
103
+ }
104
+ if (query.startsWith("@export")) {
105
+ const outputPath = query.slice("@export".length).trim() || "fawn-index-export.json";
106
+ // Build index data
107
+ const semanticRefs = conversation.semanticRefs?.getAll() || [];
108
+ let indexData = { items: [] };
109
+ if (conversation.semanticRefIndex) {
110
+ const terms = conversation.semanticRefIndex.getTerms();
111
+ indexData = {
112
+ items: terms.map(term => ({
113
+ term,
114
+ semanticRefOrdinals: conversation.semanticRefIndex.lookupTerm(term) || []
115
+ }))
116
+ };
117
+ }
118
+ const messages = conversation.messages.getAll().map((msg, index) => ({
119
+ ordinal: index,
120
+ content: msg.textChunks.join(''),
121
+ timestamp: msg.timestamp
122
+ }));
123
+ const exportData = {
124
+ indexData,
125
+ semanticRefs,
126
+ messages,
127
+ stats: {
128
+ termCount: indexData.items.length,
129
+ refCount: semanticRefs.length,
130
+ messageCount: messages.length
131
+ }
132
+ };
133
+ writeFileSync(outputPath, JSON.stringify(exportData, null, 2));
134
+ console.log(`Exported to: ${outputPath}`);
135
+ console.log(` Terms: ${indexData.items.length}`);
136
+ console.log(` Semantic Refs: ${semanticRefs.length}`);
137
+ console.log(` Messages: ${messages.length}`);
138
+ continue;
139
+ }
140
+ if (query === "@lemmatize") {
141
+ const result = conversation.lemmatize();
142
+ console.log(`Lemmatization complete:`);
143
+ console.log(` Terms processed: ${result.termsProcessed}`);
144
+ console.log(` Lemmas added: ${result.lemmasAdded}`);
145
+ continue;
146
+ }
147
+ if (query.startsWith("@related")) {
148
+ const parts = query.split(" ");
149
+ const weight = parts[1] ? parseFloat(parts[1]) : 0.9;
150
+ const maxTerms = parts[2] ? parseInt(parts[2]) : undefined;
151
+ console.log(`Expanding related terms with LLM (weight: ${weight}${maxTerms ? `, maxTerms: ${maxTerms}` : ''})...`);
152
+ const result = await conversation.expandRelatedTerms({
153
+ relatedTermWeight: weight,
154
+ maxTerms
155
+ });
156
+ console.log(`Related terms expansion complete:`);
157
+ console.log(` Terms processed: ${result.termsProcessed}`);
158
+ console.log(` Related terms added: ${result.relatedTermsAdded}`);
159
+ continue;
160
+ }
161
+ if (query.startsWith("@wordnet")) {
162
+ const parts = query.split(" ");
163
+ const weight = parts[1] ? parseFloat(parts[1]) : 0.9;
164
+ const maxTerms = parts[2] ? parseInt(parts[2]) : undefined;
165
+ console.log(`Expanding related terms with WordNet (weight: ${weight}${maxTerms ? `, maxTerms: ${maxTerms}` : ''})...`);
166
+ const result = await conversation.expandWithWordNet({
167
+ relatedTermWeight: weight,
168
+ maxTerms
169
+ });
170
+ console.log(`WordNet expansion complete:`);
171
+ console.log(` Terms processed: ${result.termsProcessed}`);
172
+ console.log(` Related terms added: ${result.relatedTermsAdded}`);
173
+ continue;
174
+ }
175
+ if (query === 'quit' || query === 'exit') {
176
+ quit = true;
177
+ break;
178
+ }
179
+ console.log(await conversation.query(query));
180
+ }
181
+ readline.close();
182
+ }
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE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AK,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { DateRange } from "./interfaces.js";
2
+ export type AnswerContext = {
3
+ entities?: RelevantKnowledge[] | undefined;
4
+ topics?: RelevantKnowledge[] | undefined;
5
+ messages?: RelevantMessage[] | undefined;
6
+ };
7
+ export type EntityNames = string | string[];
8
+ export type RelevantKnowledge = {
9
+ knowledge: unknown;
10
+ origin?: EntityNames | undefined;
11
+ audience?: EntityNames | undefined;
12
+ timeRange?: DateRange | undefined;
13
+ };
14
+ export type RelevantMessage = {
15
+ from?: EntityNames | undefined;
16
+ to?: EntityNames | undefined;
17
+ timestamp?: Date | undefined;
18
+ messageText?: string | string[] | undefined;
19
+ };
20
+ //# sourceMappingURL=answerContextSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerContextSchema.d.ts","sourceRoot":"","sources":["../../src/knowpro/answerContextSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG;IAGxB,QAAQ,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAE3C,MAAM,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAEzC,QAAQ,CAAC,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG;IAE5B,SAAS,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAEjC,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAEnC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,EAAE,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE7B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/C,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=answerContextSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerContextSchema.js","sourceRoot":"","sources":["../../src/knowpro/answerContextSchema.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
@@ -0,0 +1,7 @@
1
+ export type AnswerType = "NoAnswer" | "Answered";
2
+ export type AnswerResponse = {
3
+ type: AnswerType;
4
+ answer?: string | undefined;
5
+ whyNoAnswer?: string;
6
+ };
7
+ //# sourceMappingURL=answerResponseSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerResponseSchema.d.ts","sourceRoot":"","sources":["../../src/knowpro/answerResponseSchema.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAChB,UAAU,GACV,UAAU,CAAC;AAEjB,MAAM,MAAM,cAAc,GAAG;IAEzB,IAAI,EAAE,UAAU,CAAC;IAEjB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAG5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=answerResponseSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerResponseSchema.js","sourceRoot":"","sources":["../../src/knowpro/answerResponseSchema.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
@@ -0,0 +1,5 @@
1
+ import type { TypeChatJsonTranslator, TypeChatLanguageModel } from "typechat";
2
+ import type * as answerSchema from "./answerResponseSchema.js";
3
+ export type AnswerTranslator = TypeChatJsonTranslator<answerSchema.AnswerResponse>;
4
+ export declare function createAnswerTranslator(model: TypeChatLanguageModel): AnswerTranslator;
5
+ //# sourceMappingURL=answerTranslator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerTranslator.d.ts","sourceRoot":"","sources":["../../src/knowpro/answerTranslator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE9E,OAAO,KAAK,KAAK,YAAY,MAAM,2BAA2B,CAAC;AAI/D,MAAM,MAAM,gBAAgB,GACxB,sBAAsB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AAExD,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,qBAAqB,GAC7B,gBAAgB,CAYlB"}
@@ -0,0 +1,10 @@
1
+ import { createJsonTranslator } from "typechat";
2
+ import { loadSchema } from "./schema.js";
3
+ import { createTypeScriptJsonValidator } from "typechat/ts";
4
+ export function createAnswerTranslator(model) {
5
+ const typeName = "AnswerResponse";
6
+ const schema = loadSchema(["answerResponseSchema.ts"], import.meta.url);
7
+ const translator = createJsonTranslator(model, createTypeScriptJsonValidator(schema, typeName));
8
+ return translator;
9
+ }
10
+ //# sourceMappingURL=answerTranslator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerTranslator.js","sourceRoot":"","sources":["../../src/knowpro/answerTranslator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAK5D,MAAM,UAAU,sBAAsB,CAClC,KAA4B;IAE5B,MAAM,QAAQ,GAAG,gBAAgB,CAAC;IAClC,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAExE,MAAM,UAAU,GAAG,oBAAoB,CACnC,KAAK,EACL,6BAA6B,CACzB,MAAM,EACN,QAAQ,CACX,CACJ,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { IMessage, IMessageCollection, ISemanticRefCollection } from "./interfaces.js";
2
+ export declare function createInMemoryCollection<T, TOrdinal>(createOrdinal?: (index: number, item: T) => TOrdinal): {
3
+ isPersistent: boolean;
4
+ readonly length: number;
5
+ get: (ordinal: TOrdinal) => T;
6
+ getMultiple: (ordinals: TOrdinal[]) => T[];
7
+ getSlice: (start: number, end: number) => T[];
8
+ getAll: () => T[];
9
+ append: (...items: T[]) => void;
10
+ [Symbol.iterator](): MapIterator<T>;
11
+ };
12
+ export declare function createMessageCollection<TMessage extends IMessage = IMessage>(): IMessageCollection<TMessage>;
13
+ export declare function createSemanticRefCollection(): ISemanticRefCollection;
14
+ //# sourceMappingURL=collections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/knowpro/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,sBAAsB,EAAmD,MAAM,iBAAiB,CAAC;AAE7I,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,QAAQ,EAChD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,QAAQ;;;mBAK9B,QAAQ,KAAG,CAAC;4BASH,QAAQ,EAAE,KAAG,CAAC,EAAE;sBAMtB,MAAM,OAAO,MAAM,KAAG,CAAC,EAAE;kBAI/B,CAAC,EAAE;uBAII,CAAC,EAAE,KAAG,IAAI;;EAuBvC;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,KAAK,kBAAkB,CAAC,QAAQ,CAAC,CAE5G;AAED,wBAAgB,2BAA2B,IAAI,sBAAsB,CAEpE"}
@@ -0,0 +1,52 @@
1
+ export function createInMemoryCollection(createOrdinal) {
2
+ const entries = new Map();
3
+ const order = [];
4
+ function get(ordinal) {
5
+ const value = entries.get(ordinal);
6
+ if (value === undefined) {
7
+ throw new RangeError(`No item at ordinal ${ordinal}`);
8
+ }
9
+ return value;
10
+ }
11
+ // could be optimized look at what ms team does
12
+ function getMultiple(ordinals) {
13
+ return ordinals.map((ordinal) => {
14
+ return get(ordinal);
15
+ });
16
+ }
17
+ function getSlice(start, end) {
18
+ return order.slice(start, end).map((ordinal) => entries.get(ordinal));
19
+ }
20
+ function getAll() {
21
+ return [...entries.values()];
22
+ }
23
+ function append(...items) {
24
+ items.forEach((value, idx) => {
25
+ // ask about this cast here
26
+ const ordinal = createOrdinal ? createOrdinal(idx, value) : order.length;
27
+ order.push(ordinal);
28
+ entries.set(ordinal, value);
29
+ });
30
+ }
31
+ return {
32
+ isPersistent: false,
33
+ get length() {
34
+ return order.length;
35
+ },
36
+ get,
37
+ getMultiple,
38
+ getSlice,
39
+ getAll,
40
+ append,
41
+ [Symbol.iterator]() {
42
+ return entries.values()[Symbol.iterator]();
43
+ }
44
+ };
45
+ }
46
+ export function createMessageCollection() {
47
+ return createInMemoryCollection();
48
+ }
49
+ export function createSemanticRefCollection() {
50
+ return createInMemoryCollection();
51
+ }
52
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/knowpro/collections.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB,CACpC,aAAoD;IAEpD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAe,CAAC;IACvC,MAAM,KAAK,GAAe,EAAE,CAAC;IAE7B,SAAS,GAAG,CAAC,OAAiB;QAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,MAA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AE,CAAC;QAC/C,CAAC;KACJ,CAAA;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB;IACnC,OAAO,wBAAwB,EAA4B,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,2BAA2B;IACvC,OAAO,wBAAwB,EAAmC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { DateRange, DeletionInfo, IConversation, IMessage, IMessageCollection, IMessageMetadata, MessageTag, SemanticRef } from "./interfaces.js";
2
+ import type { KnowledgeResponse } from "./knowledgeSchema.js";
3
+ import type { PromptSection } from 'typechat';
4
+ import { type LemmatizationResult, type RelatedTermsExpansionOptions, type RelatedTermsExpansionResult, type WordNetExpansionOptions } from "./semanticRefIndex.js";
5
+ import { type InMemoryStorageProvider } from "./storageProvider.js";
6
+ export interface Message extends IMessage {
7
+ setKnowledge: (knowledge: KnowledgeResponse) => void;
8
+ }
9
+ export declare function createMessage(content: string, tags: MessageTag[], timestamp?: string | undefined, deletionInfo?: DeletionInfo | undefined, metadata?: IMessageMetadata | undefined): Message;
10
+ export interface Conversation extends IConversation {
11
+ query: (question: string) => Promise<string>;
12
+ queryTerms: (terms: string[]) => Promise<string>;
13
+ getAllTopics: () => SemanticRef[];
14
+ addMessageAsync: (message: Message, rebuild?: boolean) => Promise<boolean>;
15
+ loadFromFile: (filePath: string, rebuild?: boolean) => void;
16
+ lemmatize: () => LemmatizationResult;
17
+ expandRelatedTerms: (options?: RelatedTermsExpansionOptions) => Promise<RelatedTermsExpansionResult>;
18
+ expandWithWordNet: (options?: WordNetExpansionOptions) => Promise<RelatedTermsExpansionResult>;
19
+ }
20
+ export declare function createConversation(messages: IMessageCollection<Message>, name: string, storageProvider: InMemoryStorageProvider): Conversation;
21
+ /**
22
+ * Returns the time range for a conversation: the timestamps of the first and last messages
23
+ * If messages have no timestamps (which are optional), returns undefined
24
+ * @param conversation
25
+ * @returns {DateRange}
26
+ */
27
+ export declare function getTimeRangeForConversation(conversation: IConversation): DateRange | undefined;
28
+ export declare function getTimeRangePromptSectionForConversation(conversation: IConversation): PromptSection[];
29
+ /**
30
+ * Exported index format (from @export command or benchmark export)
31
+ */
32
+ export interface ExportedIndex {
33
+ indexData: {
34
+ items: Array<{
35
+ term: string;
36
+ semanticRefOrdinals: Array<{
37
+ semanticRefOrdinal: number;
38
+ score: number;
39
+ }>;
40
+ }>;
41
+ };
42
+ semanticRefs: SemanticRef[];
43
+ messages: Array<{
44
+ ordinal: number;
45
+ content: string;
46
+ timestamp?: string;
47
+ }>;
48
+ stats?: {
49
+ termCount: number;
50
+ refCount: number;
51
+ messageCount: number;
52
+ };
53
+ }
54
+ /**
55
+ * Load a conversation from an exported index JSON file.
56
+ * This allows querying a pre-built index without re-extracting knowledge.
57
+ */
58
+ export declare function loadConversationFromExport(exportPath: string, name?: string): Conversation;
59
+ /**
60
+ * Load a conversation from exported index data.
61
+ */
62
+ export declare function loadConversationFromExportData(exported: ExportedIndex, name?: string): Conversation;
63
+ //# sourceMappingURL=conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/knowpro/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAiC,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtL,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAiE,KAAK,mBAAmB,EAAE,KAAK,4BAA4B,EAAE,KAAK,2BAA2B,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGnO,OAAO,EAAiC,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AASnG,MAAM,WAAW,OAAQ,SAAQ,QAAQ;IACrC,YAAY,EAAE,CAAC,SAAS,E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