Skip to content
Open
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 @@ -113,6 +113,7 @@ export const ORACLE: string = 'oracle';
export const IO_INTELLIGENCE: string = 'iointelligence';
export const AIBADGR: string = 'aibadgr';
export const OVHCLOUD: string = 'ovhcloud';
export const AVIAN: string = 'avian';

export const VALID_PROVIDERS = [
ANTHROPIC,
Expand Down Expand Up @@ -189,6 +190,7 @@ export const VALID_PROVIDERS = [
IO_INTELLIGENCE,
AIBADGR,
OVHCLOUD,
AVIAN,
];

export const CONTENT_TYPES = {
Expand Down
20 changes: 20 additions & 0 deletions src/providers/avian/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ProviderAPIConfig } from '../types';

const AvianAPIConfig: ProviderAPIConfig = {
getBaseURL: () => 'https://api.avian.io/v1',
headers: ({ providerOptions }) => {
return {
Authorization: `Bearer ${providerOptions.apiKey}`,
};
},
getEndpoint: ({ fn }) => {
switch (fn) {
case 'chatComplete':
return '/chat/completions';
default:
return '';
}
},
};

export default AvianAPIConfig;
65 changes: 65 additions & 0 deletions src/providers/avian/chatComplete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { AVIAN } from '../../globals';

interface AvianStreamChunk {
id: string;
object: string;
created: number;
model: string;
choices: {
index: number;
delta: {
role?: string | null;
content?: string;
tool_calls?: {
index: number;
id?: string;
type?: string;
function?: {
name?: string;
arguments?: string;
};
}[];
};
finish_reason: string | null;
}[];
usage?: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
}

export const AvianChatCompleteStreamChunkTransform: (
responseChunk: string
) => string = (responseChunk) => {
let chunk = responseChunk.trim();
chunk = chunk.replace(/^data: /, '');
chunk = chunk.trim();

if (chunk === '[DONE]') {
return `data: ${chunk}\n\n`;
}

const parsedChunk: AvianStreamChunk = JSON.parse(chunk);
return (
`data: ${JSON.stringify({
id: parsedChunk.id,
object: parsedChunk.object,
created: parsedChunk.created,
model: parsedChunk.model,
provider: AVIAN,
choices: parsedChunk.choices.map((choice) => ({
index: choice.index,
delta: choice.delta,
finish_reason: choice.finish_reason,
})),
usage: parsedChunk.usage
? {
prompt_tokens: parsedChunk.usage.prompt_tokens,
completion_tokens: parsedChunk.usage.completion_tokens,
total_tokens: parsedChunk.usage.total_tokens,
}
: undefined,
})}` + '\n\n'
);
};
20 changes: 20 additions & 0 deletions src/providers/avian/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AVIAN } from '../../globals';
import { chatCompleteParams, responseTransformers } from '../open-ai-base';
import { ProviderConfigs } from '../types';
import AvianAPIConfig from './api';
import { AvianChatCompleteStreamChunkTransform } from './chatComplete';

const AvianConfig: ProviderConfigs = {
chatComplete: chatCompleteParams([], {
model: 'deepseek/deepseek-v3.2',
}),
api: AvianAPIConfig,
responseTransforms: {
...responseTransformers(AVIAN, {
chatComplete: true,
}),
'stream-chatComplete': AvianChatCompleteStreamChunkTransform,
},
};

export default AvianConfig;
2 changes: 2 additions & 0 deletions src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import OracleConfig from './oracle';
import IOIntelligenceConfig from './iointelligence';
import AIBadgrConfig from './aibadgr';
import OVHcloudConfig from './ovhcloud';
import AvianConfig from './avian';

const Providers: { [key: string]: ProviderConfigs } = {
openai: OpenAIConfig,
Expand Down Expand Up @@ -148,6 +149,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
iointelligence: IOIntelligenceConfig,
aibadgr: AIBadgrConfig,
ovhcloud: OVHcloudConfig,
avian: AvianConfig,
};

export default Providers;