mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-27 21:58:51 +01:00
feat(ChatAgent.js): add support for skipping completion mode in ChatAgent
feat(ChatAgent.js): add a check for images when completion is skipped to add to response feat(askGPTPlugins.js): add skipCompletion option to agentOptions feat(client): add Switch component to ui components and use for new Agent Settings chore(package.json): ignore client directory in nodemonConfig
This commit is contained in:
parent
5b1efc48d1
commit
d0be2e6f4a
13 changed files with 150 additions and 32 deletions
|
|
@ -6,7 +6,7 @@ const {
|
|||
} = require('@dqbd/tiktoken');
|
||||
const { fetchEventSource } = require('@waylaidwanderer/fetch-event-source');
|
||||
const { Agent, ProxyAgent } = require('undici');
|
||||
// const TextStream = require('../stream');
|
||||
const TextStream = require('../stream');
|
||||
const { ChatOpenAI } = require('langchain/chat_models/openai');
|
||||
const { CallbackManager } = require('langchain/callbacks');
|
||||
const { HumanChatMessage, AIChatMessage } = require('langchain/schema');
|
||||
|
|
@ -687,13 +687,14 @@ Only respond with your conversational reply to the following User Message:
|
|||
return { ...responseMessage, ...this.result };
|
||||
}
|
||||
|
||||
// if (!this.agentIsGpt3 && this.result.output) {
|
||||
// responseMessage.text = this.result.output;
|
||||
// await this.saveMessageToDatabase(responseMessage, user);
|
||||
// const textStream = new TextStream(this.result.output);
|
||||
// await textStream.processTextStream(opts.onProgress);
|
||||
// return { ...responseMessage, ...this.result };
|
||||
// }
|
||||
if (!completionMode && this.agentOptions.skipCompletion && this.result.output) {
|
||||
responseMessage.text = this.result.output;
|
||||
this.addImages(this.result.intermediateSteps, responseMessage);
|
||||
await this.saveMessageToDatabase(responseMessage, user);
|
||||
const textStream = new TextStream(this.result.output);
|
||||
await textStream.processTextStream(opts.onProgress);
|
||||
return { ...responseMessage, ...this.result };
|
||||
}
|
||||
|
||||
if (this.options.debug) {
|
||||
console.debug('this.result', this.result);
|
||||
|
|
@ -714,6 +715,26 @@ Only respond with your conversational reply to the following User Message:
|
|||
return { ...responseMessage, ...this.result };
|
||||
}
|
||||
|
||||
addImages(intermediateSteps, responseMessage) {
|
||||
if (!intermediateSteps || !responseMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
intermediateSteps.forEach(step => {
|
||||
const { observation } = step;
|
||||
if (!observation || !observation.includes('![')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!responseMessage.text.includes(observation)) {
|
||||
responseMessage.text += '\n' + observation;
|
||||
if (this.options.debug) {
|
||||
console.debug('added image from intermediateSteps');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async buildPrompt({ messages, promptPrefix: _promptPrefix, completionMode = false, isChatGptModel = true }) {
|
||||
if (this.options.debug) {
|
||||
console.debug('buildPrompt messages', messages);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ router.post('/', requireJwtAuth, async (req, res) => {
|
|||
|
||||
const agentOptions = req.body?.agentOptions ?? {
|
||||
agent: 'classic',
|
||||
skipCompletion: false,
|
||||
model: 'gpt-3.5-turbo',
|
||||
temperature: 0,
|
||||
// top_p: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue