Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

738 B
Raw Blame
import { ToolCallResult } from 'librechat-data-provider';
import { useMemo } from 'react';
import { useGetToolCalls } from '~/data-provider';
import { mapToolCalls, logger } from '~/utils';

type ToolCallsMap = {
  [x: string]: ToolCallResult[] | undefined;
};

export default function useToolCallsMap({
  conversationId,
}: {
  conversationId: string;
}): ToolCallsMap | undefined {
  const { data: toolCallsMap = null } = useGetToolCalls(
    { conversationId },
    {
      select: (res) => mapToolCalls(res),
    },
  );

  const result = useMemo<ToolCallsMap | undefined>(() => {
    return toolCallsMap !== null ? toolCallsMap : undefined;
  }, [toolCallsMap]);

  logger.log('tools', 'tool calls map:', result);
  return result;
}