1
1
import { GROQ } from '../../globals' ;
2
- import {
3
- ChatCompletionResponse ,
4
- ErrorResponse ,
5
- ProviderConfig ,
6
- } from '../types' ;
2
+ import { ChatCompletionResponse , ErrorResponse } from '../types' ;
7
3
import {
8
4
generateErrorResponse ,
9
5
generateInvalidProviderResponseError ,
10
6
} from '../utils' ;
11
7
12
- export const GroqChatCompleteConfig : ProviderConfig = {
13
- model : {
14
- param : 'model' ,
15
- required : true ,
16
- default : 'mixtral-8x7b-32768' ,
17
- } ,
18
- messages : {
19
- param : 'messages' ,
20
- default : '' ,
21
- } ,
22
- max_tokens : {
23
- param : 'max_tokens' ,
24
- default : 100 ,
25
- min : 0 ,
26
- } ,
27
- max_completion_tokens : {
28
- param : 'max_tokens' ,
29
- default : 100 ,
30
- min : 0 ,
31
- } ,
32
- temperature : {
33
- param : 'temperature' ,
34
- default : 1 ,
35
- min : 0 ,
36
- max : 2 ,
37
- } ,
38
- top_p : {
39
- param : 'top_p' ,
40
- default : 1 ,
41
- min : 0 ,
42
- max : 1 ,
43
- } ,
44
- stream : {
45
- param : 'stream' ,
46
- default : false ,
47
- } ,
48
- stop : {
49
- param : 'stop' ,
50
- } ,
51
- n : {
52
- param : 'n' ,
53
- default : 1 ,
54
- max : 1 ,
55
- min : 1 ,
56
- } ,
57
- tools : {
58
- param : 'tools' ,
59
- required : false ,
60
- } ,
61
- } ;
62
-
63
8
export interface GroqChatCompleteResponse extends ChatCompletionResponse { }
64
9
65
10
export interface GroqErrorResponse extends ErrorResponse { }
@@ -72,6 +17,7 @@ export interface GroqStreamChunk {
72
17
choices : {
73
18
delta : {
74
19
content ?: string ;
20
+ tool_calls ?: object [ ] ;
75
21
} ;
76
22
index : number ;
77
23
finish_reason : string | null ;
@@ -153,7 +99,7 @@ export const GroqChatCompleteStreamChunkTransform: (
153
99
index : parsedChunk . choices [ 0 ] . index || 0 ,
154
100
delta : { } ,
155
101
logprobs : null ,
156
- finish_reason : parsedChunk . choices [ 0 ] . index ,
102
+ finish_reason : parsedChunk . choices [ 0 ] . finish_reason ,
157
103
} ,
158
104
] ,
159
105
usage : {
@@ -175,6 +121,7 @@ export const GroqChatCompleteStreamChunkTransform: (
175
121
delta : {
176
122
role : 'assistant' ,
177
123
content : parsedChunk . choices [ 0 ] . delta . content ,
124
+ tool_calls : parsedChunk . choices [ 0 ] . delta ?. tool_calls ,
178
125
} ,
179
126
logprobs : null ,
180
127
finish_reason : parsedChunk . choices [ 0 ] . finish_reason || null ,
0 commit comments