Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const LEPTON: string = 'lepton';
export const KLUSTER_AI: string = 'kluster-ai';
export const NSCALE: string = 'nscale';
export const HYPERBOLIC: string = 'hyperbolic';
export const BYTEZ: string = 'bytez';
export const FEATHERLESS_AI: string = 'featherless-ai';
export const KRUTRIM: string = 'krutrim';
export const QDRANT: string = 'qdrant';
Expand Down Expand Up @@ -158,6 +159,7 @@ export const VALID_PROVIDERS = [
KLUSTER_AI,
NSCALE,
HYPERBOLIC,
BYTEZ,
FEATHERLESS_AI,
KRUTRIM,
QDRANT,
Expand Down
20 changes: 20 additions & 0 deletions src/providers/bytez/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ProviderAPIConfig } from '../types';
import { version } from '../../../package.json';

const BytezInferenceAPI: ProviderAPIConfig = {
getBaseURL: () => 'https://api.bytez.com',
headers: async ({ providerOptions }) => {
const { apiKey } = providerOptions;

const headers: Record<string, string> = {};

headers['Authorization'] = `Key ${apiKey}`;
headers['user-agent'] = `portkey/${version}`;

return headers;
},
getEndpoint: ({ gatewayRequestBodyJSON: { version = 2, model } }) =>
`/models/v${version}/${model}`,
};

export default BytezInferenceAPI;
77 changes: 77 additions & 0 deletions src/providers/bytez/chatComplete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { BYTEZ } from '../../globals';
import { ProviderConfig } from '../types';
import { BytezResponse } from './types';
import { generateErrorResponse } from '../utils';

const BytezInferenceChatCompleteConfig: ProviderConfig = {
messages: {
param: 'messages',
required: true,
},
max_tokens: {
param: 'params.max_new_tokens',
default: 100,
min: 0,
},
temperature: {
param: 'params.temperature',
default: 1,
min: 0,
max: 2,
},
top_p: {
param: 'params.top_p',
default: 1,
min: 0,
max: 1,
},
stream: {
param: 'stream',
default: false,
},
};

function chatComplete(
response: BytezResponse,
responseStatus: number,
responseHeaders: any,
strictOpenAiCompliance: boolean,
endpoint: string,
requestBody: any
) {
const { error, output } = response;

if (error) {
return generateErrorResponse(
{
message: error,
type: String(responseStatus),
param: null,
code: null,
},
BYTEZ
);
}

return {
id: crypto.randomUUID(),
object: 'chat.completion',
created: Date.now(),
model: requestBody.model,
choices: [
{
index: 0,
message: output,
logprobs: null,
finish_reason: 'stop',
},
],
usage: {
completion_tokens: -1,
prompt_tokens: -1,
total_tokens: -1,
},
};
}

export { BytezInferenceChatCompleteConfig, chatComplete };
13 changes: 13 additions & 0 deletions src/providers/bytez/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ProviderConfigs } from '../types';
import BytezInferenceAPI from './api';
import { BytezInferenceChatCompleteConfig, chatComplete } from './chatComplete';

const BytezInferenceAPIConfig: ProviderConfigs = {
api: BytezInferenceAPI,
chatComplete: BytezInferenceChatCompleteConfig,
responseTransforms: {
chatComplete,
},
};

export default BytezInferenceAPIConfig;
10 changes: 10 additions & 0 deletions src/providers/bytez/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
interface Model {
task: string;
}

interface BytezResponse {
error: string;
output: Model[];
}

export { Model, BytezResponse };
2 changes: 2 additions & 0 deletions src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BytezConfig from './bytez';
import AI21Config from './ai21';
import AnthropicConfig from './anthropic';
import AnyscaleConfig from './anyscale';
Expand Down Expand Up @@ -120,6 +121,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
'kluster-ai': KlusterAIConfig,
nscale: NscaleConfig,
hyperbolic: HyperbolicConfig,
bytez: BytezConfig,
'featherless-ai': FeatherlessAIConfig,
krutrim: KrutrimConfig,
};
Expand Down
2 changes: 2 additions & 0 deletions src/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ <h3>Select Provider</h3>
<option value="together-ai">Together AI</option>
<option value="perplexity-ai">Perplexity AI</option>
<option value="mistral-ai">Mistral AI</option>
<option value="bytez">Bytez</option>
<option value="others">Others</option>
</select>
</div>
Expand Down Expand Up @@ -1465,6 +1466,7 @@ <h3>Enter API Key</h3>
"together-ai": "llama-3.1-8b-instruct",
"perplexity-ai": "pplx-7b-online",
"mistral-ai": "mistral-small-latest",
"bytez": "google/gemma-3-1b-it",
"others": "gpt-4o-mini"
}

Expand Down
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DEEPINFRA,
SAMBANOVA,
BEDROCK,
BYTEZ,
} from './globals';
import { Params } from './types/requestBody';

Expand Down Expand Up @@ -48,9 +49,13 @@ export const getStreamModeSplitPattern = (
splitPattern = '\n';
}

if (proxyProvider === BYTEZ) {
splitPattern = ' ';
}

return splitPattern;
};
export type SplitPatternType = '\n\n' | '\r\n\r\n' | '\n' | '\r\n';
export type SplitPatternType = '\n\n' | '\r\n\r\n' | '\n' | '\r\n' | ' ';

export const getStreamingMode = (
reqBody: Params,
Expand Down