File tree Expand file tree Collapse file tree 5 files changed +71
-0
lines changed Expand file tree Collapse file tree 5 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ export const KLUSTER_AI: string = 'kluster-ai';
96
96
export const NSCALE : string = 'nscale' ;
97
97
export const HYPERBOLIC : string = 'hyperbolic' ;
98
98
export const FEATHERLESS_AI : string = 'featherless-ai' ;
99
+ export const KRUTRIM : string = 'krutrim' ;
99
100
100
101
export const VALID_PROVIDERS = [
101
102
ANTHROPIC ,
@@ -157,6 +158,7 @@ export const VALID_PROVIDERS = [
157
158
NSCALE ,
158
159
HYPERBOLIC ,
159
160
FEATHERLESS_AI ,
161
+ KRUTRIM ,
160
162
] ;
161
163
162
164
export const CONTENT_TYPES = {
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ import KlusterAIConfig from './kluster-ai';
60
60
import NscaleConfig from './nscale' ;
61
61
import HyperbolicConfig from './hyperbolic' ;
62
62
import { FeatherlessAIConfig } from './featherless-ai' ;
63
+ import KrutrimConfig from './krutrim' ;
63
64
64
65
const Providers : { [ key : string ] : ProviderConfigs } = {
65
66
openai : OpenAIConfig ,
@@ -120,6 +121,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
120
121
nscale : NscaleConfig ,
121
122
hyperbolic : HyperbolicConfig ,
122
123
'featherless-ai' : FeatherlessAIConfig ,
124
+ krutrim : KrutrimConfig ,
123
125
} ;
124
126
125
127
export default Providers ;
Original file line number Diff line number Diff line change
1
+ import { ProviderAPIConfig } from '../types' ;
2
+
3
+ const KrutrimAPIConfig : ProviderAPIConfig = {
4
+ getBaseURL : ( ) => 'https://cloud.olakrutrim.com/v1' ,
5
+ headers : ( { providerOptions, fn } ) => {
6
+ const headersObj : Record < string , string > = {
7
+ Authorization : `Bearer ${ providerOptions . apiKey } ` ,
8
+ } ;
9
+ return headersObj ;
10
+ } ,
11
+ getEndpoint : ( { fn } ) => {
12
+ switch ( fn ) {
13
+ case 'chatComplete' :
14
+ return '/chat/completions' ;
15
+ default :
16
+ return '' ;
17
+ }
18
+ } ,
19
+ } ;
20
+
21
+ export default KrutrimAPIConfig ;
Original file line number Diff line number Diff line change
1
+ import { ChatCompletionResponse , ErrorResponse } from '../types' ;
2
+ import { generateErrorResponse } from '../utils' ;
3
+ import { KRUTRIM } from '../../globals' ;
4
+
5
+ interface KrutrimChatCompleteResponse extends ChatCompletionResponse { }
6
+ interface KrutrimChatCompleteErrorResponse extends ErrorResponse {
7
+ 'html-message' ?: string ;
8
+ }
9
+ export const KrutrimChatCompleteResponseTransform : (
10
+ response : KrutrimChatCompleteResponse | KrutrimChatCompleteErrorResponse ,
11
+ responseStatus : number
12
+ ) => ChatCompletionResponse | ErrorResponse = ( response , responseStatus ) => {
13
+ if ( responseStatus !== 200 && 'html-message' in response ) {
14
+ // Handle Krutrim's error format
15
+ return generateErrorResponse (
16
+ {
17
+ message : response [ 'html-message' ] ?? '' ,
18
+ type : 'error' ,
19
+ param : null ,
20
+ code : String ( responseStatus ) ,
21
+ } ,
22
+ KRUTRIM
23
+ ) ;
24
+ }
25
+
26
+ // Success case - add provider info
27
+ Object . defineProperty ( response , 'provider' , {
28
+ value : KRUTRIM ,
29
+ enumerable : true ,
30
+ } ) ;
31
+
32
+ return response as ChatCompletionResponse ;
33
+ } ;
Original file line number Diff line number Diff line change
1
+ import { ProviderConfigs } from '../types' ;
2
+ import KrutrimAPIConfig from './api' ;
3
+ import { chatCompleteParams } from '../open-ai-base' ;
4
+ import { KrutrimChatCompleteResponseTransform } from './chatComplete' ;
5
+ const KrutrimConfig : ProviderConfigs = {
6
+ api : KrutrimAPIConfig ,
7
+ chatComplete : chatCompleteParams ( [ ] , { model : 'Llama-3.3-70B-Instruct' } ) ,
8
+ responseTransforms : {
9
+ chatComplete : KrutrimChatCompleteResponseTransform ,
10
+ } ,
11
+ } ;
12
+
13
+ export default KrutrimConfig ;
You can’t perform that action at this time.
0 commit comments