Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Files and Batches as a unified route #862

Merged
merged 16 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove unused cohere getBatchOutput method code, have to reimplement …
…it again
  • Loading branch information
narengogi committed Jan 14, 2025
commit 17fd0d56f324f0eeaa42b52a95f55a8848108801
4 changes: 2 additions & 2 deletions src/providers/ai21/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const AI21APIConfig: ProviderAPIConfig = {
};
return headers;
},
getEndpoint: ({ fn, gatewayRequestBodyJSON: gatewayRequestBody }) => {
const { model } = gatewayRequestBody;
getEndpoint: ({ fn, gatewayRequestBodyJSON }) => {
const { model } = gatewayRequestBodyJSON;
switch (fn) {
case 'complete': {
return `/${model}/complete`;
Expand Down
8 changes: 2 additions & 6 deletions src/providers/bedrock/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ const BedrockAPIConfig: ProviderAPIConfig = {
providerOptions.awsSessionToken || ''
);
},
getEndpoint: ({
fn,
gatewayRequestBodyJSON: gatewayRequestBody,
gatewayRequestURL,
}) => {
getEndpoint: ({ fn, gatewayRequestBodyJSON, gatewayRequestURL }) => {
if (fn === 'uploadFile') return '';
if (fn === 'retrieveFileContent') {
const objectName = gatewayRequestURL.split('/v1/files/')[1].split('/')[0];
Expand All @@ -132,7 +128,7 @@ const BedrockAPIConfig: ProviderAPIConfig = {
const batchId = gatewayRequestURL.split('/v1/batches/')[1].split('/')[0];
return `/model-invocation-job/${batchId}/stop`;
}
const { model, stream } = gatewayRequestBody;
const { model, stream } = gatewayRequestBodyJSON;
let mappedFn: string = fn;
if (stream) {
mappedFn = `stream-${fn}`;
Expand Down
98 changes: 0 additions & 98 deletions src/providers/cohere/getBatchOutput.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/providers/fireworks-ai/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const FireworksAIAPIConfig: ProviderAPIConfig = {
Accept: 'application/json',
};
},
getEndpoint: ({ fn, gatewayRequestBodyJSON: gatewayRequestBody }) => {
const model = gatewayRequestBody?.model;
getEndpoint: ({ fn, gatewayRequestBodyJSON }) => {
const model = gatewayRequestBodyJSON?.model;
switch (fn) {
case 'complete':
return '/completions';
Expand Down
8 changes: 2 additions & 6 deletions src/providers/google-vertex-ai/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ export const GoogleApiConfig: ProviderAPIConfig = {
Authorization: `Bearer ${authToken}`,
};
},
getEndpoint: ({
fn,
gatewayRequestBodyJSON: gatewayRequestBody,
providerOptions,
}) => {
getEndpoint: ({ fn, gatewayRequestBodyJSON, providerOptions }) => {
let mappedFn = fn;
const { model: inputModel, stream } = gatewayRequestBody;
const { model: inputModel, stream } = gatewayRequestBodyJSON;
if (stream) {
mappedFn = `stream-${fn}`;
}
Expand Down
8 changes: 2 additions & 6 deletions src/providers/google/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ export const GoogleApiConfig: ProviderAPIConfig = {
headers: () => {
return { 'Content-Type': 'application/json' };
},
getEndpoint: ({
fn,
providerOptions,
gatewayRequestBodyJSON: gatewayRequestBody,
}) => {
getEndpoint: ({ fn, providerOptions, gatewayRequestBodyJSON }) => {
let mappedFn = fn;
const { model, stream } = gatewayRequestBody;
const { model, stream } = gatewayRequestBodyJSON;
const { apiKey } = providerOptions;
if (stream) {
mappedFn = `stream-${fn}`;
Expand Down
8 changes: 2 additions & 6 deletions src/providers/huggingface/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ const HuggingfaceAPIConfig: ProviderAPIConfig = {
headers: ({ providerOptions }) => ({
Authorization: `Bearer ${providerOptions.apiKey}`,
}),
getEndpoint: ({
fn,
gatewayRequestBodyJSON: gatewayRequestBody,
providerOptions,
}) => {
const { model } = gatewayRequestBody;
getEndpoint: ({ fn, gatewayRequestBodyJSON, providerOptions }) => {
const { model } = gatewayRequestBodyJSON;
const modelPath = providerOptions.huggingfaceBaseUrl
? ''
: `/models/${model}`;
Expand Down
8 changes: 2 additions & 6 deletions src/providers/palm/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ export const PalmApiConfig: ProviderAPIConfig = {
headers: () => {
return { 'Content-Type': 'application/json' };
},
getEndpoint: ({
providerOptions,
fn,
gatewayRequestBodyJSON: gatewayRequestBody,
}) => {
getEndpoint: ({ providerOptions, fn, gatewayRequestBodyJSON }) => {
const { apiKey } = providerOptions;
const { model } = gatewayRequestBody;
const { model } = gatewayRequestBodyJSON;
switch (fn) {
case 'complete': {
return `/models/${model}:generateText?key=${apiKey}`;
Expand Down
6 changes: 3 additions & 3 deletions src/providers/predibase/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const PredibaseAPIConfig: ProviderAPIConfig = {
Accept: 'application/json',
};
},
getEndpoint: ({ fn, gatewayRequestBodyJSON: gatewayRequestBody }) => {
const user = gatewayRequestBody?.user;
const model = gatewayRequestBody?.model;
getEndpoint: ({ fn, gatewayRequestBodyJSON }) => {
const user = gatewayRequestBodyJSON?.user;
const model = gatewayRequestBodyJSON?.model;
const base_model = splitString(`${model}`, ':').before;
switch (fn) {
case 'chatComplete':
Expand Down
4 changes: 2 additions & 2 deletions src/providers/segmind/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const StabilityAIAPIConfig: ProviderAPIConfig = {
headers: ({ providerOptions }) => {
return { 'x-api-key': `${providerOptions.apiKey}` };
},
getEndpoint: ({ gatewayRequestBodyJSON: gatewayRequestBody }) => {
return `/${gatewayRequestBody.model}`;
getEndpoint: ({ gatewayRequestBodyJSON }) => {
return `/${gatewayRequestBodyJSON.model}`;
},
};

Expand Down
4 changes: 2 additions & 2 deletions src/providers/siliconflow/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const SiliconFlowAPIConfig: ProviderAPIConfig = {
Authorization: `Bearer ${providerOptions.apiKey}`,
};
},
getEndpoint: ({ fn, gatewayRequestBodyJSON: gatewayRequestBody }) => {
const { model = 'ByteDance/SDXL-Lightning' } = gatewayRequestBody;
getEndpoint: ({ fn, gatewayRequestBodyJSON }) => {
const { model = 'ByteDance/SDXL-Lightning' } = gatewayRequestBodyJSON;
switch (fn) {
case 'chatComplete':
return '/chat/completions';
Expand Down
12 changes: 4 additions & 8 deletions src/providers/stability-ai/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const StabilityAIAPIConfig: ProviderAPIConfig = {
headers['Accept'] = CONTENT_TYPES.APPLICATION_JSON;
return headers;
},
getEndpoint: ({
fn,
gatewayRequestBodyJSON: gatewayRequestBody,
providerOptions,
}) => {
getEndpoint: ({ fn, gatewayRequestBodyJSON, providerOptions }) => {
let mappedFn = fn;
const { urlToFetch } = providerOptions;
if (
Expand All @@ -30,9 +26,9 @@ const StabilityAIAPIConfig: ProviderAPIConfig = {

switch (mappedFn) {
case 'imageGenerate': {
if (isStabilityV1Model(gatewayRequestBody.model))
return `/v1/generation/${gatewayRequestBody.model}/text-to-image`;
return `/v2beta/stable-image/generate/${gatewayRequestBody.model}`;
if (isStabilityV1Model(gatewayRequestBodyJSON.model))
return `/v1/generation/${gatewayRequestBodyJSON.model}/text-to-image`;
return `/v2beta/stable-image/generate/${gatewayRequestBodyJSON.model}`;
}
default:
return '';
Expand Down
Loading