mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-19 18:43:34 -04:00
fix: corrected the regex in the ReactAgent (#1022)
Signed-off-by: ranjanmangla1 <ranjanmangla1@gmail.com>
This commit is contained in:
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user