You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This video shows the result of `npx copilotkit@latest init` with the [implementation](#implementation) section applied to it!
18
-
</Callout>
19
19
20
20
## What is this?
21
+
Frontend tools enable you to define client-side functions that your ADK agent can invoke, with execution happening entirely in the user's browser. When your agent calls a frontend tool,
22
+
the logic runs on the client side, giving you direct access to the frontend environment.
21
23
22
-
Frontend actions are powerful tools that allow your AI agents to directly interact with and update your application's user interface. Think of them as bridges that connect your agent's decision-making capabilities with your frontend's interactive elements.
23
-
24
-
## When should I use this?
25
-
26
-
Frontend actions are essential when you want to create truly interactive AI applications where your agent needs to:
24
+
This can be utilized for to let [your agent control the UI](/adk/frontend-actions), [generative UI](/adk/generative-ui/frontend-tools), or for Human-in-the-loop interactions.
27
25
28
-
- Dynamically update UI elements
29
-
- Trigger frontend animations or transitions
30
-
- Show alerts or notifications
31
-
- Modify application state
32
-
- Handle user interactions programmatically
26
+
In this guide, we cover the use of frontend tools driving and interacting with the UI.
33
27
34
-
Without frontend actions, agents are limited to just processing and returning data. By implementing frontend actions, you can create rich, interactive experiences where your agent actively drives the user interface.
28
+
## When should I use this?
29
+
Use frontend tools when you need your agent to interact with client-side primitives such as:
30
+
- Reading or modifying React component state
31
+
- Accessing browser APIs like localStorage, sessionStorage, or cookies
32
+
- Triggering UI updates or animations
33
+
- Interacting with third-party frontend libraries
34
+
- Performing actions that require the user's immediate browser context
35
35
36
36
## Implementation
37
37
38
38
<Steps>
39
39
<Step>
40
-
### Setup CopilotKit
41
-
42
-
To use frontend actions, you'll need to setup CopilotKit first. For the sake of brevity, we won't cover it here.
43
-
44
-
Check out our [getting started guide](/adk/quickstart/adk) and come back here when you're setup!
40
+
### Run and connect your agent
41
+
<RunAndConnectcomponents={props.components} />
45
42
</Step>
46
43
47
44
<Step>
48
-
### Create a frontend action
45
+
### Create a frontend tool
49
46
50
-
First, you'll need to create a frontend action using the [useCopilotAction](/reference/hooks/useCopilotAction) hook. Here's a simple one to get you started
47
+
First, you'll need to create a frontend tool using the [useFrontendTool](/reference/hooks/useFrontendTool) hook. Here's a simple one to get you started
That's it! Your agent will automatically have access to all frontend actions you've defined using `useCopilotAction` in your React components.
76
+
77
+
That's it! Your agent will automatically have access to all frontend tools you've defined using `useFrontendTool` in your React components.
78
+
79
+
<Callouttype="info">
80
+
Frontend tools registered with `useFrontendTool` are automatically forwarded to your agent through the AG-UI protocol. The agent can invoke them, and execution happens on the frontend.
81
+
</Callout>
124
82
</Step>
125
83
<Step>
126
84
### Give it a try!
127
-
You've now given your agent the ability to directly call any CopilotActions you've defined. These actions will be available as tools to the agent where they can be used as needed.
85
+
You've now given your agent the ability to directly call any frontend tools you've defined. These tools will be available to the agent where they can be used as needed.
0 commit comments