@tanstack/ai-groq 0.4.11 → 0.4.13
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 +3 -3
- package/dist/esm/adapters/text.d.ts +0 -77
- package/dist/esm/adapters/text.js +0 -69
- package/dist/esm/adapters/text.js.map +0 -1
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/message-types.d.ts +0 -205
- package/dist/esm/model-meta.d.ts +0 -307
- package/dist/esm/model-meta.js +0 -54
- package/dist/esm/model-meta.js.map +0 -1
- package/dist/esm/text/text-provider-options.d.ts +0 -154
- package/dist/esm/tools/function-tool.d.ts +0 -13
- package/dist/esm/tools/function-tool.js +0 -29
- package/dist/esm/tools/function-tool.js.map +0 -1
- package/dist/esm/tools/index.d.ts +0 -2
- package/dist/esm/tools/index.js +0 -7
- package/dist/esm/tools/index.js.map +0 -1
- package/dist/esm/tools/tool-converter.d.ts +0 -7
- package/dist/esm/tools/tool-converter.js +0 -10
- package/dist/esm/tools/tool-converter.js.map +0 -1
- package/dist/esm/utils/client.d.ts +0 -15
- package/dist/esm/utils/client.js +0 -21
- package/dist/esm/utils/client.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -3
- package/dist/esm/utils/schema-converter.d.ts +0 -19
- package/dist/esm/utils/schema-converter.js +0 -73
- package/dist/esm/utils/schema-converter.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-groq",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"description": "Groq adapter for TanStack AI low-latency chat, tool calling, and structured outputs.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"zod": "^4.0.0",
|
|
56
|
-
"@tanstack/ai": "^0.
|
|
56
|
+
"@tanstack/ai": "^0.36.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"openai": "^6.41.0",
|
|
60
60
|
"@tanstack/ai-utils": "0.3.0",
|
|
61
|
-
"@tanstack/openai-base": "0.9.
|
|
61
|
+
"@tanstack/openai-base": "0.9.3"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "vite build",
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { default as OpenAI } from 'openai';
|
|
2
|
-
import { OpenAIBaseChatCompletionsTextAdapter } from '@tanstack/openai-base';
|
|
3
|
-
import { Modality, TextOptions } from '@tanstack/ai';
|
|
4
|
-
import { GROQ_CHAT_MODELS, GroqChatModelToolCapabilitiesByName, ResolveInputModalities, ResolveProviderOptions } from '../model-meta.js';
|
|
5
|
-
import { GroqMessageMetadataByModality } from '../message-types.js';
|
|
6
|
-
import { GroqClientConfig } from '../utils.js';
|
|
7
|
-
type ResolveToolCapabilities<TModel extends string> = TModel extends keyof GroqChatModelToolCapabilitiesByName ? NonNullable<GroqChatModelToolCapabilitiesByName[TModel]> : readonly [];
|
|
8
|
-
/**
|
|
9
|
-
* Configuration for Groq text adapter
|
|
10
|
-
*/
|
|
11
|
-
export interface GroqTextConfig extends GroqClientConfig {
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Re-export of the public provider options type
|
|
15
|
-
*/
|
|
16
|
-
export type { ExternalTextProviderOptions as GroqTextProviderOptions } from '../text/text-provider-options.js';
|
|
17
|
-
/**
|
|
18
|
-
* Groq Text (Chat) Adapter
|
|
19
|
-
*
|
|
20
|
-
* Tree-shakeable adapter for Groq chat/text completion. Groq exposes an
|
|
21
|
-
* OpenAI-compatible Chat Completions endpoint at `/openai/v1`, so we drive
|
|
22
|
-
* it with the OpenAI SDK via a `baseURL` override (the same pattern as
|
|
23
|
-
* `ai-grok`).
|
|
24
|
-
*
|
|
25
|
-
* Quirk: when usage is present on a stream, Groq historically delivered it
|
|
26
|
-
* under `chunk.x_groq.usage` rather than `chunk.usage`. The override below
|
|
27
|
-
* promotes it to the standard location so the base's RUN_FINISHED usage
|
|
28
|
-
* accounting works unchanged.
|
|
29
|
-
*/
|
|
30
|
-
export declare class GroqTextAdapter<TModel extends (typeof GROQ_CHAT_MODELS)[number], TProviderOptions extends Record<string, any> = ResolveProviderOptions<TModel>, TInputModalities extends ReadonlyArray<Modality> = ResolveInputModalities<TModel>, TToolCapabilities extends ReadonlyArray<string> = ResolveToolCapabilities<TModel>> extends OpenAIBaseChatCompletionsTextAdapter<TModel, TProviderOptions, TInputModalities, GroqMessageMetadataByModality, TToolCapabilities> {
|
|
31
|
-
readonly kind: "text";
|
|
32
|
-
readonly name: "groq";
|
|
33
|
-
constructor(config: GroqTextConfig, model: TModel);
|
|
34
|
-
protected makeStructuredOutputCompatible(schema: Record<string, any>, originalRequired?: Array<string>): Record<string, any>;
|
|
35
|
-
protected processStreamChunks(stream: AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>, options: TextOptions, aguiState: {
|
|
36
|
-
runId: string;
|
|
37
|
-
threadId: string;
|
|
38
|
-
messageId: string;
|
|
39
|
-
hasEmittedRunStarted: boolean;
|
|
40
|
-
}): AsyncGenerator<import('@tanstack/ai').AGUIEvent, void, any>;
|
|
41
|
-
/**
|
|
42
|
-
* Surfaces Groq's reasoning deltas during streaming structured output.
|
|
43
|
-
* Groq emits `delta.reasoning` (or legacy `delta.reasoning_content`) on
|
|
44
|
-
* reasoning models when the caller sets `reasoning_format: 'parsed'` in
|
|
45
|
-
* modelOptions. The base's chatStream and structuredOutputStream both
|
|
46
|
-
* route reasoning through this hook.
|
|
47
|
-
*/
|
|
48
|
-
protected extractReasoning(chunk: OpenAI.Chat.Completions.ChatCompletionChunk): {
|
|
49
|
-
text: string;
|
|
50
|
-
} | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Groq's API rejects `response_format: json_schema` together with `tools`
|
|
53
|
-
* + `stream` (returns 400 — see Groq Structured Outputs docs:
|
|
54
|
-
* "Streaming and tool use are not currently supported with Structured
|
|
55
|
-
* Outputs."). Force the engine onto the legacy finalization path even
|
|
56
|
-
* though the OpenAI Chat Completions base would otherwise opt in.
|
|
57
|
-
*/
|
|
58
|
-
supportsCombinedToolsAndSchema(): boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Creates a Groq text adapter with explicit API key.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const adapter = createGroqText('llama-3.3-70b-versatile', "gsk_...");
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function createGroqText<TModel extends (typeof GROQ_CHAT_MODELS)[number]>(model: TModel, apiKey: string, config?: Omit<GroqTextConfig, 'apiKey'>): GroqTextAdapter<TModel>;
|
|
69
|
-
/**
|
|
70
|
-
* Creates a Groq text adapter with API key from `GROQ_API_KEY`.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const adapter = groqText('llama-3.3-70b-versatile');
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function groqText<TModel extends (typeof GROQ_CHAT_MODELS)[number]>(model: TModel, config?: Omit<GroqTextConfig, 'apiKey'>): GroqTextAdapter<TModel>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
import { OpenAIBaseChatCompletionsTextAdapter } from "@tanstack/openai-base";
|
|
3
|
-
import { withGroqDefaults, getGroqApiKeyFromEnv } from "../utils/client.js";
|
|
4
|
-
import { makeGroqStructuredOutputCompatible } from "../utils/schema-converter.js";
|
|
5
|
-
class GroqTextAdapter extends OpenAIBaseChatCompletionsTextAdapter {
|
|
6
|
-
kind = "text";
|
|
7
|
-
name = "groq";
|
|
8
|
-
constructor(config, model) {
|
|
9
|
-
super(model, "groq", new OpenAI(withGroqDefaults(config)));
|
|
10
|
-
}
|
|
11
|
-
makeStructuredOutputCompatible(schema, originalRequired) {
|
|
12
|
-
return makeGroqStructuredOutputCompatible(schema, originalRequired);
|
|
13
|
-
}
|
|
14
|
-
async *processStreamChunks(stream, options, aguiState) {
|
|
15
|
-
yield* super.processStreamChunks(
|
|
16
|
-
promoteGroqUsage(stream),
|
|
17
|
-
options,
|
|
18
|
-
aguiState
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Surfaces Groq's reasoning deltas during streaming structured output.
|
|
23
|
-
* Groq emits `delta.reasoning` (or legacy `delta.reasoning_content`) on
|
|
24
|
-
* reasoning models when the caller sets `reasoning_format: 'parsed'` in
|
|
25
|
-
* modelOptions. The base's chatStream and structuredOutputStream both
|
|
26
|
-
* route reasoning through this hook.
|
|
27
|
-
*/
|
|
28
|
-
extractReasoning(chunk) {
|
|
29
|
-
const delta = chunk.choices[0]?.delta;
|
|
30
|
-
const raw = delta?.reasoning ?? delta?.reasoning_content;
|
|
31
|
-
if (typeof raw === "string" && raw.length > 0) {
|
|
32
|
-
return { text: raw };
|
|
33
|
-
}
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Groq's API rejects `response_format: json_schema` together with `tools`
|
|
38
|
-
* + `stream` (returns 400 — see Groq Structured Outputs docs:
|
|
39
|
-
* "Streaming and tool use are not currently supported with Structured
|
|
40
|
-
* Outputs."). Force the engine onto the legacy finalization path even
|
|
41
|
-
* though the OpenAI Chat Completions base would otherwise opt in.
|
|
42
|
-
*/
|
|
43
|
-
supportsCombinedToolsAndSchema() {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function* promoteGroqUsage(stream) {
|
|
48
|
-
for await (const chunk of stream) {
|
|
49
|
-
const groqChunk = chunk;
|
|
50
|
-
if (!chunk.usage && groqChunk.x_groq?.usage) {
|
|
51
|
-
yield { ...chunk, usage: groqChunk.x_groq.usage };
|
|
52
|
-
} else {
|
|
53
|
-
yield chunk;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function createGroqText(model, apiKey, config) {
|
|
58
|
-
return new GroqTextAdapter({ apiKey, ...config }, model);
|
|
59
|
-
}
|
|
60
|
-
function groqText(model, config) {
|
|
61
|
-
const apiKey = getGroqApiKeyFromEnv();
|
|
62
|
-
return createGroqText(model, apiKey, config);
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
GroqTextAdapter,
|
|
66
|
-
createGroqText,
|
|
67
|
-
groqText
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sources":["../../../src/adapters/text.ts"],"sourcesContent":["import OpenAI from 'openai'\nimport { OpenAIBaseChatCompletionsTextAdapter } from '@tanstack/openai-base'\nimport { getGroqApiKeyFromEnv, withGroqDefaults } from '../utils/client'\nimport { makeGroqStructuredOutputCompatible } from '../utils/schema-converter'\nimport type { Modality, TextOptions } from '@tanstack/ai'\nimport type {\n GROQ_CHAT_MODELS,\n GroqChatModelToolCapabilitiesByName,\n ResolveInputModalities,\n ResolveProviderOptions,\n} from '../model-meta'\nimport type { GroqMessageMetadataByModality } from '../message-types'\nimport type { GroqClientConfig } from '../utils'\n\ntype ResolveToolCapabilities<TModel extends string> =\n TModel extends keyof GroqChatModelToolCapabilitiesByName\n ? NonNullable<GroqChatModelToolCapabilitiesByName[TModel]>\n : readonly []\n\n/**\n * Configuration for Groq text adapter\n */\nexport interface GroqTextConfig extends GroqClientConfig {}\n\n/**\n * Re-export of the public provider options type\n */\nexport type { ExternalTextProviderOptions as GroqTextProviderOptions } from '../text/text-provider-options'\n\n/**\n * Groq Text (Chat) Adapter\n *\n * Tree-shakeable adapter for Groq chat/text completion. Groq exposes an\n * OpenAI-compatible Chat Completions endpoint at `/openai/v1`, so we drive\n * it with the OpenAI SDK via a `baseURL` override (the same pattern as\n * `ai-grok`).\n *\n * Quirk: when usage is present on a stream, Groq historically delivered it\n * under `chunk.x_groq.usage` rather than `chunk.usage`. The override below\n * promotes it to the standard location so the base's RUN_FINISHED usage\n * accounting works unchanged.\n */\nexport class GroqTextAdapter<\n TModel extends (typeof GROQ_CHAT_MODELS)[number],\n TProviderOptions extends Record<string, any> = ResolveProviderOptions<TModel>,\n TInputModalities extends ReadonlyArray<Modality> =\n ResolveInputModalities<TModel>,\n TToolCapabilities extends ReadonlyArray<string> =\n ResolveToolCapabilities<TModel>,\n> extends OpenAIBaseChatCompletionsTextAdapter<\n TModel,\n TProviderOptions,\n TInputModalities,\n GroqMessageMetadataByModality,\n TToolCapabilities\n> {\n override readonly kind = 'text' as const\n override readonly name = 'groq' as const\n\n constructor(config: GroqTextConfig, model: TModel) {\n super(model, 'groq', new OpenAI(withGroqDefaults(config)))\n }\n\n protected override makeStructuredOutputCompatible(\n schema: Record<string, any>,\n originalRequired?: Array<string>,\n ): Record<string, any> {\n return makeGroqStructuredOutputCompatible(schema, originalRequired)\n }\n\n protected override async *processStreamChunks(\n stream: AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>,\n options: TextOptions,\n aguiState: {\n runId: string\n threadId: string\n messageId: string\n hasEmittedRunStarted: boolean\n },\n ) {\n yield* super.processStreamChunks(\n promoteGroqUsage(stream),\n options,\n aguiState,\n )\n }\n\n /**\n * Surfaces Groq's reasoning deltas during streaming structured output.\n * Groq emits `delta.reasoning` (or legacy `delta.reasoning_content`) on\n * reasoning models when the caller sets `reasoning_format: 'parsed'` in\n * modelOptions. The base's chatStream and structuredOutputStream both\n * route reasoning through this hook.\n */\n protected override extractReasoning(\n chunk: OpenAI.Chat.Completions.ChatCompletionChunk,\n ): { text: string } | undefined {\n const delta = chunk.choices[0]?.delta as\n | { reasoning?: unknown; reasoning_content?: unknown }\n | undefined\n const raw = delta?.reasoning ?? delta?.reasoning_content\n if (typeof raw === 'string' && raw.length > 0) {\n return { text: raw }\n }\n return undefined\n }\n\n /**\n * Groq's API rejects `response_format: json_schema` together with `tools`\n * + `stream` (returns 400 — see Groq Structured Outputs docs:\n * \"Streaming and tool use are not currently supported with Structured\n * Outputs.\"). Force the engine onto the legacy finalization path even\n * though the OpenAI Chat Completions base would otherwise opt in.\n */\n override supportsCombinedToolsAndSchema(): boolean {\n return false\n }\n}\n\n/**\n * Promotes Groq's non-standard `x_groq.usage` to the standard `chunk.usage`\n * slot the base reads. Pass-through for chunks that already carry usage at\n * the documented location.\n */\nasync function* promoteGroqUsage(\n stream: AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>,\n): AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk> {\n for await (const chunk of stream) {\n const groqChunk = chunk as typeof chunk & {\n x_groq?: { usage?: OpenAI.Chat.Completions.ChatCompletionChunk['usage'] }\n }\n if (!chunk.usage && groqChunk.x_groq?.usage) {\n yield { ...chunk, usage: groqChunk.x_groq.usage }\n } else {\n yield chunk\n }\n }\n}\n\n/**\n * Creates a Groq text adapter with explicit API key.\n *\n * @example\n * ```typescript\n * const adapter = createGroqText('llama-3.3-70b-versatile', \"gsk_...\");\n * ```\n */\nexport function createGroqText<\n TModel extends (typeof GROQ_CHAT_MODELS)[number],\n>(\n model: TModel,\n apiKey: string,\n config?: Omit<GroqTextConfig, 'apiKey'>,\n): GroqTextAdapter<TModel> {\n return new GroqTextAdapter({ apiKey, ...config }, model)\n}\n\n/**\n * Creates a Groq text adapter with API key from `GROQ_API_KEY`.\n *\n * @example\n * ```typescript\n * const adapter = groqText('llama-3.3-70b-versatile');\n * ```\n */\nexport function groqText<TModel extends (typeof GROQ_CHAT_MODELS)[number]>(\n model: TModel,\n config?: Omit<GroqTextConfig, 'apiKey'>,\n): GroqTextAdapter<TModel> {\n const apiKey = getGroqApiKeyFromEnv()\n return createGroqText(model, apiKey, config)\n}\n"],"names":[],"mappings":";;;;AA0CO,MAAM,wBAOH,qCAMR;AAAA,EACkB,OAAO;AAAA,EACP,OAAO;AAAA,EAEzB,YAAY,QAAwB,OAAe;AACjD,UAAM,OAAO,QAAQ,IAAI,OAAO,iBAAiB,MAAM,CAAC,CAAC;AAAA,EAC3D;AAAA,EAEmB,+BACjB,QACA,kBACqB;AACrB,WAAO,mCAAmC,QAAQ,gBAAgB;AAAA,EACpE;AAAA,EAEA,OAA0B,oBACxB,QACA,SACA,WAMA;AACA,WAAO,MAAM;AAAA,MACX,iBAAiB,MAAM;AAAA,MACvB;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASmB,iBACjB,OAC8B;AAC9B,UAAM,QAAQ,MAAM,QAAQ,CAAC,GAAG;AAGhC,UAAM,MAAM,OAAO,aAAa,OAAO;AACvC,QAAI,OAAO,QAAQ,YAAY,IAAI,SAAS,GAAG;AAC7C,aAAO,EAAE,MAAM,IAAA;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASS,iCAA0C;AACjD,WAAO;AAAA,EACT;AACF;AAOA,gBAAgB,iBACd,QAC4D;AAC5D,mBAAiB,SAAS,QAAQ;AAChC,UAAM,YAAY;AAGlB,QAAI,CAAC,MAAM,SAAS,UAAU,QAAQ,OAAO;AAC3C,YAAM,EAAE,GAAG,OAAO,OAAO,UAAU,OAAO,MAAA;AAAA,IAC5C,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAUO,SAAS,eAGd,OACA,QACA,QACyB;AACzB,SAAO,IAAI,gBAAgB,EAAE,QAAQ,GAAG,OAAA,GAAU,KAAK;AACzD;AAUO,SAAS,SACd,OACA,QACyB;AACzB,QAAM,SAAS,qBAAA;AACf,SAAO,eAAe,OAAO,QAAQ,MAAM;AAC7C;"}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @tanstack/ai-groq
|
|
3
|
-
*
|
|
4
|
-
* Groq provider adapter for TanStack AI.
|
|
5
|
-
* Provides tree-shakeable adapters for Groq's Chat Completions API.
|
|
6
|
-
*/
|
|
7
|
-
export { GroqTextAdapter, createGroqText, groqText, type GroqTextConfig, type GroqTextProviderOptions, } from './adapters/text.js';
|
|
8
|
-
export type { GroqChatModelProviderOptionsByName, GroqChatModelToolCapabilitiesByName, GroqModelInputModalitiesByName, ResolveProviderOptions, ResolveInputModalities, GroqChatModels, } from './model-meta.js';
|
|
9
|
-
export { GROQ_CHAT_MODELS } from './model-meta.js';
|
|
10
|
-
export type { GroqTextMetadata, GroqImageMetadata, GroqAudioMetadata, GroqVideoMetadata, GroqDocumentMetadata, GroqMessageMetadataByModality, } from './message-types.js';
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Groq-specific message types for the Chat Completions API.
|
|
3
|
-
*
|
|
4
|
-
* Groq's wire format is OpenAI Chat Completions plus a few Groq-specific
|
|
5
|
-
* extensions (compound tools, citation/service-tier provider options,
|
|
6
|
-
* etc.). These type definitions describe that wire shape directly — the
|
|
7
|
-
* Groq SDK was dropped in favour of pointing the OpenAI SDK at Groq's
|
|
8
|
-
* `/openai/v1` base URL, so this file is the source of truth for
|
|
9
|
-
* Groq-only fields rather than a mirror of an external SDK's types.
|
|
10
|
-
*
|
|
11
|
-
* @see https://console.groq.com/docs/api-reference#chat
|
|
12
|
-
*/
|
|
13
|
-
export type FunctionParameters = {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
export interface ChatCompletionNamedToolChoice {
|
|
17
|
-
/** Always `function` for a named tool choice. */
|
|
18
|
-
type: 'function';
|
|
19
|
-
function: {
|
|
20
|
-
/** The name of the function to call. */
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface FunctionDefinition {
|
|
25
|
-
/**
|
|
26
|
-
* The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
|
|
27
|
-
* underscores and dashes, with a maximum length of 64.
|
|
28
|
-
*/
|
|
29
|
-
name: string;
|
|
30
|
-
/**
|
|
31
|
-
* A description of what the function does, used by the model to choose when and
|
|
32
|
-
* how to call the function.
|
|
33
|
-
*/
|
|
34
|
-
description?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Function parameters defined as a JSON Schema object.
|
|
37
|
-
* @see https://json-schema.org/understanding-json-schema/
|
|
38
|
-
*/
|
|
39
|
-
parameters?: FunctionParameters;
|
|
40
|
-
/**
|
|
41
|
-
* Whether to enable strict schema adherence when generating the output. If set to
|
|
42
|
-
* true, the model will always follow the exact schema defined in the `schema`
|
|
43
|
-
* field. Only a subset of JSON Schema is supported when `strict` is `true`.
|
|
44
|
-
*/
|
|
45
|
-
strict?: boolean;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Controls which (if any) tool is called by the model.
|
|
49
|
-
*
|
|
50
|
-
* - `none` — the model will not call any tool and instead generates a message
|
|
51
|
-
* - `auto` — the model can pick between generating a message or calling tools
|
|
52
|
-
* - `required` — the model must call one or more tools
|
|
53
|
-
* - Named tool choice — forces the model to call a specific tool
|
|
54
|
-
*/
|
|
55
|
-
export type ChatCompletionToolChoiceOption = 'none' | 'auto' | 'required' | ChatCompletionNamedToolChoice;
|
|
56
|
-
export interface ChatCompletionTool {
|
|
57
|
-
/**
|
|
58
|
-
* The type of the tool. `function`, `browser_search`, and `code_interpreter` are
|
|
59
|
-
* supported.
|
|
60
|
-
*/
|
|
61
|
-
type: 'function' | 'browser_search' | 'code_interpreter' | (string & {});
|
|
62
|
-
function?: FunctionDefinition;
|
|
63
|
-
}
|
|
64
|
-
export interface CompoundCustomModels {
|
|
65
|
-
/** Custom model to use for answering. */
|
|
66
|
-
answering_model?: string | null;
|
|
67
|
-
/** Custom model to use for reasoning. */
|
|
68
|
-
reasoning_model?: string | null;
|
|
69
|
-
}
|
|
70
|
-
export interface CompoundCustomTools {
|
|
71
|
-
/** A list of tool names that are enabled for the request. */
|
|
72
|
-
enabled_tools?: Array<string> | null;
|
|
73
|
-
/** Configuration for the Wolfram tool integration. */
|
|
74
|
-
wolfram_settings?: CompoundCustomToolsWolframSettings | null;
|
|
75
|
-
}
|
|
76
|
-
export interface CompoundCustomToolsWolframSettings {
|
|
77
|
-
/** API key used to authorize requests to Wolfram services. */
|
|
78
|
-
authorization?: string | null;
|
|
79
|
-
}
|
|
80
|
-
export interface CompoundCustom {
|
|
81
|
-
models?: CompoundCustomModels | null;
|
|
82
|
-
/** Configuration options for tools available to Compound. */
|
|
83
|
-
tools?: CompoundCustomTools | null;
|
|
84
|
-
}
|
|
85
|
-
export interface DocumentSourceText {
|
|
86
|
-
/** The document contents. */
|
|
87
|
-
text: string;
|
|
88
|
-
/** Identifies this document source as inline text. */
|
|
89
|
-
type: 'text';
|
|
90
|
-
}
|
|
91
|
-
export interface DocumentSourceJson {
|
|
92
|
-
/** The JSON payload associated with the document. */
|
|
93
|
-
data: {
|
|
94
|
-
[key: string]: unknown;
|
|
95
|
-
};
|
|
96
|
-
/** Identifies this document source as JSON data. */
|
|
97
|
-
type: 'json';
|
|
98
|
-
}
|
|
99
|
-
export interface Document {
|
|
100
|
-
/** The source of the document. Only text and JSON sources are currently supported. */
|
|
101
|
-
source: DocumentSourceText | DocumentSourceJson;
|
|
102
|
-
/** Optional unique identifier that can be used for citations in responses. */
|
|
103
|
-
id?: string | null;
|
|
104
|
-
}
|
|
105
|
-
export interface ResponseFormatText {
|
|
106
|
-
/** The type of response format being defined. Always `text`. */
|
|
107
|
-
type: 'text';
|
|
108
|
-
}
|
|
109
|
-
export interface ResponseFormatJsonSchemaJsonSchema {
|
|
110
|
-
/**
|
|
111
|
-
* The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
|
|
112
|
-
* and dashes, with a maximum length of 64.
|
|
113
|
-
*/
|
|
114
|
-
name: string;
|
|
115
|
-
/**
|
|
116
|
-
* A description of what the response format is for, used by the model to determine
|
|
117
|
-
* how to respond in the format.
|
|
118
|
-
*/
|
|
119
|
-
description?: string;
|
|
120
|
-
/**
|
|
121
|
-
* The schema for the response format, described as a JSON Schema object.
|
|
122
|
-
* @see https://json-schema.org/
|
|
123
|
-
*/
|
|
124
|
-
schema?: {
|
|
125
|
-
[key: string]: unknown;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Whether to enable strict schema adherence when generating the output. If set to
|
|
129
|
-
* true, the model will always follow the exact schema defined in the `schema`
|
|
130
|
-
* field. Only a subset of JSON Schema is supported when `strict` is `true`.
|
|
131
|
-
*/
|
|
132
|
-
strict?: boolean | null;
|
|
133
|
-
}
|
|
134
|
-
export interface ResponseFormatJsonSchema {
|
|
135
|
-
/** Structured Outputs configuration options, including a JSON Schema. */
|
|
136
|
-
json_schema: ResponseFormatJsonSchemaJsonSchema;
|
|
137
|
-
/** The type of response format being defined. Always `json_schema`. */
|
|
138
|
-
type: 'json_schema';
|
|
139
|
-
}
|
|
140
|
-
export interface ResponseFormatJsonObject {
|
|
141
|
-
/** The type of response format being defined. Always `json_object`. */
|
|
142
|
-
type: 'json_object';
|
|
143
|
-
}
|
|
144
|
-
export interface SearchSettings {
|
|
145
|
-
/**
|
|
146
|
-
* Name of country to prioritize search results from
|
|
147
|
-
* (e.g., "united states", "germany", "france").
|
|
148
|
-
*/
|
|
149
|
-
country?: string | null;
|
|
150
|
-
/** A list of domains to exclude from the search results. */
|
|
151
|
-
exclude_domains?: Array<string> | null;
|
|
152
|
-
/** A list of domains to include in the search results. */
|
|
153
|
-
include_domains?: Array<string> | null;
|
|
154
|
-
/** Whether to include images in the search results. */
|
|
155
|
-
include_images?: boolean | null;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Metadata for Groq document content parts.
|
|
159
|
-
*/
|
|
160
|
-
export interface GroqDocumentMetadata {
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Metadata for Groq text content parts.
|
|
164
|
-
* Currently no specific metadata options for text in Groq.
|
|
165
|
-
*/
|
|
166
|
-
export interface GroqTextMetadata {
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Metadata for Groq image content parts.
|
|
170
|
-
* Controls how the model processes and analyzes images.
|
|
171
|
-
*/
|
|
172
|
-
export interface GroqImageMetadata {
|
|
173
|
-
/**
|
|
174
|
-
* Specifies the detail level of the image.
|
|
175
|
-
* - 'auto': Let the model decide based on image size and content
|
|
176
|
-
* - 'low': Use low resolution processing (faster, cheaper, less detail)
|
|
177
|
-
* - 'high': Use high resolution processing (slower, more expensive, more detail)
|
|
178
|
-
*
|
|
179
|
-
* @default 'auto'
|
|
180
|
-
*/
|
|
181
|
-
detail?: 'auto' | 'low' | 'high';
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Metadata for Groq audio content parts.
|
|
185
|
-
* Note: Audio support in Groq is limited; check current API capabilities.
|
|
186
|
-
*/
|
|
187
|
-
export interface GroqAudioMetadata {
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Metadata for Groq video content parts.
|
|
191
|
-
* Note: Groq does not currently support video input.
|
|
192
|
-
*/
|
|
193
|
-
export interface GroqVideoMetadata {
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Map of modality types to their Groq-specific metadata types.
|
|
197
|
-
* Used for type inference when constructing multimodal messages.
|
|
198
|
-
*/
|
|
199
|
-
export interface GroqMessageMetadataByModality {
|
|
200
|
-
text: GroqTextMetadata;
|
|
201
|
-
image: GroqImageMetadata;
|
|
202
|
-
audio: GroqAudioMetadata;
|
|
203
|
-
video: GroqVideoMetadata;
|
|
204
|
-
document: GroqDocumentMetadata;
|
|
205
|
-
}
|
package/dist/esm/model-meta.d.ts
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import { GroqTextProviderOptions } from './text/text-provider-options.js';
|
|
2
|
-
declare const LLAMA_3_3_70B_VERSATILE: {
|
|
3
|
-
readonly name: "llama-3.3-70b-versatile";
|
|
4
|
-
readonly context_window: 131072;
|
|
5
|
-
readonly max_completion_tokens: 32768;
|
|
6
|
-
readonly pricing: {
|
|
7
|
-
readonly input: {
|
|
8
|
-
readonly normal: 0.59;
|
|
9
|
-
};
|
|
10
|
-
readonly output: {
|
|
11
|
-
readonly normal: 0.79;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
readonly supports: {
|
|
15
|
-
readonly input: ["text"];
|
|
16
|
-
readonly output: ["text"];
|
|
17
|
-
readonly endpoints: ["chat"];
|
|
18
|
-
readonly features: ["streaming", "tools", "json_object"];
|
|
19
|
-
readonly tools: readonly [];
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
declare const LLAMA_4_MAVERICK_17B_128E_INSTRUCT: {
|
|
23
|
-
readonly name: "meta-llama/llama-4-maverick-17b-128e-instruct";
|
|
24
|
-
readonly context_window: 131072;
|
|
25
|
-
readonly max_completion_tokens: 8192;
|
|
26
|
-
readonly pricing: {
|
|
27
|
-
readonly input: {
|
|
28
|
-
readonly normal: 0.2;
|
|
29
|
-
};
|
|
30
|
-
readonly output: {
|
|
31
|
-
readonly normal: 0.6;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
readonly supports: {
|
|
35
|
-
readonly input: ["text", "image"];
|
|
36
|
-
readonly output: ["text"];
|
|
37
|
-
readonly endpoints: ["chat"];
|
|
38
|
-
readonly features: ["streaming", "tools", "json_object", "json_schema", "vision"];
|
|
39
|
-
readonly tools: readonly [];
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
declare const LLAMA_4_SCOUT_17B_16E_INSTRUCT: {
|
|
43
|
-
readonly name: "meta-llama/llama-4-scout-17b-16e-instruct";
|
|
44
|
-
readonly context_window: 131072;
|
|
45
|
-
readonly max_completion_tokens: 8192;
|
|
46
|
-
readonly pricing: {
|
|
47
|
-
readonly input: {
|
|
48
|
-
readonly normal: 0.05;
|
|
49
|
-
};
|
|
50
|
-
readonly output: {
|
|
51
|
-
readonly normal: 0.08;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
readonly supports: {
|
|
55
|
-
readonly input: ["text", "image"];
|
|
56
|
-
readonly output: ["text"];
|
|
57
|
-
readonly endpoints: ["chat"];
|
|
58
|
-
readonly features: ["streaming", "tools", "json_object"];
|
|
59
|
-
readonly tools: readonly [];
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
declare const LLAMA_GUARD_4_12B: {
|
|
63
|
-
readonly name: "meta-llama/llama-guard-4-12b";
|
|
64
|
-
readonly context_window: 131072;
|
|
65
|
-
readonly max_completion_tokens: 1024;
|
|
66
|
-
readonly pricing: {
|
|
67
|
-
readonly input: {
|
|
68
|
-
readonly normal: 0.2;
|
|
69
|
-
};
|
|
70
|
-
readonly output: {
|
|
71
|
-
readonly normal: 0.2;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
readonly supports: {
|
|
75
|
-
readonly input: ["text", "image"];
|
|
76
|
-
readonly output: ["text"];
|
|
77
|
-
readonly endpoints: ["chat"];
|
|
78
|
-
readonly features: ["streaming", "json_object", "content_moderation", "vision"];
|
|
79
|
-
readonly tools: readonly [];
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
declare const LLAMA_PROMPT_GUARD_2_86M: {
|
|
83
|
-
readonly name: "meta-llama/llama-prompt-guard-2-86m";
|
|
84
|
-
readonly context_window: 512;
|
|
85
|
-
readonly max_completion_tokens: 512;
|
|
86
|
-
readonly pricing: {
|
|
87
|
-
readonly input: {
|
|
88
|
-
readonly normal: 0.04;
|
|
89
|
-
};
|
|
90
|
-
readonly output: {
|
|
91
|
-
readonly normal: 0.04;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
readonly supports: {
|
|
95
|
-
readonly input: ["text"];
|
|
96
|
-
readonly output: ["text"];
|
|
97
|
-
readonly endpoints: ["chat"];
|
|
98
|
-
readonly features: ["streaming", "content_moderation", "json_object"];
|
|
99
|
-
readonly tools: readonly [];
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
declare const LLAMA_3_1_8B_INSTANT: {
|
|
103
|
-
readonly name: "llama-3.1-8b-instant";
|
|
104
|
-
readonly context_window: 131072;
|
|
105
|
-
readonly max_completion_tokens: 131072;
|
|
106
|
-
readonly pricing: {
|
|
107
|
-
readonly input: {
|
|
108
|
-
readonly normal: 0.05;
|
|
109
|
-
};
|
|
110
|
-
readonly output: {
|
|
111
|
-
readonly normal: 0.08;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
readonly supports: {
|
|
115
|
-
readonly input: ["text"];
|
|
116
|
-
readonly output: ["text"];
|
|
117
|
-
readonly endpoints: ["chat"];
|
|
118
|
-
readonly features: ["streaming", "json_object", "tools"];
|
|
119
|
-
readonly tools: readonly [];
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
declare const LLAMA_PROMPT_GUARD_2_22M: {
|
|
123
|
-
readonly name: "meta-llama/llama-prompt-guard-2-22m";
|
|
124
|
-
readonly context_window: 512;
|
|
125
|
-
readonly max_completion_tokens: 512;
|
|
126
|
-
readonly pricing: {
|
|
127
|
-
readonly input: {
|
|
128
|
-
readonly normal: 0.03;
|
|
129
|
-
};
|
|
130
|
-
readonly output: {
|
|
131
|
-
readonly normal: 0.03;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
readonly supports: {
|
|
135
|
-
readonly input: ["text"];
|
|
136
|
-
readonly output: ["text"];
|
|
137
|
-
readonly endpoints: ["chat"];
|
|
138
|
-
readonly features: ["streaming", "content_moderation"];
|
|
139
|
-
readonly tools: readonly [];
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
declare const GPT_OSS_120B: {
|
|
143
|
-
readonly name: "openai/gpt-oss-120b";
|
|
144
|
-
readonly context_window: 131072;
|
|
145
|
-
readonly max_completion_tokens: 65536;
|
|
146
|
-
readonly pricing: {
|
|
147
|
-
readonly input: {
|
|
148
|
-
readonly normal: 0.15;
|
|
149
|
-
readonly cached: 0.075;
|
|
150
|
-
};
|
|
151
|
-
readonly output: {
|
|
152
|
-
readonly normal: 0.6;
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
readonly supports: {
|
|
156
|
-
readonly input: ["text"];
|
|
157
|
-
readonly output: ["text"];
|
|
158
|
-
readonly endpoints: ["chat"];
|
|
159
|
-
readonly features: ["streaming", "json_object", "json_schema", "tools", "browser_search", "code_execution", "reasoning"];
|
|
160
|
-
readonly tools: readonly [];
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
declare const GPT_OSS_SAFEGUARD_20B: {
|
|
164
|
-
readonly name: "openai/gpt-oss-safeguard-20b";
|
|
165
|
-
readonly context_window: 131072;
|
|
166
|
-
readonly max_completion_tokens: 65536;
|
|
167
|
-
readonly pricing: {
|
|
168
|
-
readonly input: {
|
|
169
|
-
readonly normal: 0.075;
|
|
170
|
-
readonly cached: 0.037;
|
|
171
|
-
};
|
|
172
|
-
readonly output: {
|
|
173
|
-
readonly normal: 0.3;
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
readonly supports: {
|
|
177
|
-
readonly input: ["text"];
|
|
178
|
-
readonly output: ["text"];
|
|
179
|
-
readonly endpoints: ["chat"];
|
|
180
|
-
readonly features: ["streaming", "tools", "browser_search", "code_execution", "json_object", "json_schema", "reasoning", "content_moderation"];
|
|
181
|
-
readonly tools: readonly [];
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
declare const GPT_OSS_20B: {
|
|
185
|
-
readonly name: "openai/gpt-oss-20b";
|
|
186
|
-
readonly context_window: 131072;
|
|
187
|
-
readonly max_completion_tokens: 65536;
|
|
188
|
-
readonly pricing: {
|
|
189
|
-
readonly input: {
|
|
190
|
-
readonly normal: 0.075;
|
|
191
|
-
readonly cached: 0.037;
|
|
192
|
-
};
|
|
193
|
-
readonly output: {
|
|
194
|
-
readonly normal: 0.3;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
readonly supports: {
|
|
198
|
-
readonly input: ["text"];
|
|
199
|
-
readonly output: ["text"];
|
|
200
|
-
readonly endpoints: ["chat"];
|
|
201
|
-
readonly features: ["streaming", "browser_search", "code_execution", "json_object", "json_schema", "reasoning", "tools"];
|
|
202
|
-
readonly tools: readonly [];
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
declare const KIMI_K2_INSTRUCT_0905: {
|
|
206
|
-
readonly name: "moonshotai/kimi-k2-instruct-0905";
|
|
207
|
-
readonly context_window: 262144;
|
|
208
|
-
readonly max_completion_tokens: 16384;
|
|
209
|
-
readonly pricing: {
|
|
210
|
-
readonly input: {
|
|
211
|
-
readonly normal: 1;
|
|
212
|
-
readonly cached: 0.5;
|
|
213
|
-
};
|
|
214
|
-
readonly output: {
|
|
215
|
-
readonly normal: 3;
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
readonly supports: {
|
|
219
|
-
readonly input: ["text"];
|
|
220
|
-
readonly output: ["text"];
|
|
221
|
-
readonly endpoints: ["chat"];
|
|
222
|
-
readonly features: ["streaming", "tools", "json_object", "json_schema"];
|
|
223
|
-
readonly tools: readonly [];
|
|
224
|
-
};
|
|
225
|
-
};
|
|
226
|
-
declare const QWEN3_32B: {
|
|
227
|
-
readonly name: "qwen/qwen3-32b";
|
|
228
|
-
readonly context_window: 131072;
|
|
229
|
-
readonly max_completion_tokens: 40960;
|
|
230
|
-
readonly pricing: {
|
|
231
|
-
readonly input: {
|
|
232
|
-
readonly normal: 0.29;
|
|
233
|
-
};
|
|
234
|
-
readonly output: {
|
|
235
|
-
readonly normal: 0.59;
|
|
236
|
-
};
|
|
237
|
-
};
|
|
238
|
-
readonly supports: {
|
|
239
|
-
readonly input: ["text"];
|
|
240
|
-
readonly output: ["text"];
|
|
241
|
-
readonly endpoints: ["chat"];
|
|
242
|
-
readonly features: ["streaming", "json_object", "tools", "reasoning"];
|
|
243
|
-
readonly tools: readonly [];
|
|
244
|
-
};
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* All supported Groq chat model identifiers.
|
|
248
|
-
*/
|
|
249
|
-
export declare const GROQ_CHAT_MODELS: readonly ["llama-3.1-8b-instant", "llama-3.3-70b-versatile", "meta-llama/llama-4-maverick-17b-128e-instruct", "meta-llama/llama-4-scout-17b-16e-instruct", "meta-llama/llama-guard-4-12b", "meta-llama/llama-prompt-guard-2-86m", "meta-llama/llama-prompt-guard-2-22m", "openai/gpt-oss-20b", "openai/gpt-oss-120b", "openai/gpt-oss-safeguard-20b", "moonshotai/kimi-k2-instruct-0905", "qwen/qwen3-32b"];
|
|
250
|
-
/**
|
|
251
|
-
* Union type of all supported Groq chat model names.
|
|
252
|
-
*/
|
|
253
|
-
export type GroqChatModels = (typeof GROQ_CHAT_MODELS)[number];
|
|
254
|
-
/**
|
|
255
|
-
* Type-only map from Groq chat model name to its supported input modalities.
|
|
256
|
-
*/
|
|
257
|
-
export type GroqModelInputModalitiesByName = {
|
|
258
|
-
[LLAMA_3_1_8B_INSTANT.name]: typeof LLAMA_3_1_8B_INSTANT.supports.input;
|
|
259
|
-
[LLAMA_3_3_70B_VERSATILE.name]: typeof LLAMA_3_3_70B_VERSATILE.supports.input;
|
|
260
|
-
[LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name]: typeof LLAMA_4_MAVERICK_17B_128E_INSTRUCT.supports.input;
|
|
261
|
-
[LLAMA_4_SCOUT_17B_16E_INSTRUCT.name]: typeof LLAMA_4_SCOUT_17B_16E_INSTRUCT.supports.input;
|
|
262
|
-
[LLAMA_GUARD_4_12B.name]: typeof LLAMA_GUARD_4_12B.supports.input;
|
|
263
|
-
[LLAMA_PROMPT_GUARD_2_86M.name]: typeof LLAMA_PROMPT_GUARD_2_86M.supports.input;
|
|
264
|
-
[LLAMA_PROMPT_GUARD_2_22M.name]: typeof LLAMA_PROMPT_GUARD_2_22M.supports.input;
|
|
265
|
-
[GPT_OSS_20B.name]: typeof GPT_OSS_20B.supports.input;
|
|
266
|
-
[GPT_OSS_120B.name]: typeof GPT_OSS_120B.supports.input;
|
|
267
|
-
[GPT_OSS_SAFEGUARD_20B.name]: typeof GPT_OSS_SAFEGUARD_20B.supports.input;
|
|
268
|
-
[KIMI_K2_INSTRUCT_0905.name]: typeof KIMI_K2_INSTRUCT_0905.supports.input;
|
|
269
|
-
[QWEN3_32B.name]: typeof QWEN3_32B.supports.input;
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* Type-only map from Groq chat model name to its provider options type.
|
|
273
|
-
*/
|
|
274
|
-
export type GroqChatModelProviderOptionsByName = {
|
|
275
|
-
[K in (typeof GROQ_CHAT_MODELS)[number]]: GroqTextProviderOptions;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Type-only map from Groq chat model name to its supported provider tools.
|
|
279
|
-
* Groq exposes no provider-specific tool factories, so every model gets an
|
|
280
|
-
* empty tuple. This ensures that passing an Anthropic/OpenAI ProviderTool to
|
|
281
|
-
* a Groq adapter produces a compile-time type error.
|
|
282
|
-
*/
|
|
283
|
-
export type GroqChatModelToolCapabilitiesByName = {
|
|
284
|
-
[LLAMA_3_1_8B_INSTANT.name]: typeof LLAMA_3_1_8B_INSTANT.supports.tools;
|
|
285
|
-
[LLAMA_3_3_70B_VERSATILE.name]: typeof LLAMA_3_3_70B_VERSATILE.supports.tools;
|
|
286
|
-
[LLAMA_4_MAVERICK_17B_128E_INSTRUCT.name]: typeof LLAMA_4_MAVERICK_17B_128E_INSTRUCT.supports.tools;
|
|
287
|
-
[LLAMA_4_SCOUT_17B_16E_INSTRUCT.name]: typeof LLAMA_4_SCOUT_17B_16E_INSTRUCT.supports.tools;
|
|
288
|
-
[LLAMA_GUARD_4_12B.name]: typeof LLAMA_GUARD_4_12B.supports.tools;
|
|
289
|
-
[LLAMA_PROMPT_GUARD_2_86M.name]: typeof LLAMA_PROMPT_GUARD_2_86M.supports.tools;
|
|
290
|
-
[LLAMA_PROMPT_GUARD_2_22M.name]: typeof LLAMA_PROMPT_GUARD_2_22M.supports.tools;
|
|
291
|
-
[GPT_OSS_20B.name]: typeof GPT_OSS_20B.supports.tools;
|
|
292
|
-
[GPT_OSS_120B.name]: typeof GPT_OSS_120B.supports.tools;
|
|
293
|
-
[GPT_OSS_SAFEGUARD_20B.name]: typeof GPT_OSS_SAFEGUARD_20B.supports.tools;
|
|
294
|
-
[KIMI_K2_INSTRUCT_0905.name]: typeof KIMI_K2_INSTRUCT_0905.supports.tools;
|
|
295
|
-
[QWEN3_32B.name]: typeof QWEN3_32B.supports.tools;
|
|
296
|
-
};
|
|
297
|
-
/**
|
|
298
|
-
* Resolves the provider options type for a specific Groq model.
|
|
299
|
-
* Falls back to generic GroqTextProviderOptions for unknown models.
|
|
300
|
-
*/
|
|
301
|
-
export type ResolveProviderOptions<TModel extends string> = TModel extends keyof GroqChatModelProviderOptionsByName ? GroqChatModelProviderOptionsByName[TModel] : GroqTextProviderOptions;
|
|
302
|
-
/**
|
|
303
|
-
* Resolve input modalities for a specific model.
|
|
304
|
-
* If the model has explicit modalities in the map, use those; otherwise use text only.
|
|
305
|
-
*/
|
|
306
|
-
export type ResolveInputModalities<TModel extends string> = TModel extends keyof GroqModelInputModalitiesByName ? GroqModelInputModalitiesByName[TModel] : readonly ['text'];
|
|
307
|
-
export {};
|
package/dist/esm/model-meta.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
50
|
-
];
|
|
51
|
-
export {
|
|
52
|
-
GROQ_CHAT_MODELS
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=model-meta.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import type { GroqTextProviderOptions } from './text/text-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 * Resolves the provider options type for a specific Groq model.\n * Falls back to generic GroqTextProviderOptions for unknown models.\n */\nexport type ResolveProviderOptions<TModel extends string> =\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"],"names":[],"mappings":"AAqCA,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;"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { ChatCompletionToolChoiceOption, CompoundCustom, Document, ResponseFormatJsonObject, ResponseFormatJsonSchema, ResponseFormatText, SearchSettings } from '../message-types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Groq-specific provider options for text/chat models.
|
|
4
|
-
*
|
|
5
|
-
* These options extend the standard Chat Completions API parameters
|
|
6
|
-
* with Groq-specific features like compound models and search settings.
|
|
7
|
-
*
|
|
8
|
-
* @see https://console.groq.com/docs/api-reference#chat
|
|
9
|
-
*/
|
|
10
|
-
export interface GroqTextProviderOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Whether to enable citations in the response. When enabled, the model will
|
|
13
|
-
* include citations for information retrieved from provided documents or web
|
|
14
|
-
* searches.
|
|
15
|
-
*/
|
|
16
|
-
citation_options?: 'enabled' | 'disabled' | null;
|
|
17
|
-
/** Custom configuration of models and tools for Compound. */
|
|
18
|
-
compound_custom?: CompoundCustom | null;
|
|
19
|
-
/**
|
|
20
|
-
* If set to true, groq will return called tools without validating that the tool
|
|
21
|
-
* is present in request.tools. tool_choice=required/none will still be enforced,
|
|
22
|
-
* but the request cannot require a specific tool be used.
|
|
23
|
-
*/
|
|
24
|
-
disable_tool_validation?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* A list of documents to provide context for the conversation. Each document
|
|
27
|
-
* contains text that can be referenced by the model.
|
|
28
|
-
*/
|
|
29
|
-
documents?: Array<Document> | null;
|
|
30
|
-
/**
|
|
31
|
-
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
|
|
32
|
-
* existing frequency in the text so far, decreasing the model's likelihood to
|
|
33
|
-
* repeat the same line verbatim.
|
|
34
|
-
*/
|
|
35
|
-
frequency_penalty?: number | null;
|
|
36
|
-
/**
|
|
37
|
-
* Whether to include reasoning in the response. This field is mutually exclusive
|
|
38
|
-
* with `reasoning_format`.
|
|
39
|
-
*/
|
|
40
|
-
include_reasoning?: boolean | null;
|
|
41
|
-
/** Modify the likelihood of specified tokens appearing in the completion. */
|
|
42
|
-
logit_bias?: {
|
|
43
|
-
[key: string]: number;
|
|
44
|
-
} | null;
|
|
45
|
-
/**
|
|
46
|
-
* Whether to return log probabilities of the output tokens or not. If true,
|
|
47
|
-
* returns the log probabilities of each output token returned in the `content`
|
|
48
|
-
* of `message`.
|
|
49
|
-
*/
|
|
50
|
-
logprobs?: boolean | null;
|
|
51
|
-
/**
|
|
52
|
-
* The maximum number of tokens that can be generated in the chat completion. The
|
|
53
|
-
* total length of input tokens and generated tokens is limited by the model's
|
|
54
|
-
* context length.
|
|
55
|
-
*/
|
|
56
|
-
max_completion_tokens?: number | null;
|
|
57
|
-
/** Request metadata. */
|
|
58
|
-
metadata?: {
|
|
59
|
-
[key: string]: string;
|
|
60
|
-
} | null;
|
|
61
|
-
/**
|
|
62
|
-
* How many chat completion choices to generate for each input message.
|
|
63
|
-
* Currently only n=1 is supported.
|
|
64
|
-
*/
|
|
65
|
-
n?: number | null;
|
|
66
|
-
/** Whether to enable parallel function calling during tool use. */
|
|
67
|
-
parallel_tool_calls?: boolean | null;
|
|
68
|
-
/**
|
|
69
|
-
* Number between -2.0 and 2.0. Positive values penalize new tokens based on
|
|
70
|
-
* whether they appear in the text so far, increasing the model's likelihood to
|
|
71
|
-
* talk about new topics.
|
|
72
|
-
*/
|
|
73
|
-
presence_penalty?: number | null;
|
|
74
|
-
/**
|
|
75
|
-
* Controls reasoning effort for supported models.
|
|
76
|
-
*
|
|
77
|
-
* - qwen3 models: `'none'` to disable, `'default'` or null to enable
|
|
78
|
-
* - openai/gpt-oss models: `'low'`, `'medium'` (default), or `'high'`
|
|
79
|
-
*/
|
|
80
|
-
reasoning_effort?: 'none' | 'default' | 'low' | 'medium' | 'high' | null;
|
|
81
|
-
/**
|
|
82
|
-
* Specifies how to output reasoning tokens.
|
|
83
|
-
* This field is mutually exclusive with `include_reasoning`.
|
|
84
|
-
*/
|
|
85
|
-
reasoning_format?: 'hidden' | 'raw' | 'parsed' | null;
|
|
86
|
-
/**
|
|
87
|
-
* An object specifying the format that the model must output.
|
|
88
|
-
*
|
|
89
|
-
* - `json_schema` — enables Structured Outputs (preferred)
|
|
90
|
-
* - `json_object` — enables the older JSON mode
|
|
91
|
-
* - `text` — plain text output (default)
|
|
92
|
-
*
|
|
93
|
-
* @see https://console.groq.com/docs/structured-outputs
|
|
94
|
-
*/
|
|
95
|
-
response_format?: ResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObject | null;
|
|
96
|
-
/** Settings for web search functionality when the model uses a web search tool. */
|
|
97
|
-
search_settings?: SearchSettings | null;
|
|
98
|
-
/**
|
|
99
|
-
* If specified, our system will make a best effort to sample deterministically,
|
|
100
|
-
* such that repeated requests with the same `seed` and parameters should return
|
|
101
|
-
* the same result.
|
|
102
|
-
*/
|
|
103
|
-
seed?: number | null;
|
|
104
|
-
/**
|
|
105
|
-
* The service tier to use for the request.
|
|
106
|
-
*
|
|
107
|
-
* - `auto` — automatically select the highest tier available
|
|
108
|
-
* - `flex` — uses the flex tier, which will succeed or fail quickly
|
|
109
|
-
*/
|
|
110
|
-
service_tier?: 'auto' | 'on_demand' | 'flex' | 'performance' | null;
|
|
111
|
-
/**
|
|
112
|
-
* Up to 4 sequences where the API will stop generating further tokens.
|
|
113
|
-
* The returned text will not contain the stop sequence.
|
|
114
|
-
*/
|
|
115
|
-
stop?: string | null | Array<string>;
|
|
116
|
-
/** Whether to store the request for future use. */
|
|
117
|
-
store?: boolean | null;
|
|
118
|
-
/**
|
|
119
|
-
* Sampling temperature between 0 and 2. Higher values like 0.8 will make the
|
|
120
|
-
* output more random, while lower values like 0.2 will make it more focused
|
|
121
|
-
* and deterministic. We generally recommend altering this or top_p but not both.
|
|
122
|
-
*/
|
|
123
|
-
temperature?: number | null;
|
|
124
|
-
/**
|
|
125
|
-
* Controls which (if any) tool is called by the model.
|
|
126
|
-
*
|
|
127
|
-
* - `none` — never call tools
|
|
128
|
-
* - `auto` — model decides (default when tools are present)
|
|
129
|
-
* - `required` — model must call tools
|
|
130
|
-
* - Named choice — forces a specific tool
|
|
131
|
-
*/
|
|
132
|
-
tool_choice?: ChatCompletionToolChoiceOption | null;
|
|
133
|
-
/**
|
|
134
|
-
* An integer between 0 and 20 specifying the number of most likely tokens to
|
|
135
|
-
* return at each token position. `logprobs` must be set to `true` if this
|
|
136
|
-
* parameter is used.
|
|
137
|
-
*/
|
|
138
|
-
top_logprobs?: number | null;
|
|
139
|
-
/**
|
|
140
|
-
* An alternative to sampling with temperature, called nucleus sampling, where the
|
|
141
|
-
* model considers the results of the tokens with top_p probability mass. So 0.1
|
|
142
|
-
* means only the tokens comprising the top 10% probability mass are considered.
|
|
143
|
-
*/
|
|
144
|
-
top_p?: number | null;
|
|
145
|
-
/**
|
|
146
|
-
* A unique identifier representing your end-user, which can help monitor and
|
|
147
|
-
* detect abuse.
|
|
148
|
-
*/
|
|
149
|
-
user?: string | null;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* External provider options (what users pass in)
|
|
153
|
-
*/
|
|
154
|
-
export type ExternalTextProviderOptions = GroqTextProviderOptions;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@tanstack/ai';
|
|
2
|
-
import { ChatCompletionTool } from '../message-types.js';
|
|
3
|
-
export type FunctionTool = ChatCompletionTool;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a standard Tool to Groq ChatCompletionTool format.
|
|
6
|
-
*
|
|
7
|
-
* Tool schemas are already converted to JSON Schema in the ai layer.
|
|
8
|
-
* We apply Groq-specific transformations for strict mode:
|
|
9
|
-
* - All properties in required array
|
|
10
|
-
* - Optional fields made nullable
|
|
11
|
-
* - additionalProperties: false
|
|
12
|
-
*/
|
|
13
|
-
export declare function convertFunctionToolToAdapterFormat(tool: Tool): FunctionTool;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { makeGroqStructuredOutputCompatible } from "../utils/schema-converter.js";
|
|
2
|
-
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
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
convertFunctionToolToAdapterFormat
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=function-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
package/dist/esm/tools/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FunctionTool } from './function-tool.js';
|
|
2
|
-
import { Tool } from '@tanstack/ai';
|
|
3
|
-
/**
|
|
4
|
-
* Converts an array of standard Tools to Groq-specific format.
|
|
5
|
-
* Groq uses an OpenAI-compatible API, so we primarily support function tools.
|
|
6
|
-
*/
|
|
7
|
-
export declare function convertToolsToProviderFormat(tools: Array<Tool>): Array<FunctionTool>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { convertFunctionToolToAdapterFormat } from "./function-tool.js";
|
|
2
|
-
function convertToolsToProviderFormat(tools) {
|
|
3
|
-
return tools.map((tool) => {
|
|
4
|
-
return convertFunctionToolToAdapterFormat(tool);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
convertToolsToProviderFormat
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=tool-converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-converter.js","sources":["../../../src/tools/tool-converter.ts"],"sourcesContent":["import { convertFunctionToolToAdapterFormat } from './function-tool'\nimport type { FunctionTool } from './function-tool'\nimport type { Tool } from '@tanstack/ai'\n\n/**\n * Converts an array of standard Tools to Groq-specific format.\n * Groq uses an OpenAI-compatible API, so we primarily support function tools.\n */\nexport function convertToolsToProviderFormat(\n tools: Array<Tool>,\n): Array<FunctionTool> {\n return tools.map((tool) => {\n return convertFunctionToolToAdapterFormat(tool)\n })\n}\n"],"names":[],"mappings":";AAQO,SAAS,6BACd,OACqB;AACrB,SAAO,MAAM,IAAI,CAAC,SAAS;AACzB,WAAO,mCAAmC,IAAI;AAAA,EAChD,CAAC;AACH;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ClientOptions } from 'openai';
|
|
2
|
-
export interface GroqClientConfig extends Omit<ClientOptions, 'apiKey'> {
|
|
3
|
-
apiKey: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Gets Groq API key from environment variables
|
|
7
|
-
* @throws Error if GROQ_API_KEY is not found
|
|
8
|
-
*/
|
|
9
|
-
export declare function getGroqApiKeyFromEnv(): string;
|
|
10
|
-
/**
|
|
11
|
-
* Returns a Groq client config with Groq's OpenAI-compatible base URL
|
|
12
|
-
* applied when not already set. The Groq endpoint accepts the OpenAI SDK
|
|
13
|
-
* verbatim, so the adapter drives it via the OpenAI SDK with this baseURL.
|
|
14
|
-
*/
|
|
15
|
-
export declare function withGroqDefaults(config: GroqClientConfig): GroqClientConfig;
|
package/dist/esm/utils/client.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getApiKeyFromEnv } from "@tanstack/ai-utils";
|
|
2
|
-
function getGroqApiKeyFromEnv() {
|
|
3
|
-
try {
|
|
4
|
-
return getApiKeyFromEnv("GROQ_API_KEY");
|
|
5
|
-
} catch {
|
|
6
|
-
throw new Error(
|
|
7
|
-
"GROQ_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key."
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function withGroqDefaults(config) {
|
|
12
|
-
return {
|
|
13
|
-
...config,
|
|
14
|
-
baseURL: config.baseURL || "https://api.groq.com/openai/v1"
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
getGroqApiKeyFromEnv,
|
|
19
|
-
withGroqDefaults
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../src/utils/client.ts"],"sourcesContent":["import { getApiKeyFromEnv } from '@tanstack/ai-utils'\nimport type { ClientOptions } from 'openai'\n\nexport interface GroqClientConfig extends Omit<ClientOptions, 'apiKey'> {\n apiKey: string\n}\n\n/**\n * Gets Groq API key from environment variables\n * @throws Error if GROQ_API_KEY is not found\n */\nexport function getGroqApiKeyFromEnv(): string {\n try {\n return getApiKeyFromEnv('GROQ_API_KEY')\n } catch {\n throw new Error(\n 'GROQ_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key.',\n )\n }\n}\n\n/**\n * Returns a Groq client config with Groq's OpenAI-compatible base URL\n * applied when not already set. The Groq endpoint accepts the OpenAI SDK\n * verbatim, so the adapter drives it via the OpenAI SDK with this baseURL.\n */\nexport function withGroqDefaults(config: GroqClientConfig): GroqClientConfig {\n return {\n ...config,\n baseURL: config.baseURL || 'https://api.groq.com/openai/v1',\n }\n}\n"],"names":[],"mappings":";AAWO,SAAS,uBAA+B;AAC7C,MAAI;AACF,WAAO,iBAAiB,cAAc;AAAA,EACxC,QAAQ;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACF;AAOO,SAAS,iBAAiB,QAA4C;AAC3E,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,OAAO,WAAW;AAAA,EAAA;AAE/B;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { transformNullsToUndefined } from '@tanstack/ai-utils';
|
|
2
|
-
export { transformNullsToUndefined };
|
|
3
|
-
/**
|
|
4
|
-
* Transform a JSON schema to be compatible with Groq's structured output requirements.
|
|
5
|
-
*
|
|
6
|
-
* Groq requires:
|
|
7
|
-
* - All properties must be in the `required` array
|
|
8
|
-
* - Optional fields should have null added to their type union
|
|
9
|
-
* - additionalProperties must be false for objects
|
|
10
|
-
* - `required` must be omitted (not empty array) when there are no properties
|
|
11
|
-
*
|
|
12
|
-
* Delegates to the shared OpenAI-compatible transformer and applies the
|
|
13
|
-
* Groq-specific quirk of removing empty `required` arrays.
|
|
14
|
-
*
|
|
15
|
-
* @param schema - JSON schema to transform
|
|
16
|
-
* @param originalRequired - Original required array (to know which fields were optional)
|
|
17
|
-
* @returns Transformed schema compatible with Groq structured output
|
|
18
|
-
*/
|
|
19
|
-
export declare function makeGroqStructuredOutputCompatible(schema: Record<string, any>, originalRequired?: Array<string>): Record<string, any>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { makeStructuredOutputCompatible } from "@tanstack/openai-base";
|
|
2
|
-
import { transformNullsToUndefined } from "@tanstack/ai-utils";
|
|
3
|
-
function removeEmptyRequired(schema) {
|
|
4
|
-
const result = { ...schema };
|
|
5
|
-
if (Array.isArray(result.required) && result.required.length === 0) {
|
|
6
|
-
delete result.required;
|
|
7
|
-
}
|
|
8
|
-
if (result.properties && typeof result.properties === "object") {
|
|
9
|
-
const properties = {};
|
|
10
|
-
for (const [key, value] of Object.entries(
|
|
11
|
-
result.properties
|
|
12
|
-
)) {
|
|
13
|
-
properties[key] = typeof value === "object" && value !== null && !Array.isArray(value) ? removeEmptyRequired(value) : value;
|
|
14
|
-
}
|
|
15
|
-
result.properties = properties;
|
|
16
|
-
}
|
|
17
|
-
if (result.items && typeof result.items === "object" && !Array.isArray(result.items)) {
|
|
18
|
-
result.items = removeEmptyRequired(result.items);
|
|
19
|
-
}
|
|
20
|
-
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
21
|
-
if (Array.isArray(result[keyword])) {
|
|
22
|
-
result[keyword] = result[keyword].map(
|
|
23
|
-
(entry) => removeEmptyRequired(entry)
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (result.additionalProperties && typeof result.additionalProperties === "object" && !Array.isArray(result.additionalProperties)) {
|
|
28
|
-
result.additionalProperties = removeEmptyRequired(
|
|
29
|
-
result.additionalProperties
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
function normalizeObjectSchemas(schema) {
|
|
35
|
-
const result = schema.type === "object" && !schema.properties ? { ...schema, properties: {} } : { ...schema };
|
|
36
|
-
if (result.properties && typeof result.properties === "object") {
|
|
37
|
-
result.properties = Object.fromEntries(
|
|
38
|
-
Object.entries(result.properties).map(
|
|
39
|
-
([key, value]) => [
|
|
40
|
-
key,
|
|
41
|
-
typeof value === "object" && value !== null && !Array.isArray(value) ? normalizeObjectSchemas(value) : value
|
|
42
|
-
]
|
|
43
|
-
)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
if (result.items && typeof result.items === "object" && !Array.isArray(result.items)) {
|
|
47
|
-
result.items = normalizeObjectSchemas(result.items);
|
|
48
|
-
}
|
|
49
|
-
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
50
|
-
const branch = result[keyword];
|
|
51
|
-
if (Array.isArray(branch)) {
|
|
52
|
-
result[keyword] = branch.map(
|
|
53
|
-
(entry) => typeof entry === "object" && entry !== null ? normalizeObjectSchemas(entry) : entry
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (result.additionalProperties && typeof result.additionalProperties === "object" && !Array.isArray(result.additionalProperties)) {
|
|
58
|
-
result.additionalProperties = normalizeObjectSchemas(
|
|
59
|
-
result.additionalProperties
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
function makeGroqStructuredOutputCompatible(schema, originalRequired = []) {
|
|
65
|
-
const normalised = normalizeObjectSchemas(schema);
|
|
66
|
-
const result = makeStructuredOutputCompatible(normalised, originalRequired);
|
|
67
|
-
return removeEmptyRequired(result);
|
|
68
|
-
}
|
|
69
|
-
export {
|
|
70
|
-
makeGroqStructuredOutputCompatible,
|
|
71
|
-
transformNullsToUndefined
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=schema-converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-converter.js","sources":["../../../src/utils/schema-converter.ts"],"sourcesContent":["import { makeStructuredOutputCompatible } from '@tanstack/openai-base'\nimport { transformNullsToUndefined } from '@tanstack/ai-utils'\n\nexport { transformNullsToUndefined }\n\n/**\n * Recursively removes `required: []` from a schema object.\n * Groq rejects `required` when it is an empty array, even though\n * OpenAI-compatible schemas allow it.\n */\nfunction removeEmptyRequired(schema: Record<string, any>): Record<string, any> {\n const result = { ...schema }\n\n if (Array.isArray(result.required) && result.required.length === 0) {\n delete result.required\n }\n\n if (result.properties && typeof result.properties === 'object') {\n const properties: Record<string, any> = {}\n for (const [key, value] of Object.entries(\n result.properties as Record<string, any>,\n )) {\n properties[key] =\n typeof value === 'object' && value !== null && !Array.isArray(value)\n ? removeEmptyRequired(value)\n : value\n }\n result.properties = properties\n }\n\n if (\n result.items &&\n typeof result.items === 'object' &&\n !Array.isArray(result.items)\n ) {\n result.items = removeEmptyRequired(result.items)\n }\n\n // Recurse into combinator arrays (anyOf, oneOf, allOf)\n for (const keyword of ['anyOf', 'oneOf', 'allOf'] as const) {\n if (Array.isArray(result[keyword])) {\n result[keyword] = result[keyword].map((entry: Record<string, any>) =>\n removeEmptyRequired(entry),\n )\n }\n }\n\n // Recurse into additionalProperties if it's a schema object\n if (\n result.additionalProperties &&\n typeof result.additionalProperties === 'object' &&\n !Array.isArray(result.additionalProperties)\n ) {\n result.additionalProperties = removeEmptyRequired(\n result.additionalProperties,\n )\n }\n\n return result\n}\n\n/**\n * Recursively normalise object schemas so any `{ type: 'object' }` node\n * without `properties` gets an empty `properties: {}` object. The\n * ai-openai-base transformer only descends into objects that already have\n * `properties` set, so a Zod `z.object({})` nested inside `properties`,\n * `items`, `additionalProperties`, or a combinator branch would otherwise\n * skip the strict-mode rewrite and fail Groq validation.\n */\nfunction normalizeObjectSchemas(\n schema: Record<string, any>,\n): Record<string, any> {\n const result: Record<string, any> =\n schema.type === 'object' && !schema.properties\n ? { ...schema, properties: {} }\n : { ...schema }\n\n if (result.properties && typeof result.properties === 'object') {\n result.properties = Object.fromEntries(\n Object.entries(result.properties as Record<string, any>).map(\n ([key, value]) => [\n key,\n typeof value === 'object' && value !== null && !Array.isArray(value)\n ? normalizeObjectSchemas(value)\n : value,\n ],\n ),\n )\n }\n\n if (\n result.items &&\n typeof result.items === 'object' &&\n !Array.isArray(result.items)\n ) {\n result.items = normalizeObjectSchemas(result.items)\n }\n\n for (const keyword of ['anyOf', 'oneOf', 'allOf'] as const) {\n const branch = result[keyword]\n if (Array.isArray(branch)) {\n result[keyword] = branch.map((entry) =>\n typeof entry === 'object' && entry !== null\n ? normalizeObjectSchemas(entry as Record<string, any>)\n : entry,\n )\n }\n }\n\n if (\n result.additionalProperties &&\n typeof result.additionalProperties === 'object' &&\n !Array.isArray(result.additionalProperties)\n ) {\n result.additionalProperties = normalizeObjectSchemas(\n result.additionalProperties as Record<string, any>,\n )\n }\n\n return result\n}\n\n/**\n * Transform a JSON schema to be compatible with Groq's structured output requirements.\n *\n * Groq requires:\n * - All properties must be in the `required` array\n * - Optional fields should have null added to their type union\n * - additionalProperties must be false for objects\n * - `required` must be omitted (not empty array) when there are no properties\n *\n * Delegates to the shared OpenAI-compatible transformer and applies the\n * Groq-specific quirk of removing empty `required` arrays.\n *\n * @param schema - JSON schema to transform\n * @param originalRequired - Original required array (to know which fields were optional)\n * @returns Transformed schema compatible with Groq structured output\n */\nexport function makeGroqStructuredOutputCompatible(\n schema: Record<string, any>,\n originalRequired: Array<string> = [],\n): Record<string, any> {\n // Recursively patch every `{ type: 'object' }` node so the ai-openai-base\n // transformer descends into nested empty objects too.\n const normalised = normalizeObjectSchemas(schema)\n\n const result = makeStructuredOutputCompatible(normalised, originalRequired)\n\n // Groq rejects `required` when it is an empty array\n return removeEmptyRequired(result)\n}\n"],"names":[],"mappings":";;AAUA,SAAS,oBAAoB,QAAkD;AAC7E,QAAM,SAAS,EAAE,GAAG,OAAA;AAEpB,MAAI,MAAM,QAAQ,OAAO,QAAQ,KAAK,OAAO,SAAS,WAAW,GAAG;AAClE,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,OAAO,cAAc,OAAO,OAAO,eAAe,UAAU;AAC9D,UAAM,aAAkC,CAAA;AACxC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO;AAAA,MAChC,OAAO;AAAA,IAAA,GACN;AACD,iBAAW,GAAG,IACZ,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IAC/D,oBAAoB,KAAK,IACzB;AAAA,IACR;AACA,WAAO,aAAa;AAAA,EACtB;AAEA,MACE,OAAO,SACP,OAAO,OAAO,UAAU,YACxB,CAAC,MAAM,QAAQ,OAAO,KAAK,GAC3B;AACA,WAAO,QAAQ,oBAAoB,OAAO,KAAK;AAAA,EACjD;AAGA,aAAW,WAAW,CAAC,SAAS,SAAS,OAAO,GAAY;AAC1D,QAAI,MAAM,QAAQ,OAAO,OAAO,CAAC,GAAG;AAClC,aAAO,OAAO,IAAI,OAAO,OAAO,EAAE;AAAA,QAAI,CAAC,UACrC,oBAAoB,KAAK;AAAA,MAAA;AAAA,IAE7B;AAAA,EACF;AAGA,MACE,OAAO,wBACP,OAAO,OAAO,yBAAyB,YACvC,CAAC,MAAM,QAAQ,OAAO,oBAAoB,GAC1C;AACA,WAAO,uBAAuB;AAAA,MAC5B,OAAO;AAAA,IAAA;AAAA,EAEX;AAEA,SAAO;AACT;AAUA,SAAS,uBACP,QACqB;AACrB,QAAM,SACJ,OAAO,SAAS,YAAY,CAAC,OAAO,aAChC,EAAE,GAAG,QAAQ,YAAY,CAAA,EAAC,IAC1B,EAAE,GAAG,OAAA;AAEX,MAAI,OAAO,cAAc,OAAO,OAAO,eAAe,UAAU;AAC9D,WAAO,aAAa,OAAO;AAAA,MACzB,OAAO,QAAQ,OAAO,UAAiC,EAAE;AAAA,QACvD,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,UAChB;AAAA,UACA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IAC/D,uBAAuB,KAAK,IAC5B;AAAA,QAAA;AAAA,MACN;AAAA,IACF;AAAA,EAEJ;AAEA,MACE,OAAO,SACP,OAAO,OAAO,UAAU,YACxB,CAAC,MAAM,QAAQ,OAAO,KAAK,GAC3B;AACA,WAAO,QAAQ,uBAAuB,OAAO,KAAK;AAAA,EACpD;AAEA,aAAW,WAAW,CAAC,SAAS,SAAS,OAAO,GAAY;AAC1D,UAAM,SAAS,OAAO,OAAO;AAC7B,QAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,aAAO,OAAO,IAAI,OAAO;AAAA,QAAI,CAAC,UAC5B,OAAO,UAAU,YAAY,UAAU,OACnC,uBAAuB,KAA4B,IACnD;AAAA,MAAA;AAAA,IAER;AAAA,EACF;AAEA,MACE,OAAO,wBACP,OAAO,OAAO,yBAAyB,YACvC,CAAC,MAAM,QAAQ,OAAO,oBAAoB,GAC1C;AACA,WAAO,uBAAuB;AAAA,MAC5B,OAAO;AAAA,IAAA;AAAA,EAEX;AAEA,SAAO;AACT;AAkBO,SAAS,mCACd,QACA,mBAAkC,IACb;AAGrB,QAAM,aAAa,uBAAuB,MAAM;AAEhD,QAAM,SAAS,+BAA+B,YAAY,gBAAgB;AAG1E,SAAO,oBAAoB,MAAM;AACnC;"}
|