mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-28 21:26:13 +01:00
mcp example, mock i/o for client-to-server communications
This commit is contained in:
parent
799f0e5810
commit
7251308244
9 changed files with 343 additions and 22 deletions
|
|
@ -40,3 +40,44 @@ export const useToolCallMutation = <T extends t.ToolId>(
|
|||
},
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for creating a new tool
|
||||
*/
|
||||
interface CreateToolData {
|
||||
name: string;
|
||||
description: string;
|
||||
type: 'function' | 'code_interpreter' | 'file_search';
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutation hook for adding a new tool to the system
|
||||
* Note: Requires corresponding backend implementation of dataService.createTool
|
||||
*/
|
||||
export const useAddToolMutation = (
|
||||
// options?:
|
||||
// {
|
||||
// onMutate?: (variables: CreateToolData) => void | Promise<unknown>;
|
||||
// onError?: (error: Error, variables: CreateToolData, context: unknown) => void;
|
||||
// onSuccess?: (data: t.Tool, variables: CreateToolData, context: unknown) => void;
|
||||
// }
|
||||
options?: t.MutationOptions<Record<string, unknown>, CreateToolData>,
|
||||
): UseMutationResult<Record<string, unknown>, Error, CreateToolData> => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
(toolData: CreateToolData) => {
|
||||
return dataService.createTool(toolData);
|
||||
},
|
||||
{
|
||||
onMutate: (variables) => options?.onMutate?.(variables),
|
||||
onError: (error, variables, context) => options?.onError?.(error, variables, context),
|
||||
onSuccess: (data, variables, context) => {
|
||||
// Invalidate tools list to trigger refetch
|
||||
queryClient.invalidateQueries([QueryKeys.tools]);
|
||||
return options?.onSuccess?.(data, variables, context);
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue