MCPcopy Create free account
hub / github.com/Feather-2/Burner-X / constructPrompt

Method constructPrompt

js/processing/react_engine.js:174–214  ·  view source on GitHub ↗
(goal)

Source from the content-addressed store, hash-verified

172 }
173
174 constructPrompt(goal) {
175 const toolDescriptions = Array.from(this.tools.values())
176 .map(t => `${t.name}: ${t.description}`)
177 .join('\n');
178
179 let prompt = `Answer the following questions as best you can. You have access to the following tools:
180
181${toolDescriptions}
182
183Use the following format:
184
185Question: the input question you must answer
186Thought: you should always think about what to do
187Action: the action to take, should be one of [${Array.from(this.tools.keys()).join(', ')}]
188Action Input: the input to the action
189Observation: the result of the action
190... (this Thought/Action/Action Input/Observation can repeat N times)
191Thought: I now know the final answer
192Final Answer: the final answer to the original input question
193
194Begin!
195
196Question: ${goal}
197`;
198
199 for (const step of this.history) {
200 if (step.type === 'step') {
201 prompt += `Thought: ${step.thought}\n`;
202 prompt += `Action: ${step.action.tool}\n`;
203 prompt += `Action Input: ${step.action.args}\n`;
204 prompt += `Observation: ${step.observation}\n`;
205 } else if (step.type === 'thought') {
206 prompt += `Thought: ${step.content}\n`;
207 }
208 }
209
210 // Prompt for the next step
211 prompt += `Thought:`;
212
213 return prompt;
214 }
215
216 parseResponse(response) {
217 // Handle case where LLM includes "Thought:" prefix in the response

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected