@tanstack/ai-groq 0.5.4 → 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.
- package/README.md +1 -0
- package/dist/esm/adapters/summarize.d.ts +51 -0
- package/dist/esm/adapters/summarize.js +55 -0
- package/dist/esm/adapters/summarize.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -1
- package/package.json +4 -4
- package/src/adapters/summarize.ts +77 -0
- package/src/index.ts +8 -0
package/README.md
CHANGED
|
@@ -72,6 +72,7 @@ const adapter = createGroqText('llama-3.3-70b-versatile', 'gsk_api_key')
|
|
|
72
72
|
- ✅ Structured output (JSON Schema)
|
|
73
73
|
- ✅ Function/tool calling
|
|
74
74
|
- ✅ Multimodal input (text + images for vision models)
|
|
75
|
+
- ✅ Summarization (`groqSummarize`)
|
|
75
76
|
- ❌ Embeddings (not supported by Groq)
|
|
76
77
|
- ❌ Image generation (not supported by Groq)
|
|
77
78
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChatStreamSummarizeAdapter, InferTextProviderOptions } from '@tanstack/ai/adapters';
|
|
2
|
+
import { GroqTextAdapter } from './text.js';
|
|
3
|
+
import { GROQ_CHAT_MODELS } from '../model-meta.js';
|
|
4
|
+
import { GroqClientConfig } from '../utils/client.js';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for Groq summarize adapter
|
|
7
|
+
*/
|
|
8
|
+
export interface GroqSummarizeConfig extends GroqClientConfig {
|
|
9
|
+
}
|
|
10
|
+
/** Model type for Groq summarization */
|
|
11
|
+
export type GroqSummarizeModel = (typeof GROQ_CHAT_MODELS)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Groq summarize adapter with explicit API key.
|
|
14
|
+
* Type resolution happens here at the call site.
|
|
15
|
+
*
|
|
16
|
+
* @param model - The model name (e.g., 'llama-3.3-70b-versatile')
|
|
17
|
+
* @param apiKey - Your Groq API key
|
|
18
|
+
* @param config - Optional additional configuration
|
|
19
|
+
* @returns Configured Groq summarize adapter instance with resolved types
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const adapter = createGroqSummarize('llama-3.3-70b-versatile', "gsk_...");
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function createGroqSummarize<TModel extends GroqSummarizeModel>(model: TModel, apiKey: string, config?: Omit<GroqSummarizeConfig, 'apiKey'>): ChatStreamSummarizeAdapter<TModel, InferTextProviderOptions<GroqTextAdapter<TModel>>>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a Groq summarize adapter with automatic API key detection from environment variables.
|
|
29
|
+
* Type resolution happens here at the call site.
|
|
30
|
+
*
|
|
31
|
+
* Looks for `GROQ_API_KEY` in:
|
|
32
|
+
* - `process.env` (Node.js)
|
|
33
|
+
* - `window.env` (Browser with injected env)
|
|
34
|
+
*
|
|
35
|
+
* @param model - The model name (e.g., 'llama-3.3-70b-versatile')
|
|
36
|
+
* @param config - Optional configuration (excluding apiKey which is auto-detected)
|
|
37
|
+
* @returns Configured Groq summarize adapter instance with resolved types
|
|
38
|
+
* @throws Error if GROQ_API_KEY is not found in environment
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Automatically uses GROQ_API_KEY from environment
|
|
43
|
+
* const adapter = groqSummarize('llama-3.3-70b-versatile');
|
|
44
|
+
*
|
|
45
|
+
* await summarize({
|
|
46
|
+
* adapter,
|
|
47
|
+
* text: "Long article text..."
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function groqSummarize<TModel extends GroqSummarizeModel>(model: TModel, config?: Omit<GroqSummarizeConfig, 'apiKey'>): ChatStreamSummarizeAdapter<TModel, InferTextProviderOptions<GroqTextAdapter<TModel>>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getGroqApiKeyFromEnv } from "../utils/client.js";
|
|
2
|
+
import { GroqTextAdapter } from "./text.js";
|
|
3
|
+
import { ChatStreamSummarizeAdapter } from "@tanstack/ai/adapters";
|
|
4
|
+
//#region src/adapters/summarize.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Groq summarize adapter with explicit API key.
|
|
7
|
+
* Type resolution happens here at the call site.
|
|
8
|
+
*
|
|
9
|
+
* @param model - The model name (e.g., 'llama-3.3-70b-versatile')
|
|
10
|
+
* @param apiKey - Your Groq API key
|
|
11
|
+
* @param config - Optional additional configuration
|
|
12
|
+
* @returns Configured Groq summarize adapter instance with resolved types
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const adapter = createGroqSummarize('llama-3.3-70b-versatile', "gsk_...");
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function createGroqSummarize(model, apiKey, config) {
|
|
20
|
+
return new ChatStreamSummarizeAdapter(new GroqTextAdapter({
|
|
21
|
+
apiKey,
|
|
22
|
+
...config
|
|
23
|
+
}, model), model, "groq");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a Groq summarize adapter with automatic API key detection from environment variables.
|
|
27
|
+
* Type resolution happens here at the call site.
|
|
28
|
+
*
|
|
29
|
+
* Looks for `GROQ_API_KEY` in:
|
|
30
|
+
* - `process.env` (Node.js)
|
|
31
|
+
* - `window.env` (Browser with injected env)
|
|
32
|
+
*
|
|
33
|
+
* @param model - The model name (e.g., 'llama-3.3-70b-versatile')
|
|
34
|
+
* @param config - Optional configuration (excluding apiKey which is auto-detected)
|
|
35
|
+
* @returns Configured Groq summarize adapter instance with resolved types
|
|
36
|
+
* @throws Error if GROQ_API_KEY is not found in environment
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Automatically uses GROQ_API_KEY from environment
|
|
41
|
+
* const adapter = groqSummarize('llama-3.3-70b-versatile');
|
|
42
|
+
*
|
|
43
|
+
* await summarize({
|
|
44
|
+
* adapter,
|
|
45
|
+
* text: "Long article text..."
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function groqSummarize(model, config) {
|
|
50
|
+
return createGroqSummarize(model, getGroqApiKeyFromEnv(), config);
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { createGroqSummarize, groqSummarize };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=summarize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarize.js","names":[],"sources":["../../../src/adapters/summarize.ts"],"sourcesContent":["import { ChatStreamSummarizeAdapter } from '@tanstack/ai/adapters'\nimport { getGroqApiKeyFromEnv } from '../utils/client'\nimport { GroqTextAdapter } from './text'\nimport type { InferTextProviderOptions } from '@tanstack/ai/adapters'\nimport type { GROQ_CHAT_MODELS } from '../model-meta'\nimport type { GroqClientConfig } from '../utils/client'\n\n/**\n * Configuration for Groq summarize adapter\n */\nexport interface GroqSummarizeConfig extends GroqClientConfig {}\n\n/** Model type for Groq summarization */\nexport type GroqSummarizeModel = (typeof GROQ_CHAT_MODELS)[number]\n\n/**\n * Creates a Groq summarize adapter with explicit API key.\n * Type resolution happens here at the call site.\n *\n * @param model - The model name (e.g., 'llama-3.3-70b-versatile')\n * @param apiKey - Your Groq API key\n * @param config - Optional additional configuration\n * @returns Configured Groq summarize adapter instance with resolved types\n *\n * @example\n * ```typescript\n * const adapter = createGroqSummarize('llama-3.3-70b-versatile', \"gsk_...\");\n * ```\n */\nexport function createGroqSummarize<TModel extends GroqSummarizeModel>(\n model: TModel,\n apiKey: string,\n config?: Omit<GroqSummarizeConfig, 'apiKey'>,\n): ChatStreamSummarizeAdapter<\n TModel,\n InferTextProviderOptions<GroqTextAdapter<TModel>>\n> {\n return new ChatStreamSummarizeAdapter(\n new GroqTextAdapter({ apiKey, ...config }, model),\n model,\n 'groq',\n )\n}\n\n/**\n * Creates a Groq summarize adapter with automatic API key detection from environment variables.\n * Type resolution happens here at the call site.\n *\n * Looks for `GROQ_API_KEY` in:\n * - `process.env` (Node.js)\n * - `window.env` (Browser with injected env)\n *\n * @param model - The model name (e.g., 'llama-3.3-70b-versatile')\n * @param config - Optional configuration (excluding apiKey which is auto-detected)\n * @returns Configured Groq summarize adapter instance with resolved types\n * @throws Error if GROQ_API_KEY is not found in environment\n *\n * @example\n * ```typescript\n * // Automatically uses GROQ_API_KEY from environment\n * const adapter = groqSummarize('llama-3.3-70b-versatile');\n *\n * await summarize({\n * adapter,\n * text: \"Long article text...\"\n * });\n * ```\n */\nexport function groqSummarize<TModel extends GroqSummarizeModel>(\n model: TModel,\n config?: Omit<GroqSummarizeConfig, 'apiKey'>,\n): ChatStreamSummarizeAdapter<\n TModel,\n InferTextProviderOptions<GroqTextAdapter<TModel>>\n> {\n return createGroqSummarize(model, getGroqApiKeyFromEnv(), config)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,oBACd,OACA,QACA,QAIA;CACA,OAAO,IAAI,2BACT,IAAI,gBAAgB;EAAE;EAAQ,GAAG;CAAO,GAAG,KAAK,GAChD,OACA,MACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,cACd,OACA,QAIA;CACA,OAAO,oBAAoB,OAAO,qBAAqB,GAAG,MAAM;AAClE"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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,5 +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 { GROQ_CHAT_MODELS, GROQ_TRANSCRIPTION_MODELS, GROQ_TTS_MODELS, GroqTTSAdapter, GroqTextAdapter, GroqTranscriptionAdapter, createGroqSpeech, createGroqText, createGroqTranscription, groqSpeech, groqText, groqTranscription };
|
|
6
|
+
export { GROQ_CHAT_MODELS, GROQ_TRANSCRIPTION_MODELS, GROQ_TTS_MODELS, GroqTTSAdapter, GroqTextAdapter, GroqTranscriptionAdapter, createGroqSpeech, createGroqSummarize, createGroqText, createGroqTranscription, groqSpeech, groqSummarize, groqText, groqTranscription };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-groq",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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.44.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"openai": "^6.41.0",
|
|
60
|
-
"@tanstack/
|
|
61
|
-
"@tanstack/
|
|
60
|
+
"@tanstack/openai-base": "^0.9.11",
|
|
61
|
+
"@tanstack/ai-utils": "^0.4.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "vite build",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ChatStreamSummarizeAdapter } from '@tanstack/ai/adapters'
|
|
2
|
+
import { getGroqApiKeyFromEnv } from '../utils/client'
|
|
3
|
+
import { GroqTextAdapter } from './text'
|
|
4
|
+
import type { InferTextProviderOptions } from '@tanstack/ai/adapters'
|
|
5
|
+
import type { GROQ_CHAT_MODELS } from '../model-meta'
|
|
6
|
+
import type { GroqClientConfig } from '../utils/client'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for Groq summarize adapter
|
|
10
|
+
*/
|
|
11
|
+
export interface GroqSummarizeConfig extends GroqClientConfig {}
|
|
12
|
+
|
|
13
|
+
/** Model type for Groq summarization */
|
|
14
|
+
export type GroqSummarizeModel = (typeof GROQ_CHAT_MODELS)[number]
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Groq summarize adapter with explicit API key.
|
|
18
|
+
* Type resolution happens here at the call site.
|
|
19
|
+
*
|
|
20
|
+
* @param model - The model name (e.g., 'llama-3.3-70b-versatile')
|
|
21
|
+
* @param apiKey - Your Groq API key
|
|
22
|
+
* @param config - Optional additional configuration
|
|
23
|
+
* @returns Configured Groq summarize adapter instance with resolved types
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const adapter = createGroqSummarize('llama-3.3-70b-versatile', "gsk_...");
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function createGroqSummarize<TModel extends GroqSummarizeModel>(
|
|
31
|
+
model: TModel,
|
|
32
|
+
apiKey: string,
|
|
33
|
+
config?: Omit<GroqSummarizeConfig, 'apiKey'>,
|
|
34
|
+
): ChatStreamSummarizeAdapter<
|
|
35
|
+
TModel,
|
|
36
|
+
InferTextProviderOptions<GroqTextAdapter<TModel>>
|
|
37
|
+
> {
|
|
38
|
+
return new ChatStreamSummarizeAdapter(
|
|
39
|
+
new GroqTextAdapter({ apiKey, ...config }, model),
|
|
40
|
+
model,
|
|
41
|
+
'groq',
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a Groq summarize adapter with automatic API key detection from environment variables.
|
|
47
|
+
* Type resolution happens here at the call site.
|
|
48
|
+
*
|
|
49
|
+
* Looks for `GROQ_API_KEY` in:
|
|
50
|
+
* - `process.env` (Node.js)
|
|
51
|
+
* - `window.env` (Browser with injected env)
|
|
52
|
+
*
|
|
53
|
+
* @param model - The model name (e.g., 'llama-3.3-70b-versatile')
|
|
54
|
+
* @param config - Optional configuration (excluding apiKey which is auto-detected)
|
|
55
|
+
* @returns Configured Groq summarize adapter instance with resolved types
|
|
56
|
+
* @throws Error if GROQ_API_KEY is not found in environment
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Automatically uses GROQ_API_KEY from environment
|
|
61
|
+
* const adapter = groqSummarize('llama-3.3-70b-versatile');
|
|
62
|
+
*
|
|
63
|
+
* await summarize({
|
|
64
|
+
* adapter,
|
|
65
|
+
* text: "Long article text..."
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export function groqSummarize<TModel extends GroqSummarizeModel>(
|
|
70
|
+
model: TModel,
|
|
71
|
+
config?: Omit<GroqSummarizeConfig, 'apiKey'>,
|
|
72
|
+
): ChatStreamSummarizeAdapter<
|
|
73
|
+
TModel,
|
|
74
|
+
InferTextProviderOptions<GroqTextAdapter<TModel>>
|
|
75
|
+
> {
|
|
76
|
+
return createGroqSummarize(model, getGroqApiKeyFromEnv(), config)
|
|
77
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,14 @@ export {
|
|
|
14
14
|
type GroqTextProviderOptions,
|
|
15
15
|
} from './adapters/text'
|
|
16
16
|
|
|
17
|
+
// Summarize - thin factory functions over @tanstack/ai's ChatStreamSummarizeAdapter
|
|
18
|
+
export {
|
|
19
|
+
createGroqSummarize,
|
|
20
|
+
groqSummarize,
|
|
21
|
+
type GroqSummarizeConfig,
|
|
22
|
+
type GroqSummarizeModel,
|
|
23
|
+
} from './adapters/summarize'
|
|
24
|
+
|
|
17
25
|
// Transcription adapter
|
|
18
26
|
export {
|
|
19
27
|
GroqTranscriptionAdapter,
|