mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-13 05:58:51 +01:00
🏞️ fix: Gemini Image Filenames and Add Tool Cache Safety (#11306)
* 🔧 fix: Handle undefined tool definitions in agent and assistant creation (#11295) * Updated the tool fetching logic in createAgentHandler, createAssistant, and patchAssistant functions to use nullish coalescing, ensuring that an empty object is returned if no tools are available. This change improves robustness against undefined values in tool definitions across multiple controller files. * Adjusted the ToolService to maintain consistency in tool definition handling. * 🔧 fix: Update filename generation in createToolEndCallback function * Modified the filename generation logic to remove the tool_call_id from the filename, simplifying the naming convention for saved images. This change enhances clarity and consistency in the generated filenames.
This commit is contained in:
parent
2958fcd0c5
commit
cdffdd2926
5 changed files with 7 additions and 7 deletions
|
|
@ -408,7 +408,7 @@ function createToolEndCallback({ req, res, artifactPromises, streamId = null })
|
|||
const { url } = part.image_url;
|
||||
artifactPromises.push(
|
||||
(async () => {
|
||||
const filename = `${output.name}_${output.tool_call_id}_img_${nanoid()}`;
|
||||
const filename = `${output.name}_img_${nanoid()}`;
|
||||
const file_id = output.artifact.file_ids?.[i];
|
||||
const file = await saveBase64Image(url, {
|
||||
req,
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ const createAgentHandler = async (req, res) => {
|
|||
agentData.author = userId;
|
||||
agentData.tools = [];
|
||||
|
||||
const availableTools = await getCachedTools();
|
||||
const availableTools = (await getCachedTools()) ?? {};
|
||||
for (const tool of tools) {
|
||||
if (availableTools[tool]) {
|
||||
agentData.tools.push(tool);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const createAssistant = async (req, res) => {
|
|||
delete assistantData.conversation_starters;
|
||||
delete assistantData.append_current_datetime;
|
||||
|
||||
const toolDefinitions = await getCachedTools();
|
||||
const toolDefinitions = (await getCachedTools()) ?? {};
|
||||
|
||||
assistantData.tools = tools
|
||||
.map((tool) => {
|
||||
|
|
@ -136,7 +136,7 @@ const patchAssistant = async (req, res) => {
|
|||
...updateData
|
||||
} = req.body;
|
||||
|
||||
const toolDefinitions = await getCachedTools();
|
||||
const toolDefinitions = (await getCachedTools()) ?? {};
|
||||
|
||||
updateData.tools = (updateData.tools ?? [])
|
||||
.map((tool) => {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const createAssistant = async (req, res) => {
|
|||
delete assistantData.conversation_starters;
|
||||
delete assistantData.append_current_datetime;
|
||||
|
||||
const toolDefinitions = await getCachedTools();
|
||||
const toolDefinitions = (await getCachedTools()) ?? {};
|
||||
|
||||
assistantData.tools = tools
|
||||
.map((tool) => {
|
||||
|
|
@ -125,7 +125,7 @@ const updateAssistant = async ({ req, openai, assistant_id, updateData }) => {
|
|||
|
||||
let hasFileSearch = false;
|
||||
for (const tool of updateData.tools ?? []) {
|
||||
const toolDefinitions = await getCachedTools();
|
||||
const toolDefinitions = (await getCachedTools()) ?? {};
|
||||
let actualTool = typeof tool === 'string' ? toolDefinitions[tool] : tool;
|
||||
|
||||
if (!actualTool && manifestToolMap[tool] && manifestToolMap[tool].toolkit === true) {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ async function processRequiredActions(client, requiredActions) {
|
|||
requiredActions,
|
||||
);
|
||||
const appConfig = client.req.config;
|
||||
const toolDefinitions = await getCachedTools();
|
||||
const toolDefinitions = (await getCachedTools()) ?? {};
|
||||
const seenToolkits = new Set();
|
||||
const tools = requiredActions
|
||||
.map((action) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue