@@ -3,49 +3,49 @@ import type { ChatCompletionOutput, TextGenerationOutputFinishReason } from "@hu
3
3
import { InferenceOutputError } from "../lib/InferenceOutputError" ;
4
4
5
5
interface 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
+ } > ;
13
13
}
14
14
15
15
const FEATHERLESS_API_BASE_URL = "https://api.featherless.ai" ;
16
16
17
17
export 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
+ }
21
21
}
22
22
23
23
export 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
+ }
27
27
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
+ }
36
36
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
+ }
51
51
}
0 commit comments