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

Function getVarsMap

packages/baseai/src/dev/utils/thread/process-messages.ts:26–64  ·  view source on GitHub ↗
({
	pipe,
	variables
}: {
	pipe: Pipe;
	variables?: VariablesI;
})

Source from the content-addressed store, hash-verified

24}
25
26function getVarsMap({
27 pipe,
28 variables
29}: {
30 pipe: Pipe;
31 variables?: VariablesI;
32}) {
33 const hasPipeVars = pipe.variables ? pipe.variables.length > 0 : false;
34 const hasCurrentPromptVars = variables ? variables.length > 0 : false;
35
36 const pipeVars = hasPipeVars ? pipe.variables : [];
37 const currentPromptVars = hasCurrentPromptVars ? variables : [];
38
39 let finalVariablesMap: Map<string, string> = new Map();
40
41 if (hasPipeVars) {
42 pipeVars.forEach((v: { name: string; value: string }) =>
43 finalVariablesMap.set(v.name, v.value)
44 );
45 }
46
47 if (hasCurrentPromptVars) {
48 currentPromptVars?.forEach((v: VariableI) =>
49 finalVariablesMap.set(v.name, v.value)
50 );
51 }
52
53 // Convert the map back to an array for debugging
54 let finalVariables: VariableI[] = Array.from(
55 finalVariablesMap,
56 ([name, value]) => ({
57 name,
58 value
59 })
60 );
61 dlog(`finalVariables`, finalVariables);
62
63 return finalVariablesMap;
64}
65
66// Function to replace variables in the messages
67function replaceVarsInMessagesWithVals({

Callers 1

processMessagesFunction · 0.85

Calls 1

dlogFunction · 0.90

Tested by

no test coverage detected