File tree Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ export const RECRAFTAI: string = 'recraft-ai';
92
92
export const MILVUS : string = 'milvus' ;
93
93
export const REPLICATE : string = 'replicate' ;
94
94
export const LEPTON : string = 'lepton' ;
95
+ export const NSCALE : string = 'nscale' ;
95
96
96
97
export const VALID_PROVIDERS = [
97
98
ANTHROPIC ,
@@ -149,6 +150,7 @@ export const VALID_PROVIDERS = [
149
150
REPLICATE ,
150
151
POWERED_BY ,
151
152
LEPTON ,
153
+ NSCALE ,
152
154
] ;
153
155
154
156
export const CONTENT_TYPES = {
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ import RecraftAIConfig from './recraft-ai';
56
56
import MilvusConfig from './milvus' ;
57
57
import ReplicateConfig from './replicate' ;
58
58
import LeptonConfig from './lepton' ;
59
+ import NscaleConfig from './nscale' ;
59
60
60
61
const Providers : { [ key : string ] : ProviderConfigs } = {
61
62
openai : OpenAIConfig ,
@@ -112,6 +113,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
112
113
milvus : MilvusConfig ,
113
114
replicate : ReplicateConfig ,
114
115
lepton : LeptonConfig ,
116
+ nscale : NscaleConfig ,
115
117
} ;
116
118
117
119
export default Providers ;
Original file line number Diff line number Diff line change
1
+ import { ProviderAPIConfig } from '../types' ;
2
+
3
+ const NscaleAPIConfig : ProviderAPIConfig = {
4
+ getBaseURL : ( ) => 'https://inference.api.nscale.com/v1' ,
5
+ headers : ( { providerOptions } ) => {
6
+ return { Authorization : `Bearer ${ providerOptions . apiKey } ` } ;
7
+ } ,
8
+ getEndpoint : ( { fn } ) => {
9
+ switch ( fn ) {
10
+ case 'chatComplete' :
11
+ return '/chat/completions' ;
12
+ case 'imageGenerate' :
13
+ return '/images/generations' ;
14
+ default :
15
+ return '' ;
16
+ }
17
+ } ,
18
+ } ;
19
+
20
+ export default NscaleAPIConfig ;
Original file line number Diff line number Diff line change
1
+ import { ParameterConfig } from '../types' ;
2
+
3
+ export const NscaleImageGenerateConfig : { [ key : string ] : ParameterConfig } = {
4
+ prompt : {
5
+ param : 'prompt' ,
6
+ required : true ,
7
+ } ,
8
+ model : {
9
+ param : 'model' ,
10
+ required : true ,
11
+ } ,
12
+ n : {
13
+ param : 'n' ,
14
+ } ,
15
+ size : {
16
+ param : 'size' ,
17
+ } ,
18
+ } ;
19
+
20
+ export const NscaleImageGenerateResponseTransform = ( response : any ) => {
21
+ return {
22
+ created : Date . now ( ) ,
23
+ data : response . data . map ( ( item : any ) => ( {
24
+ url : item . url ,
25
+ b64_json : item . b64_json ,
26
+ } ) ) ,
27
+ } ;
28
+ } ;
Original file line number Diff line number Diff line change
1
+ import { ProviderConfigs } from '../types' ;
2
+ import NscaleAPIConfig from './api' ;
3
+ import {
4
+ NscaleImageGenerateConfig ,
5
+ NscaleImageGenerateResponseTransform ,
6
+ } from './imageGenerate' ;
7
+ import { responseTransformers } from '../open-ai-base' ;
8
+ import { NSCALE } from '../../globals' ;
9
+ import { chatCompleteParams } from '../open-ai-base' ;
10
+
11
+ const NscaleConfig : ProviderConfigs = {
12
+ chatComplete : chatCompleteParams ( [
13
+ 'functions' ,
14
+ 'function_call' ,
15
+ 'user' ,
16
+ 'seed' ,
17
+ 'tools' ,
18
+ 'tool_choice' ,
19
+ 'stream_options' ,
20
+ ] ) ,
21
+ imageGenerate : NscaleImageGenerateConfig ,
22
+ api : NscaleAPIConfig ,
23
+ responseTransforms : {
24
+ ...responseTransformers ( NSCALE , { chatComplete : true } ) ,
25
+ imageGenerate : NscaleImageGenerateResponseTransform ,
26
+ } ,
27
+ } ;
28
+
29
+ export default NscaleConfig ;
Original file line number Diff line number Diff line change @@ -136,6 +136,12 @@ const testVariables: TestVariables = {
136
136
apiKey : process . env . PREDIBASE_API_KEY ,
137
137
chatCompletions : { model : '' } ,
138
138
} ,
139
+ nscale : {
140
+ apiKey : process . env . NSCALE_API_KEY ,
141
+ chatCompletions : {
142
+ model : 'Qwen/Qwen2.5-Coder-3B-Instruct' ,
143
+ } ,
144
+ } ,
139
145
} ;
140
146
141
147
export default testVariables ;
You can’t perform that action at this time.
0 commit comments