mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-12 05:28:51 +01:00
* feat: add useAgentCapabilities hook to manage agent capabilities * refactor: move agents and endpoints configuration to AgentPanel context provider * refactor: implement useGetAgentsConfig hook for consolidated agents and endpoints management * refactor: enhance ToolsDropdown to utilize agent capabilities and streamline dropdown item rendering * chore: reorder return values in useAgentCapabilities for improved clarity * refactor: enhance agent capabilities handling in AttachFileMenu and update file handling logic to allow capabilities to be used for non-agents endpoints
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { AgentPanelProvider, useAgentPanelContext } from '~/Providers/AgentPanelContext';
|
|
import VersionPanel from './Version/VersionPanel';
|
|
import { useChatContext } from '~/Providers';
|
|
import ActionsPanel from './ActionsPanel';
|
|
import AgentPanel from './AgentPanel';
|
|
import MCPPanel from './MCPPanel';
|
|
import { Panel } from '~/common';
|
|
|
|
export default function AgentPanelSwitch() {
|
|
return (
|
|
<AgentPanelProvider>
|
|
<AgentPanelSwitchWithContext />
|
|
</AgentPanelProvider>
|
|
);
|
|
}
|
|
|
|
function AgentPanelSwitchWithContext() {
|
|
const { conversation } = useChatContext();
|
|
const { activePanel, setCurrentAgentId } = useAgentPanelContext();
|
|
|
|
useEffect(() => {
|
|
const agent_id = conversation?.agent_id ?? '';
|
|
if (agent_id) {
|
|
setCurrentAgentId(agent_id);
|
|
}
|
|
}, [setCurrentAgentId, conversation?.agent_id]);
|
|
|
|
if (!conversation?.endpoint) {
|
|
return null;
|
|
}
|
|
|
|
if (activePanel === Panel.actions) {
|
|
return <ActionsPanel />;
|
|
}
|
|
if (activePanel === Panel.version) {
|
|
return <VersionPanel />;
|
|
}
|
|
if (activePanel === Panel.mcp) {
|
|
return <MCPPanel />;
|
|
}
|
|
return <AgentPanel />;
|
|
}
|