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
In the root directory of your project, copy the `.dev.vars.example` into `.dev.vars` file and configure the Auth0 and OpenAI variables.
44
44
45
+
```bash .dev.vars wrap lines
46
+
# ...
47
+
# You can use any provider of your choice supported by Vercel AI
48
+
OPENAI_API_KEY="OPENAI API KEY"
49
+
50
+
SESSION_STORE=cloudflare-kv
51
+
SESSION_STORE_NAMESPACE=Session
52
+
53
+
54
+
#auth0
55
+
AUTH0_DOMAIN="YOUR-ACCOUNT.us.auth0.com"
56
+
AUTH0_CLIENT_ID="YOUR CLIENT ID"
57
+
AUTH0_CLIENT_SECRET="YOUR CLIENT SECRET"
58
+
AUTH0_SESSION_ENCRYPTION_KEY="RANDOM 32 CHARS"
59
+
AUTH0_AUDIENCE="YOUR AUDIENCE"
60
+
61
+
BASE_URL="http://localhost:3000"
62
+
```
63
+
64
+
If you use another provider for your LLM, adjust the variable name in `.dev.vars` accordingly.
65
+
45
66
### Define a tool to call your API
46
67
47
68
In this step, you'll create a Vercel AI tool to make the first-party API call to the Auth0 API. You will do the same for third-party APIs.
@@ -53,41 +74,159 @@ Since the Agent defined in the class Chat in `src/agent/chat.ts` uses the **Auth
53
74
The tool we are defining here uses the same access token to call Auth0's [`/userinfo`](https://auth0.com/docs/api/authentication/user-profile/get-user-info) endpoint.
54
75
55
76
```tsx src/agent/tools.ts wrap lines
56
-
const getUserInfoTool =tool({
57
-
description: "Get information about the current logged in user.",
58
-
parameters: z.object({}),
59
-
execute: async () => {
60
-
const { agent } =getCurrentAgent<Chat>();
61
-
const tokenSet =agent?.getCredentials();
62
-
if (!tokenSet) {
63
-
return"There is no user logged in.";
77
+
/**
78
+
* Tool definitions for the AI chat agent
79
+
* Tools can either require human confirmation or execute automatically
0 commit comments