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

Function applyJsonResponseFormat

apps/sim/providers/ollama/core.ts:30–41  ·  view source on GitHub ↗

* Ollama enforces JSON mode (`json_object`) but ignores `json_schema`, so * structured outputs use JSON mode with the schema described in-prompt. Mutates * `payload.response_format` and returns the messages with instructions appended.

(
  payload: { response_format?: unknown },
  messages: Message[],
  responseFormat: NonNullable<ProviderRequest['responseFormat']>
)

Source from the content-addressed store, hash-verified

28 * `payload.response_format` and returns the messages with instructions appended.
29 */
30function applyJsonResponseFormat(
31 payload: { response_format?: unknown },
32 messages: Message[],
33 responseFormat: NonNullable<ProviderRequest['responseFormat']>
34): Message[] {
35 payload.response_format = { type: 'json_object' }
36 const schema = responseFormat.schema || responseFormat
37 return [
38 ...messages,
39 { role: 'user', content: generateSchemaInstructions(schema, responseFormat.name) },
40 ]
41}
42
43/**
44 * Per-provider hooks for the shared Ollama execution logic. The self-hosted

Callers 1

Calls 1

Tested by

no test coverage detected