feat(agent): Process feels decent now, however it can be very slow. This is a checkpoint to come back to. Going to start trying to make it faster.
This commit is contained in:
parent
72c2ddc3a0
commit
60d36ab8f4
27 changed files with 396 additions and 211 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { BaseOutputParser } from '@langchain/core/output_parsers';
|
||||
import { removeThinkingBlocks } from '../utils/contentUtils';
|
||||
|
||||
interface LineListOutputParserArgs {
|
||||
key?: string;
|
||||
|
|
@ -23,7 +24,7 @@ class LineListOutputParser extends BaseOutputParser<string[]> {
|
|||
|
||||
// First, remove all <think>...</think> blocks to avoid parsing tags inside thinking content
|
||||
// This might be a little aggressive. Prompt massaging might be all we need, but this is a guarantee and should rarely mess anything up.
|
||||
text = this.removeThinkingBlocks(text);
|
||||
text = removeThinkingBlocks(text);
|
||||
|
||||
const regex = /^(\s*(-|\*|\d+\.\s|\d+\)\s|\u2022)\s*)+/;
|
||||
const startKeyIndex = text.indexOf(`<${this.key}>`);
|
||||
|
|
@ -46,17 +47,6 @@ class LineListOutputParser extends BaseOutputParser<string[]> {
|
|||
return lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all content within <think>...</think> blocks
|
||||
* @param text The input text containing thinking blocks
|
||||
* @returns The text with all thinking blocks removed
|
||||
*/
|
||||
private removeThinkingBlocks(text: string): string {
|
||||
// Use regex to identify and remove all <think>...</think> blocks
|
||||
// Using [\s\S] pattern to match all characters including newlines
|
||||
return text.replace(/<think>[\s\S]*?<\/think>/g, '').trim();
|
||||
}
|
||||
|
||||
getFormatInstructions(): string {
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue