Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

feat(FunctionsAgent): improve LLM instructions for more reliable results

Daniel Avila7053d76f48d3
diff --git a/api/app/langchain/ChatAgent.js b/api/app/langchain/ChatAgent.js
index d784106256..2ddfb8ec5b 100644
--- a/api/app/langchain/ChatAgent.js
+++ b/api/app/langchain/ChatAgent.js
@@ -837,8 +837,13 @@ Only respond with your conversational reply to the following User Message:
return [instructionsPayload, messagePayload];
}
+ const result = [messagePayload, instructionsPayload];
+
+ if (this.functionsAgent && !this.isGpt3 && !completionMode) {
+ result[1].content = `${result[1].content}\nSure thing! Here is the output you requested:\n`;
+ }
+
if (isChatGptModel) {
- const result = [messagePayload, instructionsPayload];
return result.filter((message) => message.content.length > 0);
}
diff --git a/api/app/langchain/agents/Functions/FunctionsAgent.js b/api/app/langchain/agents/Functions/FunctionsAgent.js
index e05407a21f..2be7bef609 100644
--- a/api/app/langchain/agents/Functions/FunctionsAgent.js
+++ b/api/app/langchain/agents/Functions/FunctionsAgent.js
@@ -7,8 +7,8 @@ const {
SystemMessagePromptTemplate,
HumanMessagePromptTemplate
} = require('langchain/prompts');
-const PREFIX = `You are a helpful AI assistant. Objective: Understand the human's query with available functions.
-The user is expecting a function response to the query; if only part of the query involves a function, prioritize the function response.`;
+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; if any part of the query requires a function, respond with the function call first since you won't get to later`;
function parseOutput(message) {
if (message.additional_kwargs.function_call) {
diff --git a/api/app/langchain/tools/structured/StableDiffusion.js b/api/app/langchain/tools/structured/StableDiffusion.js
index 1fc7eeff53..e5a8549bd9 100644
--- a/api/app/langchain/tools/structured/StableDiffusion.js
+++ b/api/app/langchain/tools/structured/StableDiffusion.js
@@ -20,8 +20,8 @@ Guidelines:
"negative_prompt":"semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, out of frame, low quality, ugly, mutation, deformed"
- Generate images only once per human query unless explicitly requested by the user`;
this.schema = z.object({
- prompt: z.string().describe("Detailed keywords to describe the subject, use at minimum but not limited to 5, separated by comma"),
- negative_prompt: z.string().describe("Keywords we want to exclude from the final image, use at minimum but not limited to 5, separated by comma")
+ prompt: z.string().describe("Detailed keywords to describe the subject, using at least 7 keywords to accurately describe the image, separated by comma"),
+ negative_prompt: z.string().describe("Keywords we want to exclude from the final image, using at least 7 keywords to accurately describe the image, separated by comma")
});
}