@@ -10,57 +10,62 @@ import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper
1010const CENTML_API_BASE_URL = "https://api.centml.com" ;
1111
1212export class CentMLConversationalTask extends BaseConversationalTask {
13- constructor ( ) {
14- super ( "centml" , CENTML_API_BASE_URL ) ;
15- }
13+ constructor ( ) {
14+ super ( "centml" , CENTML_API_BASE_URL ) ;
15+ }
1616
17- override preparePayload ( params : BodyParams ) : Record < string , unknown > {
18- const { args, model } = params ;
19- return {
20- ...args ,
21- model,
22- api_key : args . accessToken , // Use the accessToken from args
23- } ;
24- }
17+ override makeRoute ( ) : string {
18+ return "openai/v1/chat/completions" ;
19+ }
2520
26- override async getResponse ( response : ChatCompletionOutput ) : Promise < ChatCompletionOutput > {
27- if (
28- typeof response === "object" &&
29- Array . isArray ( response ?. choices ) &&
30- typeof response ?. created === "number" &&
31- typeof response ?. id === "string" &&
32- typeof response ?. model === "string" &&
33- typeof response ?. usage === "object"
34- ) {
35- return response ;
36- }
21+ override preparePayload ( params : BodyParams ) : Record < string , unknown > {
22+ const { args, model } = params ;
23+ return {
24+ ...args ,
25+ model,
26+ api_key : args . accessToken ,
27+ } ;
28+ }
3729
38- throw new InferenceOutputError ( "Expected ChatCompletionOutput" ) ;
39- }
30+ override async getResponse ( response : ChatCompletionOutput ) : Promise < ChatCompletionOutput > {
31+ if (
32+ typeof response === "object" &&
33+ Array . isArray ( response ?. choices ) &&
34+ typeof response ?. created === "number" &&
35+ typeof response ?. id === "string" &&
36+ typeof response ?. model === "string" &&
37+ typeof response ?. usage === "object"
38+ ) {
39+ return response ;
40+ }
41+
42+ throw new InferenceOutputError ( "Expected ChatCompletionOutput" ) ;
43+ }
4044}
4145
4246export class CentMLTextGenerationTask extends BaseTextGenerationTask {
43- constructor ( ) {
44- super ( "centml" , CENTML_API_BASE_URL ) ;
45- }
47+ constructor ( ) {
48+ super ( "centml" , CENTML_API_BASE_URL ) ;
49+ }
50+
51+ override makeRoute ( ) : string {
52+ return "openai/v1/completions" ;
53+ }
4654
47- override preparePayload ( params : BodyParams ) : Record < string , unknown > {
48- const { args, model } = params ;
49- return {
50- ...args ,
51- model,
52- api_key : args . accessToken , // Use the accessToken from args
53- } ;
54- }
55+ override preparePayload ( params : BodyParams ) : Record < string , unknown > {
56+ const { args, model } = params ;
57+ return {
58+ ...args ,
59+ model,
60+ api_key : args . accessToken ,
61+ } ;
62+ }
5563
56- override async getResponse ( response : TextGenerationOutput ) : Promise < TextGenerationOutput > {
57- if (
58- typeof response === "object" &&
59- typeof response ?. generated_text === "string"
60- ) {
61- return response ;
62- }
64+ override async getResponse ( response : TextGenerationOutput ) : Promise < TextGenerationOutput > {
65+ if ( typeof response === "object" && typeof response ?. generated_text === "string" ) {
66+ return response ;
67+ }
6368
64- throw new InferenceOutputError ( "Expected TextGenerationOutput" ) ;
65- }
69+ throw new InferenceOutputError ( "Expected TextGenerationOutput" ) ;
70+ }
6671}
0 commit comments