Function
createResponseFormatPayload
(
basePayload: any,
allMessages: any[],
responseFormat: any,
currentMessages?: any[]
)
Source from the content-addressed store, hash-verified
| 17 | * Creates a response format payload for xAI requests with JSON schema. |
| 18 | */ |
| 19 | export function createResponseFormatPayload( |
| 20 | basePayload: any, |
| 21 | allMessages: any[], |
| 22 | responseFormat: any, |
| 23 | currentMessages?: any[] |
| 24 | ) { |
| 25 | const payload = { |
| 26 | ...basePayload, |
| 27 | messages: currentMessages || allMessages, |
| 28 | } |
| 29 | |
| 30 | if (responseFormat) { |
| 31 | payload.response_format = { |
| 32 | type: 'json_schema', |
| 33 | json_schema: { |
| 34 | name: responseFormat.name || 'structured_response', |
| 35 | schema: responseFormat.schema || responseFormat, |
| 36 | strict: responseFormat.strict !== false, |
| 37 | }, |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return payload |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Checks if a forced tool was used in an xAI response. |
Tested by
no test coverage detected