showcase/shell-docs/src/content/docs/integrations/langgraph/generative-ui/tool-rendering.mdx
<IframeSwitcher id="backend-tools-example" exampleUrl="https://feature-viewer.copilotkit.ai/langgraph/feature/backend_tool_rendering?sidebar=false&chatDefaultOpen=false" codeUrl="https://feature-viewer.copilotkit.ai/langgraph/feature/backend_tool_rendering?view=code&sidebar=false&codeLayout=tabs" exampleLabel="Demo" codeLabel="Code" height="700px" />
<Callout> This example demonstrates the [implementation](#implementation) section applied in the{" "} <a href="https://feature-viewer.copilotkit.ai/langgraph/feature/agentic_chat" target="_blank" > CopilotKit feature viewer </a> . </Callout>Tools are a way for the LLM to call predefined, typically, deterministic functions. CopilotKit allows you to render these tools in the UI as a custom component, which we call Generative UI.
Rendering tools in the UI is useful when you want to provide the user with feedback about what your agent is doing, specifically when your agent is calling tools. CopilotKit allows you to fully customize how these tools are rendered in the chat.
The agent in the live demo above exposes a mock get_weather tool. This is
the definition straight from the Python backend:
At this point, your agent will be able to call the get_weather tool. Now
we just need to add a useRenderTool hook to render the tool call in
the UI.
The example below uses a branded <WeatherCard /> component to render
the call — same pattern as the minimal example above, just wired to a
richer UI:
For every other tool the agent calls, a single useDefaultRenderTool
hook can provide a uniform fallback UI — this is exactly how the demo
above handles get_stock_price, roll_dice, and any tool the agent might
add later without a dedicated renderer:
Try asking the agent to get the weather for a location. You should see the custom UI component that we added render the tool call and display the arguments that were passed to the tool.
</Step> </Steps>