Skip to content

Commit 9b99716

Browse files
committed
updated
1 parent 9a9ba73 commit 9b99716

File tree

6 files changed

+181
-0
lines changed

6 files changed

+181
-0
lines changed

docs/api/apiaccess/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cbapicategory:
2020
- name: CodeUtils
2121
link: /docs/api/apiaccess/codeutils
2222
description: This is a module that provides various utilities for parsing and manipulating code.
23+
2324
- name: Crawler
2425
link: /docs/api/apiaccess/crawler
2526
description: This is a module that crawls the web and returns the crawled data.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"label": "CodeBoltUtils",
3+
"position": 2,
4+
"collapsible": false,
5+
"collapsed": true,
6+
"className": "red",
7+
"link": {
8+
"type": "doc",
9+
"id": "api/codeboltutils/index"
10+
}
11+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: FollowUpQuestionBuilder
3+
cbbaseinfo:
4+
description: Creates the next prompt for the AI agent by incorporating previous conversation, tool results, and summarizing long interactions when needed.
5+
cbparameters:
6+
parameters: []
7+
returns:
8+
signatureTypeName: InferenceParams
9+
description: Returns a new inference prompt to continue the agent workflow.
10+
typeArgs: []
11+
data:
12+
name: FollowUpQuestionBuilder
13+
category: codeboltutils
14+
link: followupquestionbuilder.md
15+
---
16+
<CBBaseInfo/>
17+
<CBParameters/>
18+
19+
### Example
20+
21+
```javascript
22+
23+
const codebolt = require('@codebolt/codeboltjs').default;
24+
25+
const { FollowUpPromptBuilder } = require("@codebolt/codeboltjs/utils");
26+
27+
const followUpBuilder = new FollowUpQuestionBuilder(codebolt);
28+
const nextPrompt = await followUpBuilder
29+
.addPreviousConversation(previousPrompt)
30+
.addToolResult(toolResults)
31+
.checkAndSummarizeConversationIfLong()
32+
.buildInferenceParams();
33+
```
34+
35+
### Methods
36+
37+
The FollowUpQuestionBuilder class provides the following chainable methods:
38+
39+
- **`addPreviousConversation(previousPrompt)`**: Adds the previous conversation context to the new prompt
40+
- **`addToolResult(toolResults)`**: Incorporates tool execution results into the prompt
41+
- **`checkAndSummarizeConversationIfLong()`**: Automatically summarizes the conversation if it becomes too long
42+
- **`buildInferenceParams()`**: Builds and returns the final inference parameters for the next AI interaction
43+
44+
### Usage Notes
45+
46+
- All methods return the FollowUpQuestionBuilder instance, allowing for method chaining
47+
- The constructor requires a `codebolt` parameter
48+
- Use this class to maintain conversation context across multiple AI interactions
49+
- The summarization feature helps manage long conversations by condensing previous interactions
50+
- The final `buildInferenceParams()` method returns an `InferenceParams` object ready for the next LLM call

docs/api/codeboltutils/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
cbapicategory:
3+
- name: PromptBuilder
4+
link: /docs/api/apiaccess/codeboltutils/promptBuilder
5+
description: Constructs a smart prompt for the AI agent by combining tools, environment details, system instructions, and task-specific information.
6+
7+
- name: LLMOutputHandler
8+
link: /docs/api/apiaccess/codeboltutils/llmoutputhandler
9+
description: Processes the AI model’s response, manages tool executions, handles user communication, and detects when the task is completed.
10+
11+
- name: FollowUpQuestionBuilder
12+
link: /docs/api/apiaccess/codeboltutils/followupquestionbuilder
13+
description: Creates the next prompt for the AI agent by incorporating previous conversation, tool results, and summarizing long interactions when needed.
14+
15+
---
16+
# Codebolt Utils
17+
<CBAPICategory />
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: LLMOutputHandler
3+
cbbaseinfo:
4+
description: Processes the AI model's response, manages tool executions, handles user communication, and detects when the task is completed.
5+
cbparameters:
6+
parameters: []
7+
returns:
8+
signatureTypeName: void
9+
description: Executes AI logic and tool workflows, and optionally returns completion status.
10+
typeArgs: []
11+
data:
12+
name: LLMOutputHandler
13+
category: codeboltutils
14+
link: llmoutputhandler.md
15+
---
16+
<CBBaseInfo/>
17+
<CBParameters/>
18+
19+
### Example
20+
21+
```javascript
22+
const codebolt = require('@codebolt/codeboltjs').default;
23+
24+
const { LLMOutputHandler } = require("@codebolt/codeboltjs/utils");
25+
26+
const llmOutput = codebolt.llm.inference(prompt);
27+
const outputHandler = new LLMOutputHandler(llmOutput, codebolt);
28+
29+
await outputHandler.sendMessageToUser();
30+
const toolResults = await outputHandler.runTools();
31+
32+
if (outputHandler.isCompleted()) {
33+
console.log("Task completed!");
34+
}
35+
```
36+
37+
### Methods
38+
39+
The LLMOutputHandler class provides the following methods:
40+
41+
- **`sendMessageToUser()`**: Sends the AI model's response message to the user
42+
- **`runTools()`**: Executes any tools that were called by the AI model and returns the results
43+
- **`isCompleted()`**: Checks if the current task has been completed based on the AI's response
44+
45+
### Usage Notes
46+
47+
- The constructor requires `llmOutput` (the AI model's response) and `codebolt` parameters
48+
- Use `sendMessageToUser()` to communicate AI responses to the user
49+
- Call `runTools()` to execute any tool calls made by the AI
50+
- Check `isCompleted()` to determine if the workflow should continue or terminate
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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

Comments
 (0)