@startsimpli/integrations 0.1.5 → 0.1.6
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/package.json +1 -1
- package/src/__tests__/corpus-copy.test.tsx +196 -0
- package/src/__tests__/corpus-storage.test.ts +301 -0
- package/src/components/Markdown.tsx +193 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/AskPage.tsx +33 -8
- package/src/components/pages/LibraryPage.tsx +10 -2
- package/src/corpus/client.ts +121 -14
- package/src/corpus/entities.ts +154 -5
- package/src/corpus/fixtures.ts +426 -186
- package/src/corpus/index.ts +11 -1
- package/src/corpus/llm.ts +27 -1
package/src/corpus/index.ts
CHANGED
|
@@ -32,7 +32,10 @@ export type {
|
|
|
32
32
|
} from './types';
|
|
33
33
|
|
|
34
34
|
export {
|
|
35
|
+
DEFAULT_PARTICIPANT_EDGES,
|
|
35
36
|
DEFAULT_TYPE_KEYS,
|
|
37
|
+
indexParticipants,
|
|
38
|
+
mergeParticipants,
|
|
36
39
|
moneyEventAsDocument,
|
|
37
40
|
scopeOf,
|
|
38
41
|
toMoneyEvent,
|
|
@@ -41,7 +44,7 @@ export {
|
|
|
41
44
|
toSections,
|
|
42
45
|
toSourceDocument,
|
|
43
46
|
} from './entities';
|
|
44
|
-
export type { CorpusTypeKeys, TenantEntity } from './entities';
|
|
47
|
+
export type { CorpusTypeKeys, TenantEntity, TenantRelationship } from './entities';
|
|
45
48
|
|
|
46
49
|
export {
|
|
47
50
|
enforceScope,
|
|
@@ -68,12 +71,19 @@ export type { CorpusHttp, CreateCorpusApiOptions } from './client';
|
|
|
68
71
|
|
|
69
72
|
export {
|
|
70
73
|
createFixtureCorpusApi,
|
|
74
|
+
createFixtureCorpusHttp,
|
|
71
75
|
createFixtureLlm,
|
|
72
76
|
FIXTURE_DOCUMENTS,
|
|
73
77
|
FIXTURE_MONEY_EVENTS,
|
|
74
78
|
FIXTURE_ORG,
|
|
75
79
|
FIXTURE_OTHER_ORG,
|
|
80
|
+
FIXTURE_PARTICIPANTS,
|
|
76
81
|
FIXTURE_PARTIES,
|
|
82
|
+
FIXTURE_SOURCE_LABELS,
|
|
77
83
|
FIXTURE_SOURCES,
|
|
84
|
+
FIXTURE_TENANT_DOCUMENTS,
|
|
85
|
+
FIXTURE_TENANT_MONEY_EVENTS,
|
|
86
|
+
FIXTURE_TENANT_PARTIES,
|
|
87
|
+
FIXTURE_TENANT_RELATIONSHIPS,
|
|
78
88
|
} from './fixtures';
|
|
79
89
|
export type { FixtureCorpusOptions } from './fixtures';
|
package/src/corpus/llm.ts
CHANGED
|
@@ -27,6 +27,26 @@ export interface CorpusLlmOptions {
|
|
|
27
27
|
model?: string;
|
|
28
28
|
temperature?: number;
|
|
29
29
|
maxTokens?: number;
|
|
30
|
+
/** Injectable environment, so the configured-model lookup is testable. */
|
|
31
|
+
env?: Record<string, string | undefined>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The model this deployment CONFIGURED for a provider, from its own environment.
|
|
36
|
+
*
|
|
37
|
+
* Only used until a real response reports its own model — see `describe()`.
|
|
38
|
+
* Provider-specific first (`OPENAI_MODEL`), then the provider-agnostic
|
|
39
|
+
* `LLM_MODEL`, because a tenant that sets both means the specific one.
|
|
40
|
+
*/
|
|
41
|
+
export function configuredModel(
|
|
42
|
+
provider: string,
|
|
43
|
+
env: Record<string, string | undefined> = typeof process !== 'undefined' ? process.env : {},
|
|
44
|
+
): string {
|
|
45
|
+
const specific: Record<string, string | undefined> = {
|
|
46
|
+
openai: env.OPENAI_MODEL,
|
|
47
|
+
anthropic: env.ANTHROPIC_MODEL,
|
|
48
|
+
};
|
|
49
|
+
return (specific[provider] || env.LLM_MODEL || '').trim();
|
|
30
50
|
}
|
|
31
51
|
|
|
32
52
|
/**
|
|
@@ -139,13 +159,19 @@ export function createCorpusLlm(options: CorpusLlmOptions = {}): CorpusLlm {
|
|
|
139
159
|
});
|
|
140
160
|
|
|
141
161
|
let lastModel = options.model ?? '';
|
|
162
|
+
const env = options.env ?? (typeof process !== 'undefined' ? process.env : {});
|
|
142
163
|
|
|
143
164
|
const describe = (): LlmDescription => {
|
|
144
165
|
const available = service.getAvailableProviders();
|
|
145
166
|
const provider = available[0] ?? 'none';
|
|
167
|
+
// WHAT ANSWERED beats WHAT WAS CONFIGURED, always — but before the first
|
|
168
|
+
// call there is no "what answered", and `(provider default)` is a string
|
|
169
|
+
// dressed up as a fact. The tenant's own OPENAI_MODEL is the honest answer
|
|
170
|
+
// to "which model will run", so it is named until a response overrides it
|
|
171
|
+
// (bd startsim-768w.38.21).
|
|
146
172
|
return {
|
|
147
173
|
provider,
|
|
148
|
-
model: lastModel || options.model ||
|
|
174
|
+
model: lastModel || options.model || configuredModel(provider, env) || '',
|
|
149
175
|
live: provider !== 'none' && provider !== 'mock',
|
|
150
176
|
};
|
|
151
177
|
};
|