From 0b1b0af741aac4e78555e655654c7f01cd4010eb Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Thu, 17 Jul 2025 11:30:50 -0400 Subject: [PATCH] =?UTF-8?q?=E2=98=91=EF=B8=8F=20refactor:=20Allow=20Mid-co?= =?UTF-8?q?nvo=20Agent=20Selection=20from=20Agent=20Panel=20(#8510)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/hooks/Agents/useSelectAgent.ts | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/client/src/hooks/Agents/useSelectAgent.ts b/client/src/hooks/Agents/useSelectAgent.ts index bda268062f..585554fc39 100644 --- a/client/src/hooks/Agents/useSelectAgent.ts +++ b/client/src/hooks/Agents/useSelectAgent.ts @@ -1,6 +1,11 @@ import { useCallback, useState } from 'react'; import { useQueryClient } from '@tanstack/react-query'; -import { EModelEndpoint, isAgentsEndpoint, Constants, QueryKeys } from 'librechat-data-provider'; +import { + Constants, + QueryKeys, + EModelEndpoint, + isAssistantsEndpoint, +} from 'librechat-data-provider'; import type { TConversation, TPreset, Agent } from 'librechat-data-provider'; import useDefaultConvo from '~/hooks/Conversations/useDefaultConvo'; import { useAgentsMapContext } from '~/Providers/AgentsMapContext'; @@ -24,22 +29,22 @@ export default function useSelectAgent() { const updateConversation = useCallback( (agent: Partial, template: Partial) => { logger.log('conversation', 'Updating conversation with agent', agent); - if (isAgentsEndpoint(conversation?.endpoint)) { - const currentConvo = getDefaultConversation({ - conversation: { ...(conversation ?? {}), agent_id: agent.id }, - preset: template, - }); - newConversation({ - template: currentConvo, - preset: template as Partial, - keepLatestMessage: true, - }); - } else { + if (isAssistantsEndpoint(conversation?.endpoint)) { newConversation({ template: { ...(template as Partial) }, preset: template as Partial, }); + return; } + const currentConvo = getDefaultConversation({ + conversation: { ...(conversation ?? {}), agent_id: agent.id }, + preset: template, + }); + newConversation({ + template: currentConvo, + preset: template as Partial, + keepLatestMessage: true, + }); }, [conversation, getDefaultConversation, newConversation], );