MCPcopy Index your code
hub / github.com/simstudioai/sim / applyResponseFormat

Function applyResponseFormat

apps/sim/providers/together/index.ts:41–66  ·  view source on GitHub ↗

* Applies structured output configuration to a payload based on model capabilities. * Uses native json_schema for supported models, falls back to json_object with prompt instructions.

(
  targetPayload: any,
  messages: any[],
  responseFormat: any,
  model: string
)

Source from the content-addressed store, hash-verified

39 * Uses native json_schema for supported models, falls back to json_object with prompt instructions.
40 */
41async function applyResponseFormat(
42 targetPayload: any,
43 messages: any[],
44 responseFormat: any,
45 model: string
46): Promise<any[]> {
47 const useNative = await supportsNativeStructuredOutputs(model)
48
49 if (useNative) {
50 logger.info('Using native structured outputs for Together model', { model })
51 targetPayload.response_format = {
52 type: 'json_schema',
53 json_schema: {
54 name: responseFormat.name || 'response_schema',
55 schema: responseFormat.schema || responseFormat,
56 },
57 }
58 return messages
59 }
60
61 logger.info('Using json_object mode with prompt instructions for Together model', { model })
62 const schema = responseFormat.schema || responseFormat
63 const schemaInstructions = generateSchemaInstructions(schema, responseFormat.name)
64 targetPayload.response_format = { type: 'json_object' }
65 return [...messages, { role: 'user', content: schemaInstructions }]
66}
67
68export const togetherProvider: ProviderConfig = {
69 id: 'together',

Callers 1

index.tsFile · 0.70

Calls 3

infoMethod · 0.80

Tested by

no test coverage detected