diff --git a/.changeset/sweet-llamas-dress.md b/.changeset/sweet-llamas-dress.md new file mode 100644 index 0000000000000000000000000000000000000000..024d67eddc5d97648fc4baa6750bcd3a8f8b2b16 --- /dev/null +++ b/.changeset/sweet-llamas-dress.md @@ -0,0 +1,5 @@ +--- +"llamaindex": patch +--- + +fix: Update react agent to support tool calls from Cohere command-r models diff --git a/packages/llamaindex/src/agent/react.ts b/packages/llamaindex/src/agent/react.ts index abfa1d24c602980ccdd1ff48c789f09bb21e2d93..cfd6e6880af7833fab7bc701903647708c61c1eb 100644 --- a/packages/llamaindex/src/agent/react.ts +++ b/packages/llamaindex/src/agent/react.ts @@ -100,7 +100,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);