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 GREENPT: string = 'greenpt';

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

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

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

export default GreenPTAPIConfig;
17 changes: 17 additions & 0 deletions src/providers/greenpt/greenpt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { GREENPT, VALID_PROVIDERS } from '../../globals';
import GreenPTAPIConfig from './api';

describe('GreenPT provider', () => {
it('registers its OpenAI-compatible endpoints', () => {
expect(VALID_PROVIDERS).toContain(GREENPT);
expect(GreenPTAPIConfig.getBaseURL({} as never)).toBe(
'https://api.greenpt.ai/v1'
);
expect(GreenPTAPIConfig.getEndpoint({ fn: 'chatComplete' } as never)).toBe(
'/chat/completions'
);
expect(GreenPTAPIConfig.getEndpoint({ fn: 'embed' } as never)).toBe(
'/embeddings'
);
});
});
20 changes: 20 additions & 0 deletions src/providers/greenpt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { GREENPT } from '../../globals';
import {
chatCompleteParams,
embedParams,
responseTransformers,
} from '../open-ai-base';
import { ProviderConfigs } from '../types';
import GreenPTAPIConfig from './api';

const GreenPTConfig: ProviderConfigs = {
chatComplete: chatCompleteParams([], { model: 'glm-5.2' }),
embed: embedParams([], { model: 'green-embedding' }),
api: GreenPTAPIConfig,
responseTransforms: responseTransformers(GREENPT, {
chatComplete: true,
embed: true,
}),
};

export default GreenPTConfig;
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 GreenPTConfig from './greenpt';

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,
greenpt: GreenPTConfig,
};

export default Providers;