File tree Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ export const UPSTAGE: string = 'upstage';
7777export const LAMBDA : string = 'lambda' ;
7878export const DASHSCOPE : string = 'dashscope' ;
7979export const X_AI : string = 'x-ai' ;
80+ export const CORTEX : string = 'cortex' ;
8081export const SAGEMAKER : string = 'sagemaker' ;
8182export const NEBIUS : string = 'nebius' ;
8283export const RECRAFTAI : string = 'recraft-ai' ;
@@ -131,6 +132,7 @@ export const VALID_PROVIDERS = [
131132 LAMBDA ,
132133 DASHSCOPE ,
133134 X_AI ,
135+ CORTEX ,
134136 SAGEMAKER ,
135137 NEBIUS ,
136138 RECRAFTAI ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 STABILITY_AI ,
1717 SAGEMAKER ,
1818 FIREWORKS_AI ,
19+ CORTEX ,
1920} from '../globals' ;
2021import Providers from '../providers' ;
2122import { ProviderAPIConfig , endpointStrings } from '../providers/types' ;
@@ -1072,6 +1073,10 @@ export function constructConfigFromRequestHeaders(
10721073 }
10731074 }
10741075
1076+ const cortexConfig = {
1077+ snowflakeAccount : requestHeaders [ `x-${ POWERED_BY } -snowflake-account` ] ,
1078+ } ;
1079+
10751080 const defaultsConfig = {
10761081 input_guardrails : requestHeaders [ `x-portkey-default-input-guardrails` ]
10771082 ? JSON . parse ( requestHeaders [ `x-portkey-default-input-guardrails` ] )
@@ -1171,6 +1176,13 @@ export function constructConfigFromRequestHeaders(
11711176 ...stabilityAiConfig ,
11721177 } ;
11731178 }
1179+
1180+ if ( parsedConfigJson . provider === CORTEX ) {
1181+ parsedConfigJson = {
1182+ ...parsedConfigJson ,
1183+ ...cortexConfig ,
1184+ } ;
1185+ }
11741186 }
11751187 return convertKeysToCamelCase ( parsedConfigJson , [
11761188 'override_params' ,
@@ -1215,6 +1227,7 @@ export function constructConfigFromRequestHeaders(
12151227 stabilityAiConfig ) ,
12161228 ...( requestHeaders [ `x-${ POWERED_BY } -provider` ] === FIREWORKS_AI &&
12171229 fireworksConfig ) ,
1230+ ...( requestHeaders [ `x-${ POWERED_BY } -provider` ] === CORTEX && cortexConfig ) ,
12181231 } ;
12191232}
12201233
Original file line number Diff line number Diff line change 1+ import { ProviderAPIConfig } from '../types' ;
2+
3+ const CortexAPIConfig : ProviderAPIConfig = {
4+ getBaseURL : ( { providerOptions } ) =>
5+ `https://${ ( providerOptions as any ) . snowflakeAccount } .snowflakecomputing.com/api/v2` ,
6+ headers : ( { providerOptions } ) => ( {
7+ 'X-Snowflake-Authorization-Token-Type' : 'KEYPAIR_JWT' ,
8+ Authorization : `Bearer ${ providerOptions . apiKey } ` ,
9+ 'Content-Type' : 'application/json' ,
10+ Accept : 'application/json, text/event-stream' ,
11+ } ) ,
12+ getEndpoint : ( { fn } ) => {
13+ switch ( fn ) {
14+ case 'chatComplete' :
15+ return '/cortex/inference:complete' ;
16+ default :
17+ return '' ;
18+ }
19+ } ,
20+ } ;
21+
22+ export default CortexAPIConfig ;
Original file line number Diff line number Diff line change 1+ import { ProviderConfigs } from '../types' ;
2+ import CortexAPIConfig from './api' ;
3+ import { CORTEX } from '../../globals' ;
4+ import {
5+ chatCompleteParams ,
6+ completeParams ,
7+ embedParams ,
8+ responseTransformers ,
9+ } from '../open-ai-base' ;
10+
11+ const CortexConfig : ProviderConfigs = {
12+ chatComplete : chatCompleteParams ( [ ] , { model : 'mistral-large' } ) ,
13+ complete : completeParams ( [ ] , { model : 'mistral-large' } ) ,
14+ embed : embedParams ( [ ] , { model : 'mistral-large' } ) ,
15+ api : CortexAPIConfig ,
16+ responseTransforms : responseTransformers ( CORTEX , {
17+ chatComplete : true ,
18+ } ) ,
19+ } ;
20+
21+ export default CortexConfig ;
Original file line number Diff line number Diff line change @@ -150,6 +150,9 @@ export interface Options {
150150
151151 /** Fireworks finetune required fields */
152152 fireworksAccountId ?: string ;
153+
154+ /** Cortex specific fields */
155+ snowflakeAccount ?: string ;
153156}
154157
155158/**
You can’t perform that action at this time.
0 commit comments