File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
packages/inference/src/providers Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
25
25
type TextToImageTaskHelper ,
26
26
} from "./providerHelper.js" ;
27
27
import { InferenceClientProviderOutputError } from "../errors.js" ;
28
+ import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js" ;
28
29
29
30
const NEBIUS_API_BASE_URL = "https://api.studio.nebius.ai" ;
30
31
@@ -50,6 +51,17 @@ export class NebiusConversationalTask extends BaseConversationalTask {
50
51
constructor ( ) {
51
52
super ( "nebius" , NEBIUS_API_BASE_URL ) ;
52
53
}
54
+
55
+ override preparePayload ( params : BodyParams < ChatCompletionInput > ) : Record < string , unknown > {
56
+ const payload = super . preparePayload ( params ) as Record < string , unknown > ;
57
+
58
+ const responseFormat = params . args . response_format ;
59
+ if ( responseFormat ?. type === "json_schema" && responseFormat . json_schema ?. schema ) {
60
+ payload [ "guided_json" ] = responseFormat . json_schema . schema ;
61
+ }
62
+
63
+ return payload ;
64
+ }
53
65
}
54
66
55
67
export class NebiusTextGenerationTask extends BaseTextGenerationTask {
Original file line number Diff line number Diff line change @@ -19,11 +19,25 @@ import type { BodyParams } from "../types.js";
19
19
import type { FeatureExtractionTaskHelper } from "./providerHelper.js" ;
20
20
import { BaseConversationalTask , TaskProviderHelper } from "./providerHelper.js" ;
21
21
import { InferenceClientProviderOutputError } from "../errors.js" ;
22
+ import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js" ;
22
23
23
24
export class SambanovaConversationalTask extends BaseConversationalTask {
24
25
constructor ( ) {
25
26
super ( "sambanova" , "https://api.sambanova.ai" ) ;
26
27
}
28
+
29
+ override preparePayload ( params : BodyParams < ChatCompletionInput > ) : Record < string , unknown > {
30
+ const responseFormat = params . args . response_format ;
31
+
32
+ if ( responseFormat ?. type === "json_schema" && responseFormat . json_schema ) {
33
+ if ( responseFormat . json_schema . strict ?? true ) {
34
+ responseFormat . json_schema . strict = false ;
35
+ }
36
+ }
37
+ const payload = super . preparePayload ( params ) as Record < string , unknown > ;
38
+
39
+ return payload ;
40
+ }
27
41
}
28
42
29
43
export class SambanovaFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import {
24
24
type TextToImageTaskHelper ,
25
25
} from "./providerHelper.js" ;
26
26
import { InferenceClientProviderOutputError } from "../errors.js" ;
27
+ import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js" ;
27
28
28
29
const TOGETHER_API_BASE_URL = "https://api.together.xyz" ;
29
30
@@ -47,6 +48,22 @@ export class TogetherConversationalTask extends BaseConversationalTask {
47
48
constructor ( ) {
48
49
super ( "together" , TOGETHER_API_BASE_URL ) ;
49
50
}
51
+
52
+ override preparePayload ( params : BodyParams < ChatCompletionInput > ) : Record < string , unknown > {
53
+ const payload = super . preparePayload ( params ) ;
54
+ const response_format = payload . response_format as
55
+ | { type : "json_schema" ; json_schema : { schema : unknown } }
56
+ | undefined ;
57
+
58
+ if ( response_format ?. type === "json_schema" && response_format ?. json_schema ?. schema ) {
59
+ payload . response_format = {
60
+ type : "json_schema" ,
61
+ schema : response_format . json_schema . schema ,
62
+ } ;
63
+ }
64
+
65
+ return payload ;
66
+ }
50
67
}
51
68
52
69
export class TogetherTextGenerationTask extends BaseTextGenerationTask {
You can’t perform that action at this time.
0 commit comments