mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-27 04:44:10 +01:00
22 lines
739 B
TypeScript
22 lines
739 B
TypeScript
|
|
import { createContext, useContext } from 'react';
|
||
|
|
import useToolCallsMap from '~/hooks/Plugins/useToolCallsMap';
|
||
|
|
type ToolCallsMapContextType = ReturnType<typeof useToolCallsMap>;
|
||
|
|
|
||
|
|
export const ToolCallsMapContext = createContext<ToolCallsMapContextType>(
|
||
|
|
{} as ToolCallsMapContextType,
|
||
|
|
);
|
||
|
|
export const useToolCallsMapContext = () => useContext(ToolCallsMapContext);
|
||
|
|
|
||
|
|
interface ToolCallsMapProviderProps {
|
||
|
|
children: React.ReactNode;
|
||
|
|
conversationId: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function ToolCallsMapProvider({ children, conversationId }: ToolCallsMapProviderProps) {
|
||
|
|
const toolCallsMap = useToolCallsMap({ conversationId });
|
||
|
|
|
||
|
|
return (
|
||
|
|
<ToolCallsMapContext.Provider value={toolCallsMap}>{children}</ToolCallsMapContext.Provider>
|
||
|
|
);
|
||
|
|
}
|