core util test cleanup
This commit is contained in:
parent
af5d38e653
commit
c98cf5fc56
4 changed files with 17 additions and 4 deletions
2
core/package-lock.json
generated
2
core/package-lock.json
generated
|
|
@ -27,7 +27,7 @@
|
|||
"comment-json": "^4.2.3",
|
||||
"dbinfoz": "^0.14.0",
|
||||
"diff": "^7.0.0",
|
||||
"dotenv": "^16.4.7",
|
||||
"dotenv": "^16.4.5",
|
||||
"fastest-levenshtein": "^1.0.16",
|
||||
"follow-redirects": "^1.15.5",
|
||||
"google-auth-library": "^9.14.2",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { ILLM, LLMFullCompletionOptions } from "..";
|
||||
|
||||
import { removeQuotesAndEscapes } from ".";
|
||||
import { removeQuotesAndEscapes, removeCodeBlocksAndTrim } from ".";
|
||||
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "../protocol";
|
||||
import type { IMessenger } from "./messenger";
|
||||
import { removeCodeBlocksAndTrim } from "./markdown";
|
||||
|
||||
export class ChatDescriber {
|
||||
static prompt: string | undefined =
|
||||
|
|
|
|||
|
|
@ -328,3 +328,17 @@ export function dedent(strings: TemplateStringsArray, ...values: any[]) {
|
|||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes code blocks from a message.
|
||||
*
|
||||
* Return modified message text.
|
||||
*/
|
||||
export function removeCodeBlocksAndTrim(text: string): string {
|
||||
const codeBlockRegex = /```[\s\S]*?```/g;
|
||||
|
||||
// Remove code blocks from the message text
|
||||
const textWithoutCodeBlocks = text.replace(codeBlockRegex, "");
|
||||
|
||||
return textWithoutCodeBlocks.trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { exec, ChildProcess } from "child_process";
|
||||
import os from "node:os";
|
||||
|
||||
import { removeCodeBlocksAndTrim } from "./markdown";
|
||||
import { removeCodeBlocksAndTrim } from ".";
|
||||
|
||||
import type { IMessenger } from "./messenger";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "../protocol";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue