Skip to content

Commit c4ce77a

Browse files
committed
remove rendering system prompt env for multiagent template
1 parent 7c687ac commit c4ce77a

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

helpers/env-variables.ts

+20-19
Original file line numberDiff line numberDiff line change
@@ -426,34 +426,35 @@ const getToolEnvs = (tools?: Tool[]): EnvVar[] => {
426426
const getSystemPromptEnv = (
427427
tools?: Tool[],
428428
dataSources?: TemplateDataSource[],
429-
framework?: TemplateFramework,
429+
template?: TemplateType,
430430
): EnvVar[] => {
431431
const defaultSystemPrompt =
432432
"You are a helpful assistant who helps users with their questions.";
433433

434+
const systemPromptEnv: EnvVar[] = [];
434435
// build tool system prompt by merging all tool system prompts
435-
let toolSystemPrompt = "";
436-
tools?.forEach((tool) => {
437-
const toolSystemPromptEnv = tool.envVars?.find(
438-
(env) => env.name === TOOL_SYSTEM_PROMPT_ENV_VAR,
439-
);
440-
if (toolSystemPromptEnv) {
441-
toolSystemPrompt += toolSystemPromptEnv.value + "\n";
442-
}
443-
});
436+
// multiagent template doesn't need system prompt
437+
if (template !== "multiagent") {
438+
let toolSystemPrompt = "";
439+
tools?.forEach((tool) => {
440+
const toolSystemPromptEnv = tool.envVars?.find(
441+
(env) => env.name === TOOL_SYSTEM_PROMPT_ENV_VAR,
442+
);
443+
if (toolSystemPromptEnv) {
444+
toolSystemPrompt += toolSystemPromptEnv.value + "\n";
445+
}
446+
});
444447

445-
const systemPrompt = toolSystemPrompt
446-
? `\"${toolSystemPrompt}\"`
447-
: defaultSystemPrompt;
448+
const systemPrompt = toolSystemPrompt
449+
? `\"${toolSystemPrompt}\"`
450+
: defaultSystemPrompt;
448451

449-
const systemPromptEnv = [
450-
{
452+
systemPromptEnv.push({
451453
name: "SYSTEM_PROMPT",
452454
description: "The system prompt for the AI model.",
453455
value: systemPrompt,
454-
},
455-
];
456-
456+
});
457+
}
457458
if (tools?.length == 0 && (dataSources?.length ?? 0 > 0)) {
458459
const citationPrompt = `'You have provided information from a knowledge base that has been passed to you in nodes of information.
459460
Each node has useful metadata such as node ID, file name, page, etc.
@@ -559,7 +560,7 @@ export const createBackendEnvFile = async (
559560
...getToolEnvs(opts.tools),
560561
...getTemplateEnvs(opts.template),
561562
...getObservabilityEnvs(opts.observability),
562-
...getSystemPromptEnv(opts.tools, opts.dataSources, opts.framework),
563+
...getSystemPromptEnv(opts.tools, opts.dataSources, opts.template),
563564
];
564565
// Render and write env file
565566
const content = renderEnvVar(envVars);

0 commit comments

Comments
 (0)