Skip to content

Commit 7091bc9

Browse files
authored
Merge branch 'main' into panw-prisma-airs-plugin
2 parents 1f903a8 + 6d19ea0 commit 7091bc9

File tree

6 files changed

+87
-0
lines changed

6 files changed

+87
-0
lines changed

src/globals.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const RECRAFTAI: string = 'recraft-ai';
9292
export const MILVUS: string = 'milvus';
9393
export const REPLICATE: string = 'replicate';
9494
export const LEPTON: string = 'lepton';
95+
export const NSCALE: string = 'nscale';
9596

9697
export const VALID_PROVIDERS = [
9798
ANTHROPIC,
@@ -149,6 +150,7 @@ export const VALID_PROVIDERS = [
149150
REPLICATE,
150151
POWERED_BY,
151152
LEPTON,
153+
NSCALE,
152154
];
153155

154156
export const CONTENT_TYPES = {

src/providers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import RecraftAIConfig from './recraft-ai';
5656
import MilvusConfig from './milvus';
5757
import ReplicateConfig from './replicate';
5858
import LeptonConfig from './lepton';
59+
import NscaleConfig from './nscale';
5960

6061
const Providers: { [key: string]: ProviderConfigs } = {
6162
openai: OpenAIConfig,
@@ -112,6 +113,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
112113
milvus: MilvusConfig,
113114
replicate: ReplicateConfig,
114115
lepton: LeptonConfig,
116+
nscale: NscaleConfig,
115117
};
116118

117119
export default Providers;

src/providers/nscale/api.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
};

src/providers/nscale/index.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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;

src/tests/resources/testVariables.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ const testVariables: TestVariables = {
136136
apiKey: process.env.PREDIBASE_API_KEY,
137137
chatCompletions: { model: '' },
138138
},
139+
nscale: {
140+
apiKey: process.env.NSCALE_API_KEY,
141+
chatCompletions: {
142+
model: 'Qwen/Qwen2.5-Coder-3B-Instruct',
143+
},
144+
},
139145
};
140146

141147
export default testVariables;

0 commit comments

Comments
 (0)