mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-09 03:58:51 +01:00
🔧 refactor: Optimize Agent Tool Loading and Fix Bedrock Tool Handling (#4641)
* fix: bedrock tool name regex * fix: pass args as single input, attempt json first. * refactor: remove toolMap from agent tool load as is not used * fix: update formatAgentMessages test to use strictEqual for args comparison, testing new behavior
This commit is contained in:
parent
3428c3c647
commit
0c2a583df8
9 changed files with 11 additions and 18 deletions
|
|
@ -120,7 +120,7 @@ describe('formatAgentMessages', () => {
|
|||
];
|
||||
const result = formatAgentMessages(payload);
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].tool_calls[0].args).toBe('non-json-string');
|
||||
expect(result[0].tool_calls[0].args).toStrictEqual({ input: 'non-json-string' });
|
||||
});
|
||||
|
||||
it('should handle complex tool calls with multiple steps', () => {
|
||||
|
|
|
|||
|
|
@ -189,10 +189,13 @@ const formatAgentMessages = (payload) => {
|
|||
// TODO: investigate; args as dictionary may need to be provider-or-tool-specific
|
||||
let args = _args;
|
||||
try {
|
||||
args = JSON.parse(args);
|
||||
args = JSON.parse(_args);
|
||||
} catch (e) {
|
||||
// failed to parse, leave as is
|
||||
if (typeof _args === 'string') {
|
||||
args = { input: _args };
|
||||
}
|
||||
}
|
||||
|
||||
tool_call.args = args;
|
||||
lastAIMessage.tool_calls.push(tool_call);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue