@startsimpli/integrations 0.2.55 → 0.2.56
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.56",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"react-dom": "^19.0.0",
|
|
65
65
|
"typescript": "^6.0.0",
|
|
66
66
|
"vitest": "^3.0.0",
|
|
67
|
-
"@startsimpli/
|
|
68
|
-
"@startsimpli/
|
|
67
|
+
"@startsimpli/llm": "0.4.28",
|
|
68
|
+
"@startsimpli/ui": "0.4.165"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"type-check": "tsc --noEmit",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { voiceAnalyzerDefaults } from '../corpus/llm';
|
|
4
|
+
|
|
5
|
+
describe('which model analyses a voice note', () => {
|
|
6
|
+
it('defaults to the cheap one that passed the golden eval (OpenAI gpt-4o-mini)', () => {
|
|
7
|
+
expect(voiceAnalyzerDefaults({})).toEqual({ preferredProvider: 'openai', model: 'gpt-4o-mini' });
|
|
8
|
+
});
|
|
9
|
+
it('is configurable per deployment without a code change', () => {
|
|
10
|
+
expect(voiceAnalyzerDefaults({ VOICE_ANALYZER_PROVIDER: 'anthropic', VOICE_ANALYZER_MODEL: 'claude-haiku-5-5' }))
|
|
11
|
+
.toEqual({ preferredProvider: 'anthropic', model: 'claude-haiku-5-5' });
|
|
12
|
+
});
|
|
13
|
+
it('an explicit option beats the environment', () => {
|
|
14
|
+
expect(voiceAnalyzerDefaults({ VOICE_ANALYZER_MODEL: 'x' }, { model: 'y', preferredProvider: 'mock' }))
|
|
15
|
+
.toEqual({ preferredProvider: 'mock', model: 'y' });
|
|
16
|
+
});
|
|
17
|
+
it('ignores blank env values', () => {
|
|
18
|
+
expect(voiceAnalyzerDefaults({ VOICE_ANALYZER_PROVIDER: ' ', VOICE_ANALYZER_MODEL: '' }))
|
|
19
|
+
.toEqual({ preferredProvider: 'openai', model: 'gpt-4o-mini' });
|
|
20
|
+
});
|
|
21
|
+
it('with only an Anthropic key present, uses Anthropic with ITS default model (never an OpenAI model name)', () => {
|
|
22
|
+
expect(voiceAnalyzerDefaults({ ANTHROPIC_API_KEY: 'a' })).toEqual({ preferredProvider: 'anthropic', model: '' });
|
|
23
|
+
});
|
|
24
|
+
it('with both keys present the cheap OpenAI default stays', () => {
|
|
25
|
+
expect(voiceAnalyzerDefaults({ ANTHROPIC_API_KEY: 'a', OPENAI_API_KEY: 'o' }))
|
|
26
|
+
.toEqual({ preferredProvider: 'openai', model: 'gpt-4o-mini' });
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/corpus/llm.ts
CHANGED
|
@@ -525,14 +525,39 @@ export function stripPlaceholderOwners(summary: string): string {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Which provider/model analyses a voice note. DEFAULTS TO THE CHEAP ONE: the
|
|
530
|
+
* golden eval passed on OpenAI gpt-4o-mini (recall 1.00, ~$0.00012 a note), and
|
|
531
|
+
* the Anthropic default would cost roughly 20x that for the same job. Override
|
|
532
|
+
* per deployment with VOICE_ANALYZER_PROVIDER / VOICE_ANALYZER_MODEL; an explicit
|
|
533
|
+
* option beats the environment.
|
|
534
|
+
*/
|
|
535
|
+
export function voiceAnalyzerDefaults(
|
|
536
|
+
env: Record<string, string | undefined> = typeof process !== 'undefined' ? process.env : {},
|
|
537
|
+
options: { preferredProvider?: 'openai' | 'anthropic' | 'mock'; model?: string } = {},
|
|
538
|
+
): { preferredProvider: 'openai' | 'anthropic' | 'mock'; model: string } {
|
|
539
|
+
const clean = (value?: string) => (value ?? '').trim();
|
|
540
|
+
// Only an Anthropic key: use Anthropic and ITS default model — an OpenAI model
|
|
541
|
+
// name sent to Anthropic is an API error, not a cheaper call.
|
|
542
|
+
const onlyAnthropic = !clean(env.OPENAI_API_KEY) && Boolean(clean(env.ANTHROPIC_API_KEY));
|
|
543
|
+
const provider = (clean(env.VOICE_ANALYZER_PROVIDER) || (onlyAnthropic ? 'anthropic' : 'openai')) as
|
|
544
|
+
'openai' | 'anthropic' | 'mock';
|
|
545
|
+
const defaultModel = provider === 'openai' ? 'gpt-4o-mini' : '';
|
|
546
|
+
return {
|
|
547
|
+
preferredProvider: options.preferredProvider ?? provider,
|
|
548
|
+
model: options.model ?? (clean(env.VOICE_ANALYZER_MODEL) || defaultModel),
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
528
552
|
export function createVoiceAnalyzer(
|
|
529
553
|
options: CorpusLlmOptions & { nonce?: () => string } = {},
|
|
530
554
|
): VoiceAnalyzer {
|
|
555
|
+
const defaults = voiceAnalyzerDefaults(options.env, options);
|
|
531
556
|
const service =
|
|
532
557
|
options.service ??
|
|
533
558
|
new LLMService<unknown>({
|
|
534
|
-
preferredProvider:
|
|
535
|
-
defaultModel:
|
|
559
|
+
preferredProvider: defaults.preferredProvider,
|
|
560
|
+
defaultModel: defaults.model,
|
|
536
561
|
defaultTemperature: options.temperature ?? 0.2,
|
|
537
562
|
defaultMaxTokens: options.maxTokens ?? 1500,
|
|
538
563
|
});
|