@@ -3,49 +3,49 @@ import type { ChatCompletionOutput, TextGenerationOutputFinishReason } from "@hu
33import { InferenceOutputError } from "../lib/InferenceOutputError" ;
44
55interface FeatherlessAITextCompletionOutput extends Omit < ChatCompletionOutput , "choices" > {
6- choices : Array < {
7- text : string ;
8- finish_reason : TextGenerationOutputFinishReason ;
9- seed : number ;
10- logprobs : unknown ;
11- index : number ;
12- } > ;
6+ choices : Array < {
7+ text : string ;
8+ finish_reason : TextGenerationOutputFinishReason ;
9+ seed : number ;
10+ logprobs : unknown ;
11+ index : number ;
12+ } > ;
1313}
1414
1515const FEATHERLESS_API_BASE_URL = "https://api.featherless.ai" ;
1616
1717export class FeatherlessAIConversationalTask extends BaseConversationalTask {
18- constructor ( ) {
19- super ( "featherless-ai" , FEATHERLESS_API_BASE_URL ) ;
20- }
18+ constructor ( ) {
19+ super ( "featherless-ai" , FEATHERLESS_API_BASE_URL ) ;
20+ }
2121}
2222
2323export class FeatherlessAITextGenerationTask extends BaseTextGenerationTask {
24- constructor ( ) {
25- super ( "featherless-ai" , FEATHERLESS_API_BASE_URL ) ;
26- }
24+ constructor ( ) {
25+ super ( "featherless-ai" , FEATHERLESS_API_BASE_URL ) ;
26+ }
2727
28- override preparePayload ( params : BodyParams ) : Record < string , unknown > {
29- return {
30- model : params . model ,
31- ...params . args ,
32- ...params . args . parameters ,
33- prompt : params . args . inputs ,
34- } ;
35- }
28+ override preparePayload ( params : BodyParams ) : Record < string , unknown > {
29+ return {
30+ model : params . model ,
31+ ...params . args ,
32+ ...params . args . parameters ,
33+ prompt : params . args . inputs ,
34+ } ;
35+ }
3636
37- override async getResponse ( response : FeatherlessAITextCompletionOutput ) : Promise < TextGenerationOutput > {
38- if (
39- typeof response === "object" &&
40- "choices" in response &&
41- Array . isArray ( response ?. choices ) &&
42- typeof response ?. model === "string"
43- ) {
44- const completion = response . choices [ 0 ] ;
45- return {
46- generated_text : completion . text ,
47- } ;
48- }
49- throw new InferenceOutputError ( "Expected Together text generation response format" ) ;
50- }
37+ override async getResponse ( response : FeatherlessAITextCompletionOutput ) : Promise < TextGenerationOutput > {
38+ if (
39+ typeof response === "object" &&
40+ "choices" in response &&
41+ Array . isArray ( response ?. choices ) &&
42+ typeof response ?. model === "string"
43+ ) {
44+ const completion = response . choices [ 0 ] ;
45+ return {
46+ generated_text : completion . text ,
47+ } ;
48+ }
49+ throw new InferenceOutputError ( "Expected Together text generation response format" ) ;
50+ }
5151}
0 commit comments