Skip to content

Commit 9cfc993

Browse files
authored
fix: Improve error messages and enhance AskNebulaToolSchema description (#68)
- Updated AskNebulaToolSchema to provide a more detailed description for querying ERC20 token metrics, emphasizing the importance of including token decimals for accurate formatting.
1 parent cc72dd2 commit 9cfc993

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/tools/thirdWeb.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const AskNebulaToolSchema = {
3131
message: z
3232
.string()
3333
.min(20)
34-
.describe("The blockchain-related question to ask ThirdWeb"),
34+
.describe(
35+
"The blockchain-related question to ask ThirdWeb. When querying ERC20 token metrics (supply, balance, etc.), always request token decimals information to ensure accurate number formatting. Example: Instead of 'What is the total supply?' use 'What is the total supply? Include token decimals and calculate the human-readable amount.'"
36+
),
3537
}),
3638
execute: async (input: ThirdWebParams) => {
3739
try {
@@ -57,11 +59,15 @@ export class ThirdWebTool extends APITool<ThirdWebParams> {
5759
});
5860

5961
if (!process.env.THIRDWEB_SECRET_KEY) {
60-
throw new Error("Please set the THIRDWEB_SECRET_KEY environment variable.");
62+
throw new Error(
63+
"Please set the THIRDWEB_SECRET_KEY environment variable."
64+
);
6165
}
6266

6367
if (!process.env.THIRDWEB_SESSION_ID) {
64-
throw new Error("Please set the THIRDWEB_SESSION_ID environment variable.");
68+
throw new Error(
69+
"Please set the THIRDWEB_SESSION_ID environment variable."
70+
);
6571
}
6672
}
6773

@@ -88,21 +94,23 @@ export class ThirdWebTool extends APITool<ThirdWebParams> {
8894
"x-secret-key": secretKey,
8995
"Content-Type": "application/json",
9096
},
91-
timeout: timeout
97+
timeout: timeout,
9298
}
9399
);
94100
return response.data;
95101
} catch (error) {
96102
if (axios.isAxiosError(error)) {
97-
if (error.code === 'ECONNABORTED') {
98-
throw new Error(`Request timed out after ${timeout/1000} seconds`);
103+
if (error.code === "ECONNABORTED") {
104+
throw new Error(`Request timed out after ${timeout / 1000} seconds`);
99105
}
100106
if (error.response?.status === 401) {
101107
throw new Error("Authentication failed: Invalid ThirdWeb secret key");
102108
} else if (error.response?.status === 422) {
103109
throw new Error("Invalid request parameters");
104110
} else if (error.response?.status === 524) {
105-
throw new Error("Server timeout: The ThirdWeb API took too long to respond");
111+
throw new Error(
112+
"Server timeout: The ThirdWeb API took too long to respond"
113+
);
106114
}
107115
}
108116
throw error;

0 commit comments

Comments
 (0)