@ai-sdk/groq 0.0.1
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/CHANGELOG.md +7 -0
- package/LICENSE +13 -0
- package/README.md +36 -0
- package/dist/index.d.mts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +647 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +635 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +70 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# AI SDK - Groq Provider
|
|
2
|
+
|
|
3
|
+
The **[Groq provider](https://sdk.vercel.ai/providers/ai-sdk-providers/groq)** for the [AI SDK](https://sdk.vercel.ai/docs)
|
|
4
|
+
contains language model support for the Groq chat and completion APIs and embedding model support for the Groq embeddings API.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
The Groq provider is available in the `@ai-sdk/groq` module. You can install it with
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i @ai-sdk/groq
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Provider Instance
|
|
15
|
+
|
|
16
|
+
You can import the default provider instance `groq` from `@ai-sdk/groq`:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { groq } from '@ai-sdk/groq';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { groq } from '@ai-sdk/groq';
|
|
26
|
+
import { generateText } from 'ai';
|
|
27
|
+
|
|
28
|
+
const { text } = await generateText({
|
|
29
|
+
model: groq('gemma2-9b-it'),
|
|
30
|
+
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
Please check out the **[Groq provider documentation](https://sdk.vercel.ai/providers/ai-sdk-providers/groq)** for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type GroqChatModelId = 'gemma2-9b-it' | 'gemma-7b-it' | 'llama3-groq-70b-8192-tool-use-preview' | 'llama3-groq-8b-8192-tool-use-preview' | 'llama-3.1-70b-versatile' | 'llama-3.1-8b-instant' | 'llama-3.2-1b-preview' | 'llama-3.2-3b-preview' | 'llama-3.2-11b-vision-preview' | 'llama-guard-3-8b' | 'llava-v1.5-7b-4096-preview' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | (string & {});
|
|
5
|
+
interface GroqChatSettings {
|
|
6
|
+
/**
|
|
7
|
+
Whether to enable parallel function calling during tool use. Default to true.
|
|
8
|
+
*/
|
|
9
|
+
parallelToolCalls?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
12
|
+
monitor and detect abuse. Learn more.
|
|
13
|
+
*/
|
|
14
|
+
user?: string;
|
|
15
|
+
/**
|
|
16
|
+
Automatically download images and pass the image as data to the model.
|
|
17
|
+
Groq supports image URLs for public models, so this is only needed for
|
|
18
|
+
private models or when the images are not publicly accessible.
|
|
19
|
+
|
|
20
|
+
Defaults to `false`.
|
|
21
|
+
*/
|
|
22
|
+
downloadImages?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface GroqProvider extends ProviderV1 {
|
|
26
|
+
/**
|
|
27
|
+
Creates a model for text generation.
|
|
28
|
+
*/
|
|
29
|
+
(modelId: GroqChatModelId, settings?: GroqChatSettings): LanguageModelV1;
|
|
30
|
+
/**
|
|
31
|
+
Creates an Groq chat model for text generation.
|
|
32
|
+
*/
|
|
33
|
+
languageModel(modelId: GroqChatModelId, settings?: GroqChatSettings): LanguageModelV1;
|
|
34
|
+
}
|
|
35
|
+
interface GroqProviderSettings {
|
|
36
|
+
/**
|
|
37
|
+
Base URL for the Groq API calls.
|
|
38
|
+
*/
|
|
39
|
+
baseURL?: string;
|
|
40
|
+
/**
|
|
41
|
+
API key for authenticating requests.
|
|
42
|
+
*/
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
/**
|
|
45
|
+
Custom headers to include in the requests.
|
|
46
|
+
*/
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
50
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
51
|
+
*/
|
|
52
|
+
fetch?: FetchFunction;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
Create an Groq provider instance.
|
|
56
|
+
*/
|
|
57
|
+
declare function createGroq(options?: GroqProviderSettings): GroqProvider;
|
|
58
|
+
/**
|
|
59
|
+
Default Groq provider instance.
|
|
60
|
+
*/
|
|
61
|
+
declare const groq: GroqProvider;
|
|
62
|
+
|
|
63
|
+
export { type GroqProvider, type GroqProviderSettings, createGroq, groq };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
type GroqChatModelId = 'gemma2-9b-it' | 'gemma-7b-it' | 'llama3-groq-70b-8192-tool-use-preview' | 'llama3-groq-8b-8192-tool-use-preview' | 'llama-3.1-70b-versatile' | 'llama-3.1-8b-instant' | 'llama-3.2-1b-preview' | 'llama-3.2-3b-preview' | 'llama-3.2-11b-vision-preview' | 'llama-guard-3-8b' | 'llava-v1.5-7b-4096-preview' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | (string & {});
|
|
5
|
+
interface GroqChatSettings {
|
|
6
|
+
/**
|
|
7
|
+
Whether to enable parallel function calling during tool use. Default to true.
|
|
8
|
+
*/
|
|
9
|
+
parallelToolCalls?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
12
|
+
monitor and detect abuse. Learn more.
|
|
13
|
+
*/
|
|
14
|
+
user?: string;
|
|
15
|
+
/**
|
|
16
|
+
Automatically download images and pass the image as data to the model.
|
|
17
|
+
Groq supports image URLs for public models, so this is only needed for
|
|
18
|
+
private models or when the images are not publicly accessible.
|
|
19
|
+
|
|
20
|
+
Defaults to `false`.
|
|
21
|
+
*/
|
|
22
|
+
downloadImages?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface GroqProvider extends ProviderV1 {
|
|
26
|
+
/**
|
|
27
|
+
Creates a model for text generation.
|
|
28
|
+
*/
|
|
29
|
+
(modelId: GroqChatModelId, settings?: GroqChatSettings): LanguageModelV1;
|
|
30
|
+
/**
|
|
31
|
+
Creates an Groq chat model for text generation.
|
|
32
|
+
*/
|
|
33
|
+
languageModel(modelId: GroqChatModelId, settings?: GroqChatSettings): LanguageModelV1;
|
|
34
|
+
}
|
|
35
|
+
interface GroqProviderSettings {
|
|
36
|
+
/**
|
|
37
|
+
Base URL for the Groq API calls.
|
|
38
|
+
*/
|
|
39
|
+
baseURL?: string;
|
|
40
|
+
/**
|
|
41
|
+
API key for authenticating requests.
|
|
42
|
+
*/
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
/**
|
|
45
|
+
Custom headers to include in the requests.
|
|
46
|
+
*/
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
50
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
51
|
+
*/
|
|
52
|
+
fetch?: FetchFunction;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
Create an Groq provider instance.
|
|
56
|
+
*/
|
|
57
|
+
declare function createGroq(options?: GroqProviderSettings): GroqProvider;
|
|
58
|
+
/**
|
|
59
|
+
Default Groq provider instance.
|
|
60
|
+
*/
|
|
61
|
+
declare const groq: GroqProvider;
|
|
62
|
+
|
|
63
|
+
export { type GroqProvider, type GroqProviderSettings, createGroq, groq };
|