@tanstack/ai-groq 0.4.16 → 0.5.0
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/dist/esm/adapters/transcription.d.ts +80 -0
- package/dist/esm/adapters/transcription.js +179 -0
- package/dist/esm/adapters/transcription.js.map +1 -0
- package/dist/esm/adapters/tts.d.ts +81 -0
- package/dist/esm/adapters/tts.js +73 -0
- package/dist/esm/adapters/tts.js.map +1 -0
- package/dist/esm/audio/audio-provider-options.d.ts +20 -0
- package/dist/esm/audio/audio-provider-options.js +9 -0
- package/dist/esm/audio/audio-provider-options.js.map +1 -0
- package/dist/esm/audio/transcription-provider-options.d.ts +19 -0
- package/dist/esm/audio/tts-provider-options.d.ts +30 -0
- package/dist/esm/index.d.ts +7 -3
- package/dist/esm/index.js +12 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model-meta.d.ts +25 -2
- package/dist/esm/model-meta.js +17 -1
- package/dist/esm/model-meta.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/transcription.ts +334 -0
- package/src/adapters/tts.ts +168 -0
- package/src/audio/audio-provider-options.ts +25 -0
- package/src/audio/transcription-provider-options.ts +20 -0
- package/src/audio/tts-provider-options.ts +48 -0
- package/src/index.ts +34 -2
- package/src/model-meta.ts +74 -4
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Groq TTS voice options for English models
|
|
3
|
+
*/
|
|
4
|
+
export type GroqTTSEnglishVoice =
|
|
5
|
+
| 'autumn'
|
|
6
|
+
| 'diana'
|
|
7
|
+
| 'hannah'
|
|
8
|
+
| 'austin'
|
|
9
|
+
| 'daniel'
|
|
10
|
+
| 'troy'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Groq TTS voice options for Arabic models
|
|
14
|
+
*/
|
|
15
|
+
export type GroqTTSArabicVoice = 'fahad' | 'sultan' | 'lulwa' | 'noura'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Union of all Groq TTS voice options
|
|
19
|
+
*/
|
|
20
|
+
export type GroqTTSVoice = GroqTTSEnglishVoice | GroqTTSArabicVoice
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Groq TTS output format options.
|
|
24
|
+
*/
|
|
25
|
+
export type GroqTTSFormat = 'flac' | 'mp3' | 'mulaw' | 'ogg' | 'wav'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Groq TTS sample rate options
|
|
29
|
+
*/
|
|
30
|
+
export type GroqTTSSampleRate =
|
|
31
|
+
| 8000
|
|
32
|
+
| 16000
|
|
33
|
+
| 22050
|
|
34
|
+
| 24000
|
|
35
|
+
| 32000
|
|
36
|
+
| 44100
|
|
37
|
+
| 48000
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Provider-specific options for Groq TTS.
|
|
41
|
+
* These options are passed via `modelOptions` when calling `generateSpeech`.
|
|
42
|
+
*/
|
|
43
|
+
export interface GroqTTSProviderOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The sample rate of the generated audio in Hz.
|
|
46
|
+
*/
|
|
47
|
+
sample_rate?: GroqTTSSampleRate
|
|
48
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module @tanstack/ai-groq
|
|
3
3
|
*
|
|
4
4
|
* Groq provider adapter for TanStack AI.
|
|
5
|
-
* Provides tree-shakeable adapters for Groq's Chat Completions API.
|
|
5
|
+
* Provides tree-shakeable adapters for Groq's Chat Completions API and TTS API.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// Text (Chat) adapter
|
|
@@ -14,16 +14,48 @@ export {
|
|
|
14
14
|
type GroqTextProviderOptions,
|
|
15
15
|
} from './adapters/text'
|
|
16
16
|
|
|
17
|
+
// Transcription adapter
|
|
18
|
+
export {
|
|
19
|
+
GroqTranscriptionAdapter,
|
|
20
|
+
createGroqTranscription,
|
|
21
|
+
groqTranscription,
|
|
22
|
+
type GroqTranscriptionConfig,
|
|
23
|
+
} from './adapters/transcription'
|
|
24
|
+
export type { GroqTranscriptionProviderOptions } from './audio/transcription-provider-options'
|
|
25
|
+
|
|
26
|
+
// TTS adapter - for text-to-speech
|
|
27
|
+
export {
|
|
28
|
+
GroqTTSAdapter,
|
|
29
|
+
createGroqSpeech,
|
|
30
|
+
groqSpeech,
|
|
31
|
+
type GroqTTSConfig,
|
|
32
|
+
} from './adapters/tts'
|
|
33
|
+
export type {
|
|
34
|
+
GroqTTSProviderOptions,
|
|
35
|
+
GroqTTSVoice,
|
|
36
|
+
GroqTTSEnglishVoice,
|
|
37
|
+
GroqTTSArabicVoice,
|
|
38
|
+
GroqTTSFormat,
|
|
39
|
+
GroqTTSSampleRate,
|
|
40
|
+
} from './audio/tts-provider-options'
|
|
41
|
+
|
|
17
42
|
// Types
|
|
18
43
|
export type {
|
|
19
44
|
GroqChatModelProviderOptionsByName,
|
|
45
|
+
GroqTTSModelProviderOptionsByName,
|
|
20
46
|
GroqChatModelToolCapabilitiesByName,
|
|
21
47
|
GroqModelInputModalitiesByName,
|
|
22
48
|
ResolveProviderOptions,
|
|
23
49
|
ResolveInputModalities,
|
|
24
50
|
GroqChatModels,
|
|
51
|
+
GroqTranscriptionModel,
|
|
52
|
+
GroqTTSModel,
|
|
53
|
+
} from './model-meta'
|
|
54
|
+
export {
|
|
55
|
+
GROQ_CHAT_MODELS,
|
|
56
|
+
GROQ_TRANSCRIPTION_MODELS,
|
|
57
|
+
GROQ_TTS_MODELS,
|
|
25
58
|
} from './model-meta'
|
|
26
|
-
export { GROQ_CHAT_MODELS } from './model-meta'
|
|
27
59
|
export type {
|
|
28
60
|
GroqTextMetadata,
|
|
29
61
|
GroqImageMetadata,
|
package/src/model-meta.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GroqTextProviderOptions } from './text/text-provider-options'
|
|
2
|
+
import type { GroqTTSProviderOptions } from './audio/tts-provider-options'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Internal metadata structure describing a Groq model's capabilities and pricing.
|
|
@@ -385,14 +386,23 @@ export type GroqChatModelToolCapabilitiesByName = {
|
|
|
385
386
|
[QWEN3_32B.name]: typeof QWEN3_32B.supports.tools
|
|
386
387
|
}
|
|
387
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Type-only map from Groq TTS model name to its provider options type.
|
|
391
|
+
*/
|
|
392
|
+
export type GroqTTSModelProviderOptionsByName = {
|
|
393
|
+
[K in GroqTTSModel]: GroqTTSProviderOptions
|
|
394
|
+
}
|
|
395
|
+
|
|
388
396
|
/**
|
|
389
397
|
* Resolves the provider options type for a specific Groq model.
|
|
390
|
-
*
|
|
398
|
+
* Checks TTS models first, then chat models, then falls back to generic options.
|
|
391
399
|
*/
|
|
392
400
|
export type ResolveProviderOptions<TModel extends string> =
|
|
393
|
-
TModel extends
|
|
394
|
-
?
|
|
395
|
-
:
|
|
401
|
+
TModel extends GroqTTSModel
|
|
402
|
+
? GroqTTSProviderOptions
|
|
403
|
+
: TModel extends keyof GroqChatModelProviderOptionsByName
|
|
404
|
+
? GroqChatModelProviderOptionsByName[TModel]
|
|
405
|
+
: GroqTextProviderOptions
|
|
396
406
|
|
|
397
407
|
/**
|
|
398
408
|
* Resolve input modalities for a specific model.
|
|
@@ -402,3 +412,63 @@ export type ResolveInputModalities<TModel extends string> =
|
|
|
402
412
|
TModel extends keyof GroqModelInputModalitiesByName
|
|
403
413
|
? GroqModelInputModalitiesByName[TModel]
|
|
404
414
|
: readonly ['text']
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* All supported Groq transcription model identifiers.
|
|
418
|
+
*/
|
|
419
|
+
export const GROQ_TRANSCRIPTION_MODELS = [
|
|
420
|
+
'whisper-large-v3-turbo',
|
|
421
|
+
'whisper-large-v3',
|
|
422
|
+
] as const
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Union type of all supported Groq transcription model names.
|
|
426
|
+
*/
|
|
427
|
+
export type GroqTranscriptionModel = (typeof GROQ_TRANSCRIPTION_MODELS)[number]
|
|
428
|
+
|
|
429
|
+
// ============================================================================
|
|
430
|
+
// TTS Models
|
|
431
|
+
// ============================================================================
|
|
432
|
+
|
|
433
|
+
const ORPHEUS_V1_ENGLISH = {
|
|
434
|
+
name: 'canopylabs/orpheus-v1-english',
|
|
435
|
+
pricing: {
|
|
436
|
+
input: {
|
|
437
|
+
normal: 22,
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
supports: {
|
|
441
|
+
input: ['text'],
|
|
442
|
+
output: ['audio'],
|
|
443
|
+
endpoints: ['tts'],
|
|
444
|
+
features: [],
|
|
445
|
+
},
|
|
446
|
+
} as const satisfies ModelMeta<GroqTTSProviderOptions>
|
|
447
|
+
|
|
448
|
+
const ORPHEUS_ARABIC_SAUDI = {
|
|
449
|
+
name: 'canopylabs/orpheus-arabic-saudi',
|
|
450
|
+
pricing: {
|
|
451
|
+
input: {
|
|
452
|
+
normal: 40,
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
supports: {
|
|
456
|
+
input: ['text'],
|
|
457
|
+
output: ['audio'],
|
|
458
|
+
endpoints: ['tts'],
|
|
459
|
+
features: [],
|
|
460
|
+
},
|
|
461
|
+
} as const satisfies ModelMeta<GroqTTSProviderOptions>
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* All supported Groq TTS model identifiers.
|
|
465
|
+
*/
|
|
466
|
+
export const GROQ_TTS_MODELS = [
|
|
467
|
+
ORPHEUS_V1_ENGLISH.name,
|
|
468
|
+
ORPHEUS_ARABIC_SAUDI.name,
|
|
469
|
+
] as const
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Union type of all supported Groq TTS model names.
|
|
473
|
+
*/
|
|
474
|
+
export type GroqTTSModel = (typeof GROQ_TTS_MODELS)[number]
|