fix: corrected the regex in the ReactAgent (#1022)

Signed-off-by: ranjanmangla1 <ranjanmangla1@gmail.com>
This commit is contained in:
Ranjan Mangla
2024-07-09 21:25:38 +05:30
committed by GitHub
parent 3ae832ca28
commit a0f424e592
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
corrected the regex in the react.ts file in extractToolUse & extractJsonStr functions, as mentioned in https://github.com/run-llama/LlamaIndexTS/issues/1019
+2 -2
View File
@@ -66,7 +66,7 @@ function reasonFormatter(reason: Reason): string | Promise<string> {
}
function extractJsonStr(text: string): string {
const pattern = /\{.*}/s;
const pattern = /\{.*\}/s;
const match = text.match(pattern);
if (!match) {
@@ -98,7 +98,7 @@ function extractToolUse(
inputText: string,
): [thought: string, action: string, input: string] {
const pattern =
/\s*Thought: (.*?)\nAction: ([a-zA-Z0-9_]+).*?\.*Input: .*?(\{.*?})/s;
/\s*Thought: (.*?)\nAction: ([a-zA-Z0-9_]+).*?\.*Input: .*?(\{.*?\})/s;
const match = inputText.match(pattern);