feat(Functions Agent): use official langchain function executor/agent for better output handling (#538)

* style(FunctionsAgent.js): remove unnecessary comments and update PREFIX variable
refactor(initializeFunctionsAgent.js): update to use initializeAgentExecutorWithOptions
deps(package.json): update langchain to v0.0.95
refactor(askGPTPlugins.js): pass endpointOption to onStart function

* fix(ChatAgent.js): handle undefined delta content in progressMessage.choices array
This commit is contained in:
Danny Avila 2023-06-19 14:15:56 -04:00 committed by GitHub
parent 49e2cdf76c
commit f84da37c9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 28 deletions

View file

@ -7,8 +7,7 @@ const {
SystemMessagePromptTemplate,
HumanMessagePromptTemplate
} = require('langchain/prompts');
const PREFIX = `You are a helpful AI assistant. Objective: Resolve the user's query with provided functions.
The user is demanding a function response to the query.`;
const PREFIX = `You are a helpful AI assistant.`;
function parseOutput(message) {
if (message.additional_kwargs.function_call) {
@ -52,9 +51,9 @@ class FunctionsAgent extends Agent {
return ChatPromptTemplate.fromPromptMessages([
SystemMessagePromptTemplate.fromTemplate(`Date: ${currentDateString}\n${prefix}`),
HumanMessagePromptTemplate.fromTemplate(`{chat_history}
Query: {input}`),
new MessagesPlaceholder('agent_scratchpad')
new MessagesPlaceholder('chat_history'),
HumanMessagePromptTemplate.fromTemplate(`Query: {input}`),
new MessagesPlaceholder('agent_scratchpad'),
]);
}