|
| 1 | +--- |
| 2 | +name: PromptBuilder |
| 3 | +cbbaseinfo: |
| 4 | + description: Constructs a smart prompt for the AI agent by combining tools, environment details, system instructions, and task-specific information. |
| 5 | +cbparameters: |
| 6 | + parameters: [] |
| 7 | + returns: |
| 8 | + signatureTypeName: InferenceParams |
| 9 | + description: Returns an inference parameter object suitable for running an LLM. |
| 10 | + typeArgs: [] |
| 11 | +data: |
| 12 | + name: PromptBuilder |
| 13 | + category: codeboltutils |
| 14 | + link: promptBuilder.md |
| 15 | +--- |
| 16 | +<CBBaseInfo/> |
| 17 | +<CBParameters/> |
| 18 | + |
| 19 | +### Example |
| 20 | + |
| 21 | +```javascript |
| 22 | + |
| 23 | +const codebolt = require('@codebolt/codeboltjs').default; |
| 24 | + |
| 25 | +const { InitialPromptBuilder } = require("@codebolt/codeboltjs/utils"); |
| 26 | + |
| 27 | +const promptBuilder = new InitialPromptBuilder(userMessage, codebolt); |
| 28 | +const prompt = await promptBuilder |
| 29 | + .addMCPTools() |
| 30 | + .addAgentTools() |
| 31 | + .addEnvironmentDetails() |
| 32 | + .addSystemPrompt('agent.yaml', 'test', 'example.md') |
| 33 | + .addTaskInstruction('task.yaml', 'main_task') |
| 34 | + .buildInferenceParams(); |
| 35 | +``` |
| 36 | + |
| 37 | +### Methods |
| 38 | + |
| 39 | +The PromptBuilder class provides the following chainable methods: |
| 40 | + |
| 41 | +- **`addMCPTools()`**: Adds MCP (Model Context Protocol) tools to the prompt |
| 42 | +- **`addAgentTools()`**: Includes agent-specific tools in the prompt |
| 43 | +- **`addEnvironmentDetails()`**: Adds environment context and details |
| 44 | +- **`addSystemPrompt(yamlFile, section, exampleFile)`**: Loads system instructions from YAML configuration |
| 45 | +- **`addTaskInstruction(yamlFile, taskName)`**: Adds specific task instructions |
| 46 | +- **`buildInferenceParams()`**: Builds and returns the final inference parameters |
| 47 | + |
| 48 | +### Usage Notes |
| 49 | + |
| 50 | +- All methods return the PromptBuilder instance, allowing for method chaining |
| 51 | +- The constructor requires `userMessage` and `codebolt` parameters |
| 52 | +- The final `buildInferenceParams()` method returns an `InferenceParams` object ready for LLM execution |
0 commit comments