diff --git a/.changeset/loud-bananas-shout.md b/.changeset/loud-bananas-shout.md new file mode 100644 index 0000000000000000000000000000000000000000..ab86c9f9cb0c3339763a9b71de63f40c446f9b6c --- /dev/null +++ b/.changeset/loud-bananas-shout.md @@ -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 diff --git a/packages/llamaindex/src/agent/react.ts b/packages/llamaindex/src/agent/react.ts index 091348f53ee53fe5706d7efb08b23ff950f56709..866a5faa9eb8619cb1ab4b06818afc176e811324 100644 --- a/packages/llamaindex/src/agent/react.ts +++ b/packages/llamaindex/src/agent/react.ts @@ -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);