@tanstack/ai-groq 0.5.3 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"tts.js","sources":["../../../src/adapters/tts.ts"],"sourcesContent":["import OpenAI from 'openai'\nimport { BaseTTSAdapter } from '@tanstack/ai/adapters'\nimport { toRunErrorPayload } from '@tanstack/ai/adapter-internals'\nimport { arrayBufferToBase64, generateId } from '@tanstack/ai-utils'\nimport { getGroqApiKeyFromEnv, withGroqDefaults } from '../utils/client'\nimport { validateAudioInput } from '../audio/audio-provider-options'\nimport type { TTSOptions, TTSResult } from '@tanstack/ai'\nimport type OpenAI_SDK from 'openai'\nimport type { GroqTTSModel } from '../model-meta'\nimport type { GroqTTSProviderOptions } from '../audio/tts-provider-options'\nimport type { GroqClientConfig } from '../utils/client'\n\n/**\n * Configuration for Groq TTS adapter\n */\nexport interface GroqTTSConfig extends GroqClientConfig {}\n\n/**\n * Groq Text-to-Speech Adapter\n *\n * Tree-shakeable adapter for Groq TTS functionality. Groq exposes an\n * OpenAI-compatible `/audio/speech` endpoint, so the adapter drives it with\n * the OpenAI SDK via a `baseURL` override (the same pattern as the Groq text\n * adapter).\n *\n * Supports `canopylabs/orpheus-v1-english` and\n * `canopylabs/orpheus-arabic-saudi`.\n *\n * Features:\n * - English voices: autumn(f), diana(f), hannah(f), austin(m), daniel(m), troy(m)\n * - Arabic voices: fahad(m), sultan(m), lulwa(f), noura(f)\n * - Output formats: flac, mp3, mulaw, ogg, wav (default wav)\n * - Speed control\n * - Configurable sample rate via `modelOptions`\n */\nexport class GroqTTSAdapter<TModel extends GroqTTSModel> extends BaseTTSAdapter<\n TModel,\n GroqTTSProviderOptions\n> {\n readonly name = 'groq' as const\n\n protected client: OpenAI\n\n constructor(config: GroqTTSConfig, model: TModel) {\n super(model, {})\n this.client = new OpenAI(withGroqDefaults(config))\n }\n\n async generateSpeech(\n options: TTSOptions<GroqTTSProviderOptions>,\n ): Promise<TTSResult> {\n const { model, text, voice, format, speed, modelOptions } = options\n\n validateAudioInput({ input: text, model: this.model })\n\n // Spreading optional inputs conditionally keeps the request compatible\n // with the vendor SDK shape under exactOptionalPropertyTypes. `sample_rate`\n // is a Groq-only body field carried via modelOptions.\n const request: OpenAI_SDK.Audio.SpeechCreateParams = {\n model,\n input: text,\n voice: voice ?? 'autumn',\n response_format: format ?? 'wav',\n ...(speed !== undefined && { speed }),\n ...(modelOptions ?? {}),\n }\n\n try {\n options.logger.request(\n `activity=tts provider=${this.name} model=${model} format=${request.response_format ?? 'default'} voice=${request.voice}`,\n { provider: this.name, model },\n )\n const response = await this.client.audio.speech.create(request)\n\n const arrayBuffer = await response.arrayBuffer()\n const base64 = arrayBufferToBase64(arrayBuffer)\n\n const outputFormat = request.response_format ?? 'wav'\n const contentType = this.getContentType(outputFormat)\n\n return {\n id: generateId(this.name),\n model,\n audio: base64,\n format: outputFormat,\n contentType,\n }\n } catch (error: unknown) {\n // Narrow before logging: raw SDK errors can carry request metadata\n // (including auth headers) which we must never surface to user loggers.\n options.logger.errors(`${this.name}.generateSpeech fatal`, {\n error: toRunErrorPayload(error, `${this.name}.generateSpeech failed`),\n source: `${this.name}.generateSpeech`,\n })\n throw error\n }\n }\n\n private getContentType(format: string): string {\n const contentTypes: Record<string, string> = {\n flac: 'audio/flac',\n mp3: 'audio/mpeg',\n mulaw: 'audio/basic',\n ogg: 'audio/ogg',\n wav: 'audio/wav',\n }\n return contentTypes[format] || 'audio/wav'\n }\n}\n\n/**\n * Creates a Groq speech adapter with explicit API key.\n * Type resolution happens here at the call site.\n *\n * @param model - The model name (e.g., 'canopylabs/orpheus-v1-english')\n * @param apiKey - Your Groq API key\n * @param config - Optional additional configuration\n * @returns Configured Groq speech adapter instance with resolved types\n *\n * @example\n * ```typescript\n * const adapter = createGroqSpeech('canopylabs/orpheus-v1-english', 'gsk_...')\n *\n * const result = await generateSpeech({\n * adapter,\n * text: 'Hello, world!',\n * voice: 'autumn',\n * })\n * ```\n */\nexport function createGroqSpeech<TModel extends GroqTTSModel>(\n model: TModel,\n apiKey: string,\n config?: Omit<GroqTTSConfig, 'apiKey'>,\n): GroqTTSAdapter<TModel> {\n return new GroqTTSAdapter({ apiKey, ...config }, model)\n}\n\n/**\n * Creates a Groq speech adapter with automatic API key detection from\n * environment variables.\n *\n * Looks for `GROQ_API_KEY` in the environment.\n *\n * @param model - The model name (e.g., 'canopylabs/orpheus-v1-english')\n * @param config - Optional configuration (excluding apiKey which is auto-detected)\n * @returns Configured Groq speech adapter instance with resolved types\n * @throws Error if GROQ_API_KEY is not found in environment\n *\n * @example\n * ```typescript\n * const adapter = groqSpeech('canopylabs/orpheus-v1-english')\n *\n * const result = await generateSpeech({\n * adapter,\n * text: 'Welcome to TanStack AI!',\n * voice: 'autumn',\n * format: 'wav',\n * })\n * ```\n */\nexport function groqSpeech<TModel extends GroqTTSModel>(\n model: TModel,\n config?: Omit<GroqTTSConfig, 'apiKey'>,\n): GroqTTSAdapter<TModel> {\n const apiKey = getGroqApiKeyFromEnv()\n return createGroqSpeech(model, apiKey, config)\n}\n"],"names":[],"mappings":";;;;;;AAmCO,MAAM,uBAAoD,eAG/D;AAAA,EACS,OAAO;AAAA,EAEN;AAAA,EAEV,YAAY,QAAuB,OAAe;AAChD,UAAM,OAAO,EAAE;AACf,SAAK,SAAS,IAAI,OAAO,iBAAiB,MAAM,CAAC;AAAA,EACnD;AAAA,EAEA,MAAM,eACJ,SACoB;AACpB,UAAM,EAAE,OAAO,MAAM,OAAO,QAAQ,OAAO,iBAAiB;AAE5D,uBAAmB,EAAE,OAAO,MAAM,OAAO,KAAK,OAAO;AAKrD,UAAM,UAA+C;AAAA,MACnD;AAAA,MACA,OAAO;AAAA,MACP,OAAO,SAAS;AAAA,MAChB,iBAAiB,UAAU;AAAA,MAC3B,GAAI,UAAU,UAAa,EAAE,MAAA;AAAA,MAC7B,GAAI,gBAAgB,CAAA;AAAA,IAAC;AAGvB,QAAI;AACF,cAAQ,OAAO;AAAA,QACb,yBAAyB,KAAK,IAAI,UAAU,KAAK,WAAW,QAAQ,mBAAmB,SAAS,UAAU,QAAQ,KAAK;AAAA,QACvH,EAAE,UAAU,KAAK,MAAM,MAAA;AAAA,MAAM;AAE/B,YAAM,WAAW,MAAM,KAAK,OAAO,MAAM,OAAO,OAAO,OAAO;AAE9D,YAAM,cAAc,MAAM,SAAS,YAAA;AACnC,YAAM,SAAS,oBAAoB,WAAW;AAE9C,YAAM,eAAe,QAAQ,mBAAmB;AAChD,YAAM,cAAc,KAAK,eAAe,YAAY;AAEpD,aAAO;AAAA,QACL,IAAI,WAAW,KAAK,IAAI;AAAA,QACxB;AAAA,QACA,OAAO;AAAA,QACP,QAAQ;AAAA,QACR;AAAA,MAAA;AAAA,IAEJ,SAAS,OAAgB;AAGvB,cAAQ,OAAO,OAAO,GAAG,KAAK,IAAI,yBAAyB;AAAA,QACzD,OAAO,kBAAkB,OAAO,GAAG,KAAK,IAAI,wBAAwB;AAAA,QACpE,QAAQ,GAAG,KAAK,IAAI;AAAA,MAAA,CACrB;AACD,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEQ,eAAe,QAAwB;AAC7C,UAAM,eAAuC;AAAA,MAC3C,MAAM;AAAA,MACN,KAAK;AAAA,MACL,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,IAAA;AAEP,WAAO,aAAa,MAAM,KAAK;AAAA,EACjC;AACF;AAsBO,SAAS,iBACd,OACA,QACA,QACwB;AACxB,SAAO,IAAI,eAAe,EAAE,QAAQ,GAAG,OAAA,GAAU,KAAK;AACxD;AAyBO,SAAS,WACd,OACA,QACwB;AACxB,QAAM,SAAS,qBAAA;AACf,SAAO,iBAAiB,OAAO,QAAQ,MAAM;AAC/C;"}
1
+ {"version":3,"file":"tts.js","names":[],"sources":["../../../src/adapters/tts.ts"],"sourcesContent":["import OpenAI from 'openai'\nimport { BaseTTSAdapter } from '@tanstack/ai/adapters'\nimport { toRunErrorPayload } from '@tanstack/ai/adapter-internals'\nimport { arrayBufferToBase64, generateId } from '@tanstack/ai-utils'\nimport { getGroqApiKeyFromEnv, withGroqDefaults } from '../utils/client'\nimport { validateAudioInput } from '../audio/audio-provider-options'\nimport type { TTSOptions, TTSResult } from '@tanstack/ai'\nimport type OpenAI_SDK from 'openai'\nimport type { GroqTTSModel } from '../model-meta'\nimport type { GroqTTSProviderOptions } from '../audio/tts-provider-options'\nimport type { GroqClientConfig } from '../utils/client'\n\n/**\n * Configuration for Groq TTS adapter\n */\nexport interface GroqTTSConfig extends GroqClientConfig {}\n\n/**\n * Groq Text-to-Speech Adapter\n *\n * Tree-shakeable adapter for Groq TTS functionality. Groq exposes an\n * OpenAI-compatible `/audio/speech` endpoint, so the adapter drives it with\n * the OpenAI SDK via a `baseURL` override (the same pattern as the Groq text\n * adapter).\n *\n * Supports `canopylabs/orpheus-v1-english` and\n * `canopylabs/orpheus-arabic-saudi`.\n *\n * Features:\n * - English voices: autumn(f), diana(f), hannah(f), austin(m), daniel(m), troy(m)\n * - Arabic voices: fahad(m), sultan(m), lulwa(f), noura(f)\n * - Output formats: flac, mp3, mulaw, ogg, wav (default wav)\n * - Speed control\n * - Configurable sample rate via `modelOptions`\n */\nexport class GroqTTSAdapter<TModel extends GroqTTSModel> extends BaseTTSAdapter<\n TModel,\n GroqTTSProviderOptions\n> {\n readonly name = 'groq' as const\n\n protected client: OpenAI\n\n constructor(config: GroqTTSConfig, model: TModel) {\n super(model, {})\n this.client = new OpenAI(withGroqDefaults(config))\n }\n\n async generateSpeech(\n options: TTSOptions<GroqTTSProviderOptions>,\n ): Promise<TTSResult> {\n const { model, text, voice, format, speed, modelOptions } = options\n\n validateAudioInput({ input: text, model: this.model })\n\n // Spreading optional inputs conditionally keeps the request compatible\n // with the vendor SDK shape under exactOptionalPropertyTypes. `sample_rate`\n // is a Groq-only body field carried via modelOptions.\n const request: OpenAI_SDK.Audio.SpeechCreateParams = {\n model,\n input: text,\n voice: voice ?? 'autumn',\n response_format: format ?? 'wav',\n ...(speed !== undefined && { speed }),\n ...(modelOptions ?? {}),\n }\n\n try {\n options.logger.request(\n `activity=tts provider=${this.name} model=${model} format=${request.response_format ?? 'default'} voice=${request.voice}`,\n { provider: this.name, model },\n )\n const response = await this.client.audio.speech.create(request)\n\n const arrayBuffer = await response.arrayBuffer()\n const base64 = arrayBufferToBase64(arrayBuffer)\n\n const outputFormat = request.response_format ?? 'wav'\n const contentType = this.getContentType(outputFormat)\n\n return {\n id: generateId(this.name),\n model,\n audio: base64,\n format: outputFormat,\n contentType,\n }\n } catch (error: unknown) {\n // Narrow before logging: raw SDK errors can carry request metadata\n // (including auth headers) which we must never surface to user loggers.\n options.logger.errors(`${this.name}.generateSpeech fatal`, {\n error: toRunErrorPayload(error, `${this.name}.generateSpeech failed`),\n source: `${this.name}.generateSpeech`,\n })\n throw error\n }\n }\n\n private getContentType(format: string): string {\n const contentTypes: Record<string, string> = {\n flac: 'audio/flac',\n mp3: 'audio/mpeg',\n mulaw: 'audio/basic',\n ogg: 'audio/ogg',\n wav: 'audio/wav',\n }\n return contentTypes[format] || 'audio/wav'\n }\n}\n\n/**\n * Creates a Groq speech adapter with explicit API key.\n * Type resolution happens here at the call site.\n *\n * @param model - The model name (e.g., 'canopylabs/orpheus-v1-english')\n * @param apiKey - Your Groq API key\n * @param config - Optional additional configuration\n * @returns Configured Groq speech adapter instance with resolved types\n *\n * @example\n * ```typescript\n * const adapter = createGroqSpeech('canopylabs/orpheus-v1-english', 'gsk_...')\n *\n * const result = await generateSpeech({\n * adapter,\n * text: 'Hello, world!',\n * voice: 'autumn',\n * })\n * ```\n */\nexport function createGroqSpeech<TModel extends GroqTTSModel>(\n model: TModel,\n apiKey: string,\n config?: Omit<GroqTTSConfig, 'apiKey'>,\n): GroqTTSAdapter<TModel> {\n return new GroqTTSAdapter({ apiKey, ...config }, model)\n}\n\n/**\n * Creates a Groq speech adapter with automatic API key detection from\n * environment variables.\n *\n * Looks for `GROQ_API_KEY` in the environment.\n *\n * @param model - The model name (e.g., 'canopylabs/orpheus-v1-english')\n * @param config - Optional configuration (excluding apiKey which is auto-detected)\n * @returns Configured Groq speech adapter instance with resolved types\n * @throws Error if GROQ_API_KEY is not found in environment\n *\n * @example\n * ```typescript\n * const adapter = groqSpeech('canopylabs/orpheus-v1-english')\n *\n * const result = await generateSpeech({\n * adapter,\n * text: 'Welcome to TanStack AI!',\n * voice: 'autumn',\n * format: 'wav',\n * })\n * ```\n */\nexport function groqSpeech<TModel extends GroqTTSModel>(\n model: TModel,\n config?: Omit<GroqTTSConfig, 'apiKey'>,\n): GroqTTSAdapter<TModel> {\n const apiKey = getGroqApiKeyFromEnv()\n return createGroqSpeech(model, apiKey, config)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAa,iBAAb,cAAiE,eAG/D;CACA,OAAgB;CAEhB;CAEA,YAAY,QAAuB,OAAe;EAChD,MAAM,OAAO,CAAC,CAAC;EACf,KAAK,SAAS,IAAI,OAAO,iBAAiB,MAAM,CAAC;CACnD;CAEA,MAAM,eACJ,SACoB;EACpB,MAAM,EAAE,OAAO,MAAM,OAAO,QAAQ,OAAO,iBAAiB;EAE5D,mBAAmB;GAAE,OAAO;GAAM,OAAO,KAAK;EAAM,CAAC;EAKrD,MAAM,UAA+C;GACnD;GACA,OAAO;GACP,OAAO,SAAS;GAChB,iBAAiB,UAAU;GAC3B,GAAI,UAAU,KAAA,KAAa,EAAE,MAAM;GACnC,GAAI,gBAAgB,CAAC;EACvB;EAEA,IAAI;GACF,QAAQ,OAAO,QACb,yBAAyB,KAAK,KAAK,SAAS,MAAM,UAAU,QAAQ,mBAAmB,UAAU,SAAS,QAAQ,SAClH;IAAE,UAAU,KAAK;IAAM;GAAM,CAC/B;GAIA,MAAM,SAAS,oBAAoB,OADT,MAFH,KAAK,OAAO,MAAM,OAAO,OAAO,OAAO,EAAA,CAE3B,YAAY,CACD;GAE9C,MAAM,eAAe,QAAQ,mBAAmB;GAChD,MAAM,cAAc,KAAK,eAAe,YAAY;GAEpD,OAAO;IACL,IAAI,WAAW,KAAK,IAAI;IACxB;IACA,OAAO;IACP,QAAQ;IACR;GACF;EACF,SAAS,OAAgB;GAGvB,QAAQ,OAAO,OAAO,GAAG,KAAK,KAAK,wBAAwB;IACzD,OAAO,kBAAkB,OAAO,GAAG,KAAK,KAAK,uBAAuB;IACpE,QAAQ,GAAG,KAAK,KAAK;GACvB,CAAC;GACD,MAAM;EACR;CACF;CAEA,eAAuB,QAAwB;EAQ7C,OAAO;GANL,MAAM;GACN,KAAK;GACL,OAAO;GACP,KAAK;GACL,KAAK;EAEA,EAAa,WAAW;CACjC;AACF;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBACd,OACA,QACA,QACwB;CACxB,OAAO,IAAI,eAAe;EAAE;EAAQ,GAAG;CAAO,GAAG,KAAK;AACxD;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,WACd,OACA,QACwB;CAExB,OAAO,iBAAiB,OADT,qBACgB,GAAQ,MAAM;AAC/C"}
@@ -1,9 +1,12 @@
1
- const validateAudioInput = (options) => {
2
- if (options.input.length > 200) {
3
- throw new Error("Input text exceeds maximum length of 200 characters.");
4
- }
1
+ //#region src/audio/audio-provider-options.ts
2
+ /**
3
+ * Validates that the audio input text does not exceed the maximum length.
4
+ * @throws Error if input text exceeds 200 characters
5
+ */
6
+ var validateAudioInput = (options) => {
7
+ if (options.input.length > 200) throw new Error("Input text exceeds maximum length of 200 characters.");
5
8
  };
6
- export {
7
- validateAudioInput
8
- };
9
- //# sourceMappingURL=audio-provider-options.js.map
9
+ //#endregion
10
+ export { validateAudioInput };
11
+
12
+ //# sourceMappingURL=audio-provider-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"audio-provider-options.js","sources":["../../../src/audio/audio-provider-options.ts"],"sourcesContent":["/**\n * Common audio provider options for Groq audio endpoints.\n */\nexport interface AudioProviderOptions {\n /**\n * The text to generate audio for.\n * Maximum length is 200 characters.\n * Use [directions] for vocal control (English voices only).\n */\n input: string\n /**\n * The audio model to use for generation.\n */\n model: string\n}\n\n/**\n * Validates that the audio input text does not exceed the maximum length.\n * @throws Error if input text exceeds 200 characters\n */\nexport const validateAudioInput = (options: AudioProviderOptions) => {\n if (options.input.length > 200) {\n throw new Error('Input text exceeds maximum length of 200 characters.')\n }\n}\n"],"names":[],"mappings":"AAoBO,MAAM,qBAAqB,CAAC,YAAkC;AACnE,MAAI,QAAQ,MAAM,SAAS,KAAK;AAC9B,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACF;"}
1
+ {"version":3,"file":"audio-provider-options.js","names":[],"sources":["../../../src/audio/audio-provider-options.ts"],"sourcesContent":["/**\n * Common audio provider options for Groq audio endpoints.\n */\nexport interface AudioProviderOptions {\n /**\n * The text to generate audio for.\n * Maximum length is 200 characters.\n * Use [directions] for vocal control (English voices only).\n */\n input: string\n /**\n * The audio model to use for generation.\n */\n model: string\n}\n\n/**\n * Validates that the audio input text does not exceed the maximum length.\n * @throws Error if input text exceeds 200 characters\n */\nexport const validateAudioInput = (options: AudioProviderOptions) => {\n if (options.input.length > 200) {\n throw new Error('Input text exceeds maximum length of 200 characters.')\n }\n}\n"],"mappings":";;;;;AAoBA,IAAa,sBAAsB,YAAkC;CACnE,IAAI,QAAQ,MAAM,SAAS,KACzB,MAAM,IAAI,MAAM,sDAAsD;AAE1E"}
@@ -5,6 +5,7 @@
5
5
  * Provides tree-shakeable adapters for Groq's Chat Completions API and TTS API.
6
6
  */
7
7
  export { GroqTextAdapter, createGroqText, groqText, type GroqTextConfig, type GroqTextProviderOptions, } from './adapters/text.js';
8
+ export { createGroqSummarize, groqSummarize, type GroqSummarizeConfig, type GroqSummarizeModel, } from './adapters/summarize.js';
8
9
  export { GroqTranscriptionAdapter, createGroqTranscription, groqTranscription, type GroqTranscriptionConfig, } from './adapters/transcription.js';
9
10
  export type { GroqTranscriptionProviderOptions } from './audio/transcription-provider-options.js';
10
11
  export { GroqTTSAdapter, createGroqSpeech, groqSpeech, type GroqTTSConfig, } from './adapters/tts.js';
package/dist/esm/index.js CHANGED
@@ -1,19 +1,6 @@
1
1
  import { GroqTextAdapter, createGroqText, groqText } from "./adapters/text.js";
2
+ import { createGroqSummarize, groqSummarize } from "./adapters/summarize.js";
2
3
  import { GroqTranscriptionAdapter, createGroqTranscription, groqTranscription } from "./adapters/transcription.js";
3
4
  import { GroqTTSAdapter, createGroqSpeech, groqSpeech } from "./adapters/tts.js";
4
5
  import { GROQ_CHAT_MODELS, GROQ_TRANSCRIPTION_MODELS, GROQ_TTS_MODELS } from "./model-meta.js";
5
- export {
6
- GROQ_CHAT_MODELS,
7
- GROQ_TRANSCRIPTION_MODELS,
8
- GROQ_TTS_MODELS,
9
- GroqTTSAdapter,
10
- GroqTextAdapter,
11
- GroqTranscriptionAdapter,
12
- createGroqSpeech,
13
- createGroqText,
14
- createGroqTranscription,
15
- groqSpeech,
16
- groqText,
17
- groqTranscription
18
- };
19
- //# sourceMappingURL=index.js.map
6
+ export { GROQ_CHAT_MODELS, GROQ_TRANSCRIPTION_MODELS, GROQ_TTS_MODELS, GroqTTSAdapter, GroqTextAdapter, GroqTranscriptionAdapter, createGroqSpeech, createGroqSummarize, createGroqText, createGroqTranscription, groqSpeech, groqSummarize, groqText, groqTranscription };
@@ -1,70 +1,301 @@
1
- const LLAMA_3_3_70B_VERSATILE = {
2
- name: "llama-3.3-70b-versatile"
3
- };
4
- const LLAMA_4_MAVERICK_17B_128E_INSTRUCT = {
5
- name: "meta-llama/llama-4-maverick-17b-128e-instruct"
6
- };
7
- const LLAMA_4_SCOUT_17B_16E_INSTRUCT = {
8
- name: "meta-llama/llama-4-scout-17b-16e-instruct"
9
- };
10
- const LLAMA_GUARD_4_12B = {
11
- name: "meta-llama/llama-guard-4-12b"
12
- };
13
- const LLAMA_PROMPT_GUARD_2_86M = {
14
- name: "meta-llama/llama-prompt-guard-2-86m"
15
- };
16
- const LLAMA_3_1_8B_INSTANT = {
17
- name: "llama-3.1-8b-instant"
18
- };
19
- const LLAMA_PROMPT_GUARD_2_22M = {
20
- name: "meta-llama/llama-prompt-guard-2-22m"
21
- };
22
- const GPT_OSS_120B = {
23
- name: "openai/gpt-oss-120b"
24
- };
25
- const GPT_OSS_SAFEGUARD_20B = {
26
- name: "openai/gpt-oss-safeguard-20b"
27
- };
28
- const GPT_OSS_20B = {
29
- name: "openai/gpt-oss-20b"
30
- };
31
- const KIMI_K2_INSTRUCT_0905 = {
32
- name: "moonshotai/kimi-k2-instruct-0905"
33
- };
34
- const QWEN3_32B = {
35
- name: "qwen/qwen3-32b"
36
- };
37
- const GROQ_CHAT_MODELS = [
38
- LLAMA_3_1_8B_INSTANT.name,
39
- LLAMA_3_3_70B_VERSATILE.name,
40
- LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name,
41
- LLAMA_4_SCOUT_17B_16E_INSTRUCT.name,
42
- LLAMA_GUARD_4_12B.name,
43
- LLAMA_PROMPT_GUARD_2_86M.name,
44
- LLAMA_PROMPT_GUARD_2_22M.name,
45
- GPT_OSS_20B.name,
46
- GPT_OSS_120B.name,
47
- GPT_OSS_SAFEGUARD_20B.name,
48
- KIMI_K2_INSTRUCT_0905.name,
49
- QWEN3_32B.name
1
+ /**
2
+ * All supported Groq chat model identifiers.
3
+ */
4
+ var GROQ_CHAT_MODELS = [
5
+ {
6
+ name: "llama-3.1-8b-instant",
7
+ context_window: 131072,
8
+ max_completion_tokens: 131072,
9
+ pricing: {
10
+ input: { normal: .05 },
11
+ output: { normal: .08 }
12
+ },
13
+ supports: {
14
+ input: ["text"],
15
+ output: ["text"],
16
+ endpoints: ["chat"],
17
+ features: [
18
+ "streaming",
19
+ "json_object",
20
+ "tools"
21
+ ],
22
+ tools: []
23
+ }
24
+ }.name,
25
+ {
26
+ name: "llama-3.3-70b-versatile",
27
+ context_window: 131072,
28
+ max_completion_tokens: 32768,
29
+ pricing: {
30
+ input: { normal: .59 },
31
+ output: { normal: .79 }
32
+ },
33
+ supports: {
34
+ input: ["text"],
35
+ output: ["text"],
36
+ endpoints: ["chat"],
37
+ features: [
38
+ "streaming",
39
+ "tools",
40
+ "json_object"
41
+ ],
42
+ tools: []
43
+ }
44
+ }.name,
45
+ {
46
+ name: "meta-llama/llama-4-maverick-17b-128e-instruct",
47
+ context_window: 131072,
48
+ max_completion_tokens: 8192,
49
+ pricing: {
50
+ input: { normal: .2 },
51
+ output: { normal: .6 }
52
+ },
53
+ supports: {
54
+ input: ["text", "image"],
55
+ output: ["text"],
56
+ endpoints: ["chat"],
57
+ features: [
58
+ "streaming",
59
+ "tools",
60
+ "json_object",
61
+ "json_schema",
62
+ "vision"
63
+ ],
64
+ tools: []
65
+ }
66
+ }.name,
67
+ {
68
+ name: "meta-llama/llama-4-scout-17b-16e-instruct",
69
+ context_window: 131072,
70
+ max_completion_tokens: 8192,
71
+ pricing: {
72
+ input: { normal: .05 },
73
+ output: { normal: .08 }
74
+ },
75
+ supports: {
76
+ input: ["text", "image"],
77
+ output: ["text"],
78
+ endpoints: ["chat"],
79
+ features: [
80
+ "streaming",
81
+ "tools",
82
+ "json_object"
83
+ ],
84
+ tools: []
85
+ }
86
+ }.name,
87
+ {
88
+ name: "meta-llama/llama-guard-4-12b",
89
+ context_window: 131072,
90
+ max_completion_tokens: 1024,
91
+ pricing: {
92
+ input: { normal: .2 },
93
+ output: { normal: .2 }
94
+ },
95
+ supports: {
96
+ input: ["text", "image"],
97
+ output: ["text"],
98
+ endpoints: ["chat"],
99
+ features: [
100
+ "streaming",
101
+ "json_object",
102
+ "content_moderation",
103
+ "vision"
104
+ ],
105
+ tools: []
106
+ }
107
+ }.name,
108
+ {
109
+ name: "meta-llama/llama-prompt-guard-2-86m",
110
+ context_window: 512,
111
+ max_completion_tokens: 512,
112
+ pricing: {
113
+ input: { normal: .04 },
114
+ output: { normal: .04 }
115
+ },
116
+ supports: {
117
+ input: ["text"],
118
+ output: ["text"],
119
+ endpoints: ["chat"],
120
+ features: [
121
+ "streaming",
122
+ "content_moderation",
123
+ "json_object"
124
+ ],
125
+ tools: []
126
+ }
127
+ }.name,
128
+ {
129
+ name: "meta-llama/llama-prompt-guard-2-22m",
130
+ context_window: 512,
131
+ max_completion_tokens: 512,
132
+ pricing: {
133
+ input: { normal: .03 },
134
+ output: { normal: .03 }
135
+ },
136
+ supports: {
137
+ input: ["text"],
138
+ output: ["text"],
139
+ endpoints: ["chat"],
140
+ features: ["streaming", "content_moderation"],
141
+ tools: []
142
+ }
143
+ }.name,
144
+ {
145
+ name: "openai/gpt-oss-20b",
146
+ context_window: 131072,
147
+ max_completion_tokens: 65536,
148
+ pricing: {
149
+ input: {
150
+ normal: .075,
151
+ cached: .037
152
+ },
153
+ output: { normal: .3 }
154
+ },
155
+ supports: {
156
+ input: ["text"],
157
+ output: ["text"],
158
+ endpoints: ["chat"],
159
+ features: [
160
+ "streaming",
161
+ "browser_search",
162
+ "code_execution",
163
+ "json_object",
164
+ "json_schema",
165
+ "reasoning",
166
+ "tools"
167
+ ],
168
+ tools: []
169
+ }
170
+ }.name,
171
+ {
172
+ name: "openai/gpt-oss-120b",
173
+ context_window: 131072,
174
+ max_completion_tokens: 65536,
175
+ pricing: {
176
+ input: {
177
+ normal: .15,
178
+ cached: .075
179
+ },
180
+ output: { normal: .6 }
181
+ },
182
+ supports: {
183
+ input: ["text"],
184
+ output: ["text"],
185
+ endpoints: ["chat"],
186
+ features: [
187
+ "streaming",
188
+ "json_object",
189
+ "json_schema",
190
+ "tools",
191
+ "browser_search",
192
+ "code_execution",
193
+ "reasoning"
194
+ ],
195
+ tools: []
196
+ }
197
+ }.name,
198
+ {
199
+ name: "openai/gpt-oss-safeguard-20b",
200
+ context_window: 131072,
201
+ max_completion_tokens: 65536,
202
+ pricing: {
203
+ input: {
204
+ normal: .075,
205
+ cached: .037
206
+ },
207
+ output: { normal: .3 }
208
+ },
209
+ supports: {
210
+ input: ["text"],
211
+ output: ["text"],
212
+ endpoints: ["chat"],
213
+ features: [
214
+ "streaming",
215
+ "tools",
216
+ "browser_search",
217
+ "code_execution",
218
+ "json_object",
219
+ "json_schema",
220
+ "reasoning",
221
+ "content_moderation"
222
+ ],
223
+ tools: []
224
+ }
225
+ }.name,
226
+ {
227
+ name: "moonshotai/kimi-k2-instruct-0905",
228
+ context_window: 262144,
229
+ max_completion_tokens: 16384,
230
+ pricing: {
231
+ input: {
232
+ normal: 1,
233
+ cached: .5
234
+ },
235
+ output: { normal: 3 }
236
+ },
237
+ supports: {
238
+ input: ["text"],
239
+ output: ["text"],
240
+ endpoints: ["chat"],
241
+ features: [
242
+ "streaming",
243
+ "tools",
244
+ "json_object",
245
+ "json_schema"
246
+ ],
247
+ tools: []
248
+ }
249
+ }.name,
250
+ {
251
+ name: "qwen/qwen3-32b",
252
+ context_window: 131072,
253
+ max_completion_tokens: 40960,
254
+ pricing: {
255
+ input: { normal: .29 },
256
+ output: { normal: .59 }
257
+ },
258
+ supports: {
259
+ input: ["text"],
260
+ output: ["text"],
261
+ endpoints: ["chat"],
262
+ features: [
263
+ "streaming",
264
+ "json_object",
265
+ "tools",
266
+ "reasoning"
267
+ ],
268
+ tools: []
269
+ }
270
+ }.name
50
271
  ];
51
- const GROQ_TRANSCRIPTION_MODELS = [
52
- "whisper-large-v3-turbo",
53
- "whisper-large-v3"
54
- ];
55
- const ORPHEUS_V1_ENGLISH = {
56
- name: "canopylabs/orpheus-v1-english"
57
- };
58
- const ORPHEUS_ARABIC_SAUDI = {
59
- name: "canopylabs/orpheus-arabic-saudi"
60
- };
61
- const GROQ_TTS_MODELS = [
62
- ORPHEUS_V1_ENGLISH.name,
63
- ORPHEUS_ARABIC_SAUDI.name
64
- ];
65
- export {
66
- GROQ_CHAT_MODELS,
67
- GROQ_TRANSCRIPTION_MODELS,
68
- GROQ_TTS_MODELS
69
- };
70
- //# sourceMappingURL=model-meta.js.map
272
+ /**
273
+ * All supported Groq transcription model identifiers.
274
+ */
275
+ var GROQ_TRANSCRIPTION_MODELS = ["whisper-large-v3-turbo", "whisper-large-v3"];
276
+ /**
277
+ * All supported Groq TTS model identifiers.
278
+ */
279
+ var GROQ_TTS_MODELS = [{
280
+ name: "canopylabs/orpheus-v1-english",
281
+ pricing: { input: { normal: 22 } },
282
+ supports: {
283
+ input: ["text"],
284
+ output: ["audio"],
285
+ endpoints: ["tts"],
286
+ features: []
287
+ }
288
+ }.name, {
289
+ name: "canopylabs/orpheus-arabic-saudi",
290
+ pricing: { input: { normal: 40 } },
291
+ supports: {
292
+ input: ["text"],
293
+ output: ["audio"],
294
+ endpoints: ["tts"],
295
+ features: []
296
+ }
297
+ }.name];
298
+ //#endregion
299
+ export { GROQ_CHAT_MODELS, GROQ_TRANSCRIPTION_MODELS, GROQ_TTS_MODELS };
300
+
301
+ //# sourceMappingURL=model-meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import type { GroqTextProviderOptions } from './text/text-provider-options'\nimport type { GroqTTSProviderOptions } from './audio/tts-provider-options'\n\n/**\n * Internal metadata structure describing a Groq model's capabilities and pricing.\n */\ninterface ModelMeta<TProviderOptions = unknown> {\n name: string\n context_window?: number\n max_completion_tokens?: number\n pricing: {\n input?: { normal: number; cached?: number }\n output?: { normal: number }\n }\n supports: {\n input: Array<'text' | 'image' | 'audio'>\n output: Array<'text' | 'audio'>\n endpoints: Array<'chat' | 'tts' | 'transcription' | 'batch'>\n\n features: Array<\n | 'streaming'\n | 'tools'\n | 'json_object'\n | 'browser_search'\n | 'code_execution'\n | 'reasoning'\n | 'content_moderation'\n | 'json_schema'\n | 'vision'\n >\n tools?: ReadonlyArray<never>\n }\n /**\n * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n}\n\nconst LLAMA_3_3_70B_VERSATILE = {\n name: 'llama-3.3-70b-versatile',\n context_window: 131_072,\n max_completion_tokens: 32_768,\n pricing: {\n input: {\n normal: 0.59,\n },\n output: {\n normal: 0.79,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_4_MAVERICK_17B_128E_INSTRUCT = {\n name: 'meta-llama/llama-4-maverick-17b-128e-instruct',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: {\n normal: 0.2,\n },\n output: {\n normal: 0.6,\n },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_4_SCOUT_17B_16E_INSTRUCT = {\n name: 'meta-llama/llama-4-scout-17b-16e-instruct',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: {\n normal: 0.05,\n },\n output: {\n normal: 0.08,\n },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_GUARD_4_12B = {\n name: 'meta-llama/llama-guard-4-12b',\n context_window: 131_072,\n max_completion_tokens: 1024,\n pricing: {\n input: {\n normal: 0.2,\n },\n output: {\n normal: 0.2,\n },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'json_object', 'content_moderation', 'vision'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_PROMPT_GUARD_2_86M = {\n name: 'meta-llama/llama-prompt-guard-2-86m',\n context_window: 512,\n max_completion_tokens: 512,\n pricing: {\n input: {\n normal: 0.04,\n },\n output: {\n normal: 0.04,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'content_moderation', 'json_object'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_3_1_8B_INSTANT = {\n name: 'llama-3.1-8b-instant',\n context_window: 131_072,\n max_completion_tokens: 131_072,\n pricing: {\n input: {\n normal: 0.05,\n },\n output: {\n normal: 0.08,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'json_object', 'tools'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_PROMPT_GUARD_2_22M = {\n name: 'meta-llama/llama-prompt-guard-2-22m',\n context_window: 512,\n max_completion_tokens: 512,\n pricing: {\n input: {\n normal: 0.03,\n },\n output: {\n normal: 0.03,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'content_moderation'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst GPT_OSS_120B = {\n name: 'openai/gpt-oss-120b',\n context_window: 131_072,\n max_completion_tokens: 65_536,\n pricing: {\n input: {\n normal: 0.15,\n cached: 0.075,\n },\n output: {\n normal: 0.6,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: [\n 'streaming',\n 'json_object',\n 'json_schema',\n 'tools',\n 'browser_search',\n 'code_execution',\n 'reasoning',\n ],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst GPT_OSS_SAFEGUARD_20B = {\n name: 'openai/gpt-oss-safeguard-20b',\n context_window: 131_072,\n max_completion_tokens: 65_536,\n pricing: {\n input: {\n normal: 0.075,\n cached: 0.037,\n },\n output: {\n normal: 0.3,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: [\n 'streaming',\n 'tools',\n 'browser_search',\n 'code_execution',\n 'json_object',\n 'json_schema',\n 'reasoning',\n 'content_moderation',\n ],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst GPT_OSS_20B = {\n name: 'openai/gpt-oss-20b',\n context_window: 131_072,\n max_completion_tokens: 65_536,\n pricing: {\n input: {\n normal: 0.075,\n cached: 0.037,\n },\n output: {\n normal: 0.3,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: [\n 'streaming',\n 'browser_search',\n 'code_execution',\n 'json_object',\n 'json_schema',\n 'reasoning',\n 'tools',\n ],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst KIMI_K2_INSTRUCT_0905 = {\n name: 'moonshotai/kimi-k2-instruct-0905',\n context_window: 262_144,\n max_completion_tokens: 16_384,\n pricing: {\n input: {\n normal: 1,\n cached: 0.5,\n },\n output: {\n normal: 3,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst QWEN3_32B = {\n name: 'qwen/qwen3-32b',\n context_window: 131_072,\n max_completion_tokens: 40_960,\n pricing: {\n input: {\n normal: 0.29,\n },\n output: {\n normal: 0.59,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'json_object', 'tools', 'reasoning'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\n/**\n * All supported Groq chat model identifiers.\n */\nexport const GROQ_CHAT_MODELS = [\n LLAMA_3_1_8B_INSTANT.name,\n LLAMA_3_3_70B_VERSATILE.name,\n LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name,\n LLAMA_4_SCOUT_17B_16E_INSTRUCT.name,\n LLAMA_GUARD_4_12B.name,\n LLAMA_PROMPT_GUARD_2_86M.name,\n LLAMA_PROMPT_GUARD_2_22M.name,\n GPT_OSS_20B.name,\n GPT_OSS_120B.name,\n GPT_OSS_SAFEGUARD_20B.name,\n KIMI_K2_INSTRUCT_0905.name,\n QWEN3_32B.name,\n] as const\n\n/**\n * Union type of all supported Groq chat model names.\n */\nexport type GroqChatModels = (typeof GROQ_CHAT_MODELS)[number]\n\n/**\n * Type-only map from Groq chat model name to its supported input modalities.\n */\nexport type GroqModelInputModalitiesByName = {\n [LLAMA_3_1_8B_INSTANT.name]: typeof LLAMA_3_1_8B_INSTANT.supports.input\n [LLAMA_3_3_70B_VERSATILE.name]: typeof LLAMA_3_3_70B_VERSATILE.supports.input\n [LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name]: typeof LLAMA_4_MAVERICK_17B_128E_INSTRUCT.supports.input\n [LLAMA_4_SCOUT_17B_16E_INSTRUCT.name]: typeof LLAMA_4_SCOUT_17B_16E_INSTRUCT.supports.input\n [LLAMA_GUARD_4_12B.name]: typeof LLAMA_GUARD_4_12B.supports.input\n [LLAMA_PROMPT_GUARD_2_86M.name]: typeof LLAMA_PROMPT_GUARD_2_86M.supports.input\n [LLAMA_PROMPT_GUARD_2_22M.name]: typeof LLAMA_PROMPT_GUARD_2_22M.supports.input\n [GPT_OSS_20B.name]: typeof GPT_OSS_20B.supports.input\n [GPT_OSS_120B.name]: typeof GPT_OSS_120B.supports.input\n [GPT_OSS_SAFEGUARD_20B.name]: typeof GPT_OSS_SAFEGUARD_20B.supports.input\n [KIMI_K2_INSTRUCT_0905.name]: typeof KIMI_K2_INSTRUCT_0905.supports.input\n [QWEN3_32B.name]: typeof QWEN3_32B.supports.input\n}\n\n/**\n * Type-only map from Groq chat model name to its provider options type.\n */\nexport type GroqChatModelProviderOptionsByName = {\n [K in (typeof GROQ_CHAT_MODELS)[number]]: GroqTextProviderOptions\n}\n\n/**\n * Type-only map from Groq chat model name to its supported provider tools.\n * Groq exposes no provider-specific tool factories, so every model gets an\n * empty tuple. This ensures that passing an Anthropic/OpenAI ProviderTool to\n * a Groq adapter produces a compile-time type error.\n */\nexport type GroqChatModelToolCapabilitiesByName = {\n [LLAMA_3_1_8B_INSTANT.name]: typeof LLAMA_3_1_8B_INSTANT.supports.tools\n [LLAMA_3_3_70B_VERSATILE.name]: typeof LLAMA_3_3_70B_VERSATILE.supports.tools\n [LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name]: typeof LLAMA_4_MAVERICK_17B_128E_INSTRUCT.supports.tools\n [LLAMA_4_SCOUT_17B_16E_INSTRUCT.name]: typeof LLAMA_4_SCOUT_17B_16E_INSTRUCT.supports.tools\n [LLAMA_GUARD_4_12B.name]: typeof LLAMA_GUARD_4_12B.supports.tools\n [LLAMA_PROMPT_GUARD_2_86M.name]: typeof LLAMA_PROMPT_GUARD_2_86M.supports.tools\n [LLAMA_PROMPT_GUARD_2_22M.name]: typeof LLAMA_PROMPT_GUARD_2_22M.supports.tools\n [GPT_OSS_20B.name]: typeof GPT_OSS_20B.supports.tools\n [GPT_OSS_120B.name]: typeof GPT_OSS_120B.supports.tools\n [GPT_OSS_SAFEGUARD_20B.name]: typeof GPT_OSS_SAFEGUARD_20B.supports.tools\n [KIMI_K2_INSTRUCT_0905.name]: typeof KIMI_K2_INSTRUCT_0905.supports.tools\n [QWEN3_32B.name]: typeof QWEN3_32B.supports.tools\n}\n\n/**\n * Type-only map from Groq TTS model name to its provider options type.\n */\nexport type GroqTTSModelProviderOptionsByName = {\n [K in GroqTTSModel]: GroqTTSProviderOptions\n}\n\n/**\n * Resolves the provider options type for a specific Groq model.\n * Checks TTS models first, then chat models, then falls back to generic options.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends GroqTTSModel\n ? GroqTTSProviderOptions\n : TModel extends keyof GroqChatModelProviderOptionsByName\n ? GroqChatModelProviderOptionsByName[TModel]\n : GroqTextProviderOptions\n\n/**\n * Resolve input modalities for a specific model.\n * If the model has explicit modalities in the map, use those; otherwise use text only.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof GroqModelInputModalitiesByName\n ? GroqModelInputModalitiesByName[TModel]\n : readonly ['text']\n\n/**\n * All supported Groq transcription model identifiers.\n */\nexport const GROQ_TRANSCRIPTION_MODELS = [\n 'whisper-large-v3-turbo',\n 'whisper-large-v3',\n] as const\n\n/**\n * Union type of all supported Groq transcription model names.\n */\nexport type GroqTranscriptionModel = (typeof GROQ_TRANSCRIPTION_MODELS)[number]\n\n// ============================================================================\n// TTS Models\n// ============================================================================\n\nconst ORPHEUS_V1_ENGLISH = {\n name: 'canopylabs/orpheus-v1-english',\n pricing: {\n input: {\n normal: 22,\n },\n },\n supports: {\n input: ['text'],\n output: ['audio'],\n endpoints: ['tts'],\n features: [],\n },\n} as const satisfies ModelMeta<GroqTTSProviderOptions>\n\nconst ORPHEUS_ARABIC_SAUDI = {\n name: 'canopylabs/orpheus-arabic-saudi',\n pricing: {\n input: {\n normal: 40,\n },\n },\n supports: {\n input: ['text'],\n output: ['audio'],\n endpoints: ['tts'],\n features: [],\n },\n} as const satisfies ModelMeta<GroqTTSProviderOptions>\n\n/**\n * All supported Groq TTS model identifiers.\n */\nexport const GROQ_TTS_MODELS = [\n ORPHEUS_V1_ENGLISH.name,\n ORPHEUS_ARABIC_SAUDI.name,\n] as const\n\n/**\n * Union type of all supported Groq TTS model names.\n */\nexport type GroqTTSModel = (typeof GROQ_TTS_MODELS)[number]\n"],"names":[],"mappings":"AAsCA,MAAM,0BAA0B;AAAA,EAC9B,MAAM;AAkBR;AAEA,MAAM,qCAAqC;AAAA,EACzC,MAAM;AAkBR;AAEA,MAAM,iCAAiC;AAAA,EACrC,MAAM;AAkBR;AAEA,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAkBR;AAEA,MAAM,2BAA2B;AAAA,EAC/B,MAAM;AAkBR;AAEA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AAkBR;AAEA,MAAM,2BAA2B;AAAA,EAC/B,MAAM;AAkBR;AAEA,MAAM,eAAe;AAAA,EACnB,MAAM;AA2BR;AAEA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AA4BR;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AA2BR;AAEA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AAmBR;AAEA,MAAM,YAAY;AAAA,EAChB,MAAM;AAkBR;AAKO,MAAM,mBAAmB;AAAA,EAC9B,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,mCAAmC;AAAA,EACnC,+BAA+B;AAAA,EAC/B,kBAAkB;AAAA,EAClB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,UAAU;AACZ;AAmFO,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AACF;AAWA,MAAM,qBAAqB;AAAA,EACzB,MAAM;AAYR;AAEA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AAYR;AAKO,MAAM,kBAAkB;AAAA,EAC7B,mBAAmB;AAAA,EACnB,qBAAqB;AACvB;"}
1
+ {"version":3,"file":"model-meta.js","names":[],"sources":["../../src/model-meta.ts"],"sourcesContent":["import type { GroqTextProviderOptions } from './text/text-provider-options'\nimport type { GroqTTSProviderOptions } from './audio/tts-provider-options'\n\n/**\n * Internal metadata structure describing a Groq model's capabilities and pricing.\n */\ninterface ModelMeta<TProviderOptions = unknown> {\n name: string\n context_window?: number\n max_completion_tokens?: number\n pricing: {\n input?: { normal: number; cached?: number }\n output?: { normal: number }\n }\n supports: {\n input: Array<'text' | 'image' | 'audio'>\n output: Array<'text' | 'audio'>\n endpoints: Array<'chat' | 'tts' | 'transcription' | 'batch'>\n\n features: Array<\n | 'streaming'\n | 'tools'\n | 'json_object'\n | 'browser_search'\n | 'code_execution'\n | 'reasoning'\n | 'content_moderation'\n | 'json_schema'\n | 'vision'\n >\n tools?: ReadonlyArray<never>\n }\n /**\n * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n}\n\nconst LLAMA_3_3_70B_VERSATILE = {\n name: 'llama-3.3-70b-versatile',\n context_window: 131_072,\n max_completion_tokens: 32_768,\n pricing: {\n input: {\n normal: 0.59,\n },\n output: {\n normal: 0.79,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_4_MAVERICK_17B_128E_INSTRUCT = {\n name: 'meta-llama/llama-4-maverick-17b-128e-instruct',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: {\n normal: 0.2,\n },\n output: {\n normal: 0.6,\n },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_4_SCOUT_17B_16E_INSTRUCT = {\n name: 'meta-llama/llama-4-scout-17b-16e-instruct',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: {\n normal: 0.05,\n },\n output: {\n normal: 0.08,\n },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_GUARD_4_12B = {\n name: 'meta-llama/llama-guard-4-12b',\n context_window: 131_072,\n max_completion_tokens: 1024,\n pricing: {\n input: {\n normal: 0.2,\n },\n output: {\n normal: 0.2,\n },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'json_object', 'content_moderation', 'vision'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_PROMPT_GUARD_2_86M = {\n name: 'meta-llama/llama-prompt-guard-2-86m',\n context_window: 512,\n max_completion_tokens: 512,\n pricing: {\n input: {\n normal: 0.04,\n },\n output: {\n normal: 0.04,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'content_moderation', 'json_object'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_3_1_8B_INSTANT = {\n name: 'llama-3.1-8b-instant',\n context_window: 131_072,\n max_completion_tokens: 131_072,\n pricing: {\n input: {\n normal: 0.05,\n },\n output: {\n normal: 0.08,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'json_object', 'tools'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst LLAMA_PROMPT_GUARD_2_22M = {\n name: 'meta-llama/llama-prompt-guard-2-22m',\n context_window: 512,\n max_completion_tokens: 512,\n pricing: {\n input: {\n normal: 0.03,\n },\n output: {\n normal: 0.03,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'content_moderation'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst GPT_OSS_120B = {\n name: 'openai/gpt-oss-120b',\n context_window: 131_072,\n max_completion_tokens: 65_536,\n pricing: {\n input: {\n normal: 0.15,\n cached: 0.075,\n },\n output: {\n normal: 0.6,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: [\n 'streaming',\n 'json_object',\n 'json_schema',\n 'tools',\n 'browser_search',\n 'code_execution',\n 'reasoning',\n ],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst GPT_OSS_SAFEGUARD_20B = {\n name: 'openai/gpt-oss-safeguard-20b',\n context_window: 131_072,\n max_completion_tokens: 65_536,\n pricing: {\n input: {\n normal: 0.075,\n cached: 0.037,\n },\n output: {\n normal: 0.3,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: [\n 'streaming',\n 'tools',\n 'browser_search',\n 'code_execution',\n 'json_object',\n 'json_schema',\n 'reasoning',\n 'content_moderation',\n ],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst GPT_OSS_20B = {\n name: 'openai/gpt-oss-20b',\n context_window: 131_072,\n max_completion_tokens: 65_536,\n pricing: {\n input: {\n normal: 0.075,\n cached: 0.037,\n },\n output: {\n normal: 0.3,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: [\n 'streaming',\n 'browser_search',\n 'code_execution',\n 'json_object',\n 'json_schema',\n 'reasoning',\n 'tools',\n ],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst KIMI_K2_INSTRUCT_0905 = {\n name: 'moonshotai/kimi-k2-instruct-0905',\n context_window: 262_144,\n max_completion_tokens: 16_384,\n pricing: {\n input: {\n normal: 1,\n cached: 0.5,\n },\n output: {\n normal: 3,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\nconst QWEN3_32B = {\n name: 'qwen/qwen3-32b',\n context_window: 131_072,\n max_completion_tokens: 40_960,\n pricing: {\n input: {\n normal: 0.29,\n },\n output: {\n normal: 0.59,\n },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'json_object', 'tools', 'reasoning'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta<GroqTextProviderOptions>\n\n/**\n * All supported Groq chat model identifiers.\n */\nexport const GROQ_CHAT_MODELS = [\n LLAMA_3_1_8B_INSTANT.name,\n LLAMA_3_3_70B_VERSATILE.name,\n LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name,\n LLAMA_4_SCOUT_17B_16E_INSTRUCT.name,\n LLAMA_GUARD_4_12B.name,\n LLAMA_PROMPT_GUARD_2_86M.name,\n LLAMA_PROMPT_GUARD_2_22M.name,\n GPT_OSS_20B.name,\n GPT_OSS_120B.name,\n GPT_OSS_SAFEGUARD_20B.name,\n KIMI_K2_INSTRUCT_0905.name,\n QWEN3_32B.name,\n] as const\n\n/**\n * Union type of all supported Groq chat model names.\n */\nexport type GroqChatModels = (typeof GROQ_CHAT_MODELS)[number]\n\n/**\n * Type-only map from Groq chat model name to its supported input modalities.\n */\nexport type GroqModelInputModalitiesByName = {\n [LLAMA_3_1_8B_INSTANT.name]: typeof LLAMA_3_1_8B_INSTANT.supports.input\n [LLAMA_3_3_70B_VERSATILE.name]: typeof LLAMA_3_3_70B_VERSATILE.supports.input\n [LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name]: typeof LLAMA_4_MAVERICK_17B_128E_INSTRUCT.supports.input\n [LLAMA_4_SCOUT_17B_16E_INSTRUCT.name]: typeof LLAMA_4_SCOUT_17B_16E_INSTRUCT.supports.input\n [LLAMA_GUARD_4_12B.name]: typeof LLAMA_GUARD_4_12B.supports.input\n [LLAMA_PROMPT_GUARD_2_86M.name]: typeof LLAMA_PROMPT_GUARD_2_86M.supports.input\n [LLAMA_PROMPT_GUARD_2_22M.name]: typeof LLAMA_PROMPT_GUARD_2_22M.supports.input\n [GPT_OSS_20B.name]: typeof GPT_OSS_20B.supports.input\n [GPT_OSS_120B.name]: typeof GPT_OSS_120B.supports.input\n [GPT_OSS_SAFEGUARD_20B.name]: typeof GPT_OSS_SAFEGUARD_20B.supports.input\n [KIMI_K2_INSTRUCT_0905.name]: typeof KIMI_K2_INSTRUCT_0905.supports.input\n [QWEN3_32B.name]: typeof QWEN3_32B.supports.input\n}\n\n/**\n * Type-only map from Groq chat model name to its provider options type.\n */\nexport type GroqChatModelProviderOptionsByName = {\n [K in (typeof GROQ_CHAT_MODELS)[number]]: GroqTextProviderOptions\n}\n\n/**\n * Type-only map from Groq chat model name to its supported provider tools.\n * Groq exposes no provider-specific tool factories, so every model gets an\n * empty tuple. This ensures that passing an Anthropic/OpenAI ProviderTool to\n * a Groq adapter produces a compile-time type error.\n */\nexport type GroqChatModelToolCapabilitiesByName = {\n [LLAMA_3_1_8B_INSTANT.name]: typeof LLAMA_3_1_8B_INSTANT.supports.tools\n [LLAMA_3_3_70B_VERSATILE.name]: typeof LLAMA_3_3_70B_VERSATILE.supports.tools\n [LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name]: typeof LLAMA_4_MAVERICK_17B_128E_INSTRUCT.supports.tools\n [LLAMA_4_SCOUT_17B_16E_INSTRUCT.name]: typeof LLAMA_4_SCOUT_17B_16E_INSTRUCT.supports.tools\n [LLAMA_GUARD_4_12B.name]: typeof LLAMA_GUARD_4_12B.supports.tools\n [LLAMA_PROMPT_GUARD_2_86M.name]: typeof LLAMA_PROMPT_GUARD_2_86M.supports.tools\n [LLAMA_PROMPT_GUARD_2_22M.name]: typeof LLAMA_PROMPT_GUARD_2_22M.supports.tools\n [GPT_OSS_20B.name]: typeof GPT_OSS_20B.supports.tools\n [GPT_OSS_120B.name]: typeof GPT_OSS_120B.supports.tools\n [GPT_OSS_SAFEGUARD_20B.name]: typeof GPT_OSS_SAFEGUARD_20B.supports.tools\n [KIMI_K2_INSTRUCT_0905.name]: typeof KIMI_K2_INSTRUCT_0905.supports.tools\n [QWEN3_32B.name]: typeof QWEN3_32B.supports.tools\n}\n\n/**\n * Type-only map from Groq TTS model name to its provider options type.\n */\nexport type GroqTTSModelProviderOptionsByName = {\n [K in GroqTTSModel]: GroqTTSProviderOptions\n}\n\n/**\n * Resolves the provider options type for a specific Groq model.\n * Checks TTS models first, then chat models, then falls back to generic options.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends GroqTTSModel\n ? GroqTTSProviderOptions\n : TModel extends keyof GroqChatModelProviderOptionsByName\n ? GroqChatModelProviderOptionsByName[TModel]\n : GroqTextProviderOptions\n\n/**\n * Resolve input modalities for a specific model.\n * If the model has explicit modalities in the map, use those; otherwise use text only.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof GroqModelInputModalitiesByName\n ? GroqModelInputModalitiesByName[TModel]\n : readonly ['text']\n\n/**\n * All supported Groq transcription model identifiers.\n */\nexport const GROQ_TRANSCRIPTION_MODELS = [\n 'whisper-large-v3-turbo',\n 'whisper-large-v3',\n] as const\n\n/**\n * Union type of all supported Groq transcription model names.\n */\nexport type GroqTranscriptionModel = (typeof GROQ_TRANSCRIPTION_MODELS)[number]\n\n// ============================================================================\n// TTS Models\n// ============================================================================\n\nconst ORPHEUS_V1_ENGLISH = {\n name: 'canopylabs/orpheus-v1-english',\n pricing: {\n input: {\n normal: 22,\n },\n },\n supports: {\n input: ['text'],\n output: ['audio'],\n endpoints: ['tts'],\n features: [],\n },\n} as const satisfies ModelMeta<GroqTTSProviderOptions>\n\nconst ORPHEUS_ARABIC_SAUDI = {\n name: 'canopylabs/orpheus-arabic-saudi',\n pricing: {\n input: {\n normal: 40,\n },\n },\n supports: {\n input: ['text'],\n output: ['audio'],\n endpoints: ['tts'],\n features: [],\n },\n} as const satisfies ModelMeta<GroqTTSProviderOptions>\n\n/**\n * All supported Groq TTS model identifiers.\n */\nexport const GROQ_TTS_MODELS = [\n ORPHEUS_V1_ENGLISH.name,\n ORPHEUS_ARABIC_SAUDI.name,\n] as const\n\n/**\n * Union type of all supported Groq TTS model names.\n */\nexport type GroqTTSModel = (typeof GROQ_TTS_MODELS)[number]\n"],"mappings":"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"}
@@ -1,29 +1,34 @@
1
1
  import { makeGroqStructuredOutputCompatible } from "../utils/schema-converter.js";
2
+ //#region src/tools/function-tool.ts
3
+ /**
4
+ * Converts a standard Tool to Groq ChatCompletionTool format.
5
+ *
6
+ * Tool schemas are already converted to JSON Schema in the ai layer.
7
+ * We apply Groq-specific transformations for strict mode:
8
+ * - All properties in required array
9
+ * - Optional fields made nullable
10
+ * - additionalProperties: false
11
+ */
2
12
  function convertFunctionToolToAdapterFormat(tool) {
3
- const inputSchema = tool.inputSchema ?? {
4
- type: "object",
5
- properties: {},
6
- required: []
7
- };
8
- if (inputSchema.type === "object" && !inputSchema.properties) {
9
- inputSchema.properties = {};
10
- }
11
- const jsonSchema = makeGroqStructuredOutputCompatible(
12
- inputSchema,
13
- inputSchema.required || []
14
- );
15
- jsonSchema.additionalProperties = false;
16
- return {
17
- type: "function",
18
- function: {
19
- name: tool.name,
20
- description: tool.description,
21
- parameters: jsonSchema,
22
- strict: true
23
- }
24
- };
13
+ const inputSchema = tool.inputSchema ?? {
14
+ type: "object",
15
+ properties: {},
16
+ required: []
17
+ };
18
+ if (inputSchema.type === "object" && !inputSchema.properties) inputSchema.properties = {};
19
+ const jsonSchema = makeGroqStructuredOutputCompatible(inputSchema, inputSchema.required || []);
20
+ jsonSchema.additionalProperties = false;
21
+ return {
22
+ type: "function",
23
+ function: {
24
+ name: tool.name,
25
+ description: tool.description,
26
+ parameters: jsonSchema,
27
+ strict: true
28
+ }
29
+ };
25
30
  }
26
- export {
27
- convertFunctionToolToAdapterFormat
28
- };
29
- //# sourceMappingURL=function-tool.js.map
31
+ //#endregion
32
+ export { convertFunctionToolToAdapterFormat };
33
+
34
+ //# sourceMappingURL=function-tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"function-tool.js","sources":["../../../src/tools/function-tool.ts"],"sourcesContent":["import { makeGroqStructuredOutputCompatible } from '../utils/schema-converter'\nimport type { JSONSchema, Tool } from '@tanstack/ai'\nimport type { ChatCompletionTool } from '../message-types'\n\nexport type FunctionTool = ChatCompletionTool\n\n/**\n * Converts a standard Tool to Groq ChatCompletionTool format.\n *\n * Tool schemas are already converted to JSON Schema in the ai layer.\n * We apply Groq-specific transformations for strict mode:\n * - All properties in required array\n * - Optional fields made nullable\n * - additionalProperties: false\n */\nexport function convertFunctionToolToAdapterFormat(tool: Tool): FunctionTool {\n const inputSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n // Ensure object schemas always have properties (e.g. z.object({}) may produce { type: 'object' } without properties)\n if (inputSchema.type === 'object' && !inputSchema.properties) {\n inputSchema.properties = {}\n }\n\n const jsonSchema = makeGroqStructuredOutputCompatible(\n inputSchema,\n inputSchema.required || [],\n )\n\n jsonSchema.additionalProperties = false\n\n return {\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: jsonSchema,\n strict: true,\n },\n } satisfies FunctionTool\n}\n"],"names":[],"mappings":";AAeO,SAAS,mCAAmC,MAA0B;AAC3E,QAAM,cAAe,KAAK,eAAe;AAAA,IACvC,MAAM;AAAA,IACN,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,EAAC;AAIb,MAAI,YAAY,SAAS,YAAY,CAAC,YAAY,YAAY;AAC5D,gBAAY,aAAa,CAAA;AAAA,EAC3B;AAEA,QAAM,aAAa;AAAA,IACjB;AAAA,IACA,YAAY,YAAY,CAAA;AAAA,EAAC;AAG3B,aAAW,uBAAuB;AAElC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM,KAAK;AAAA,MACX,aAAa,KAAK;AAAA,MAClB,YAAY;AAAA,MACZ,QAAQ;AAAA,IAAA;AAAA,EACV;AAEJ;"}
1
+ {"version":3,"file":"function-tool.js","names":[],"sources":["../../../src/tools/function-tool.ts"],"sourcesContent":["import { makeGroqStructuredOutputCompatible } from '../utils/schema-converter'\nimport type { JSONSchema, Tool } from '@tanstack/ai'\nimport type { ChatCompletionTool } from '../message-types'\n\nexport type FunctionTool = ChatCompletionTool\n\n/**\n * Converts a standard Tool to Groq ChatCompletionTool format.\n *\n * Tool schemas are already converted to JSON Schema in the ai layer.\n * We apply Groq-specific transformations for strict mode:\n * - All properties in required array\n * - Optional fields made nullable\n * - additionalProperties: false\n */\nexport function convertFunctionToolToAdapterFormat(tool: Tool): FunctionTool {\n const inputSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n // Ensure object schemas always have properties (e.g. z.object({}) may produce { type: 'object' } without properties)\n if (inputSchema.type === 'object' && !inputSchema.properties) {\n inputSchema.properties = {}\n }\n\n const jsonSchema = makeGroqStructuredOutputCompatible(\n inputSchema,\n inputSchema.required || [],\n )\n\n jsonSchema.additionalProperties = false\n\n return {\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: jsonSchema,\n strict: true,\n },\n } satisfies FunctionTool\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,mCAAmC,MAA0B;CAC3E,MAAM,cAAe,KAAK,eAAe;EACvC,MAAM;EACN,YAAY,CAAC;EACb,UAAU,CAAC;CACb;CAGA,IAAI,YAAY,SAAS,YAAY,CAAC,YAAY,YAChD,YAAY,aAAa,CAAC;CAG5B,MAAM,aAAa,mCACjB,aACA,YAAY,YAAY,CAAC,CAC3B;CAEA,WAAW,uBAAuB;CAElC,OAAO;EACL,MAAM;EACN,UAAU;GACR,MAAM,KAAK;GACX,aAAa,KAAK;GAClB,YAAY;GACZ,QAAQ;EACV;CACF;AACF"}
@@ -1,7 +1,3 @@
1
1
  import { convertFunctionToolToAdapterFormat } from "./function-tool.js";
2
2
  import { convertToolsToProviderFormat } from "./tool-converter.js";
3
- export {
4
- convertFunctionToolToAdapterFormat,
5
- convertToolsToProviderFormat
6
- };
7
- //# sourceMappingURL=index.js.map
3
+ export { convertFunctionToolToAdapterFormat, convertToolsToProviderFormat };