chore: system message tools: cleanup and restore edit test
This commit is contained in:
parent
9511eb5fa9
commit
400013333d
10 changed files with 66 additions and 33 deletions
|
|
@ -1,13 +1,15 @@
|
|||
import { ChatMessage, PromptLog, TextMessagePart } from "../..";
|
||||
import { normalizeToMessageParts } from "../../util/messageContent";
|
||||
import { detectToolCallStart } from "./detectToolCallStart";
|
||||
import { generateOpenAIToolCallId } from "./openAiToolCallId";
|
||||
import {
|
||||
getInitialTooLCallParseState,
|
||||
handleToolCallBuffer,
|
||||
ToolCallParseState,
|
||||
} from "./parseSystemToolCall";
|
||||
import { splitAtCodeblocksAndNewLines } from "./systemToolUtils";
|
||||
import {
|
||||
generateOpenAIToolCallId,
|
||||
splitAtCodeblocksAndNewLines,
|
||||
} from "./systemToolUtils";
|
||||
|
||||
/*
|
||||
Function to intercept tool calls in markdown code blocks format from a chat message stream
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
function randomLettersAndNumbers(length: number): string {
|
||||
const characters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
let result = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function generateOpenAIToolCallId(): string {
|
||||
return `call_${randomLettersAndNumbers(24)}`;
|
||||
}
|
||||
|
|
@ -2,16 +2,20 @@ export function closeTag(openingTag: string): string {
|
|||
return `</${openingTag.slice(1)}`;
|
||||
}
|
||||
|
||||
export function getStringDelta(original: string, updated: string): string {
|
||||
if (!updated.startsWith(original)) {
|
||||
console.warn(
|
||||
`Original string "${original}" is not a prefix of updated string "${updated}"`,
|
||||
);
|
||||
return updated;
|
||||
}
|
||||
return updated.slice(original.length);
|
||||
}
|
||||
|
||||
export function splitAtCodeblocksAndNewLines(content: string) {
|
||||
return content.split(/(```|\n)/g).filter(Boolean);
|
||||
}
|
||||
|
||||
function randomLettersAndNumbers(length: number): string {
|
||||
const characters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
let result = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function generateOpenAIToolCallId(): string {
|
||||
return `call_${randomLettersAndNumbers(24)}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ describe("Edit Test", () => {
|
|||
return codeLens;
|
||||
}
|
||||
|
||||
it("Accepts an Edit in the GUI", async () => {
|
||||
it.only("Accepts an Edit in the GUI", async () => {
|
||||
({ view } = await GUIActions.switchToReactIframe());
|
||||
|
||||
await EditActions.acceptEditInGUI(view);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
By,
|
||||
EditorView,
|
||||
Key,
|
||||
VSBrowser,
|
||||
WebDriver,
|
||||
WebElement,
|
||||
WebView,
|
||||
|
|
@ -15,14 +16,14 @@ import { DEFAULT_TIMEOUT } from "../constants";
|
|||
import { GUISelectors } from "../selectors/GUI.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
|
||||
describe.only("GUI Test", () => {
|
||||
describe("GUI Test", () => {
|
||||
let view: WebView;
|
||||
let driver: WebDriver;
|
||||
|
||||
before(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
// Uncomment this line for faster testing
|
||||
// await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
||||
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
||||
await GlobalActions.openTestWorkspace();
|
||||
await GlobalActions.clearAllNotifications();
|
||||
});
|
||||
|
|
|
|||
7
extensions/vscode/package-lock.json
generated
7
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.63",
|
||||
"version": "1.1.66",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.63",
|
||||
"version": "1.1.66",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
@ -129,6 +129,7 @@
|
|||
"handlebars": "^4.7.8",
|
||||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ignore": "^5.3.1",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
|
|
@ -142,7 +143,7 @@
|
|||
"node-html-markdown": "^1.3.0",
|
||||
"ollama": "^0.4.6",
|
||||
"onnxruntime-node": "1.14.0",
|
||||
"openai": "^4.76.0",
|
||||
"openai": "^4.104.0",
|
||||
"p-limit": "^6.1.0",
|
||||
"partial-json": "^0.1.7",
|
||||
"pg": "^8.11.3",
|
||||
|
|
|
|||
3
gui/package-lock.json
generated
3
gui/package-lock.json
generated
|
|
@ -140,6 +140,7 @@
|
|||
"handlebars": "^4.7.8",
|
||||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ignore": "^5.3.1",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
|
|
@ -153,7 +154,7 @@
|
|||
"node-html-markdown": "^1.3.0",
|
||||
"ollama": "^0.4.6",
|
||||
"onnxruntime-node": "1.14.0",
|
||||
"openai": "^4.76.0",
|
||||
"openai": "^4.104.0",
|
||||
"p-limit": "^6.1.0",
|
||||
"partial-json": "^0.1.7",
|
||||
"pg": "^8.11.3",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
CANCELLED_TOOL_CALL_MESSAGE,
|
||||
NO_TOOL_CALL_OUTPUT_MESSAGE,
|
||||
} from "core/tools/constants";
|
||||
import { convertToolCallStatesToSystemCallsAndOutput } from "core/tools/systemMessageTools/textifySystemTools";
|
||||
import { convertToolCallStatesToSystemCallsAndOutput } from "core/tools/systemMessageTools/convertSystemTools";
|
||||
import { findLast, findLastIndex } from "core/util/findLast";
|
||||
import {
|
||||
normalizeToMessageParts,
|
||||
|
|
|
|||
|
|
@ -1,21 +1,50 @@
|
|||
/**
|
||||
* Calculator class for performing basic arithmetic operations
|
||||
* Uses method chaining to allow consecutive operations
|
||||
*/
|
||||
class Calculator {
|
||||
/**
|
||||
* Initialize calculator with result set to 0
|
||||
*/
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a number to the current result
|
||||
* @param {number} number - The number to add
|
||||
* @returns {Calculator} - Returns this instance for method chaining
|
||||
*/
|
||||
add(number) {
|
||||
this.result += number;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract a number from the current result
|
||||
* @param {number} number - The number to subtract
|
||||
* @returns {Calculator} - Returns this instance for method chaining
|
||||
*/
|
||||
subtract(number) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply the current result by a number
|
||||
* @param {number} number - The number to multiply by
|
||||
* @returns {Calculator} - Returns this instance for method chaining
|
||||
*/
|
||||
multiply(number) {
|
||||
this.result *= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide the current result by a number
|
||||
* @param {number} number - The number to divide by
|
||||
* @returns {Calculator} - Returns this instance for method chaining
|
||||
* @throws {Error} - Throws error if attempting to divide by zero
|
||||
*/
|
||||
divide(number) {
|
||||
if (number === 0) {
|
||||
throw new Error("Cannot divide by zero");
|
||||
|
|
@ -24,10 +53,18 @@ class Calculator {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current result value
|
||||
* @returns {number} - The current result
|
||||
*/
|
||||
getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the result to 0
|
||||
* @returns {Calculator} - Returns this instance for method chaining
|
||||
*/
|
||||
reset() {
|
||||
this.result = 0;
|
||||
return this;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue