mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
feat(experimental): FunctionsAgent, uses new function payload for tooling
This commit is contained in:
parent
550e566097
commit
3caddd6854
8 changed files with 227 additions and 52 deletions
|
|
@ -0,0 +1,33 @@
|
|||
const FunctionsAgent = require('./FunctionsAgent');
|
||||
const { AgentExecutor } = require('langchain/agents');
|
||||
const { BufferMemory, ChatMessageHistory } = require('langchain/memory');
|
||||
|
||||
const initializeFunctionsAgent = async ({
|
||||
tools,
|
||||
model,
|
||||
pastMessages,
|
||||
currentDateString,
|
||||
...rest
|
||||
}) => {
|
||||
const agent = FunctionsAgent.fromLLMAndTools(
|
||||
model,
|
||||
tools,
|
||||
{
|
||||
currentDateString,
|
||||
});
|
||||
|
||||
const memory = new BufferMemory({
|
||||
chatHistory: new ChatMessageHistory(pastMessages),
|
||||
// returnMessages: true, // commenting this out retains memory
|
||||
memoryKey: 'chat_history',
|
||||
humanPrefix: 'User',
|
||||
aiPrefix: 'Assistant',
|
||||
inputKey: 'input',
|
||||
outputKey: 'output'
|
||||
});
|
||||
|
||||
return AgentExecutor.fromAgentAndTools({ agent, tools, memory, ...rest });
|
||||
};
|
||||
|
||||
module.exports = initializeFunctionsAgent;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue