MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / addJsonMode

Function addJsonMode

packages/baseai/src/dev/utils/thread/add-json-mode.ts:13–31  ·  view source on GitHub ↗
({
	pipe,
	systemPrompt
}: {
	pipe: Pipe;
	systemPrompt: string;
})

Source from the content-addressed store, hash-verified

11import type { Pipe } from 'types/pipe';
12
13export function addJsonMode({
14 pipe,
15 systemPrompt
16}: {
17 pipe: Pipe;
18 systemPrompt: string;
19}) {
20 // Return the system prompt if JSON mode is not enabled
21 if (!pipe?.json) return systemPrompt;
22
23 const modelName = pipe.model.split(':')[1];
24 // Return the system prompt if JSON mode is not supported by the current model
25 if (!jsonModeModels.includes(modelName)) return systemPrompt;
26
27 const jsonModePrompt = getJsonPrompt(pipe);
28
29 // Add JSON mode if enabled & supported by model
30 return `${systemPrompt}\n\n${jsonModePrompt}`;
31}
32
33function getJsonPrompt(pipe: Pipe): string {
34 const jsonPrompt =

Callers 1

getSystemPromptMessageFunction · 0.90

Calls 1

getJsonPromptFunction · 0.85

Tested by

no test coverage detected