Custom Tool Setup #5316
Replies: 1 comment
|
@theangrykangaroo
then one of these is more likely happening:
A few things to verify: 1. Make sure your tool returns a stringAccording to the Flowise documentation, a Custom Tool must return a string value from the JavaScript function. If your API returns JSON, serialize it before returning it. :contentReference[oaicite:0]{index=0} For example: const response = await fetch(url);
const data = await response.json();
return JSON.stringify(data);or, even better, format it into a human-readable string if the agent only needs a few fields. 2. Define a clear Input SchemaThe Input Schema tells the LLM exactly what arguments it should generate when calling the tool. If it's vague or incomplete, the model may invoke your tool with incorrect parameters. :contentReference[oaicite:1]{index=1} For example: {
"type": "object",
"properties": {
"memberNumber": {
"type": "string",
"description": "Member ID, e.g. 0001"
}
},
"required": ["memberNumber"]
}Then use it in your function as: const memberNumber = $memberNumber;3. Check the actual API responseSince const response = await fetch(url);
console.log(response.status);
const text = await response.text();
console.log(text);
return text;This will tell you whether:
4. Give the tool a descriptive promptThe tool description is how the LLM decides when to call it. For example:
Good descriptions significantly improve tool selection. :contentReference[oaicite:2]{index=2} 5. Handle API errors explicitlyInstead of letting the function fail silently: if (!response.ok) {
return `API returned ${response.status}: ${await response.text()}`;
}That way you'll see the real backend error instead of the generic "service unavailable" response. Could you share the following?
Those three pieces should be enough to determine whether the issue is with the schema, the tool implementation, or the API response itself. If this solves your problem, feel free to mark it as the accepted answer so others can find it easily. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I'm running Flowise on a container as well as an api on another container that just exposes a simple API that I wrote to access a simple schema for medical appointments on a postgres DB. The containers can talk and I can run curl commands from my flowise container to my-appointment-api.
API.json
The problem I'm having is when the tool gets called the agent tells me
"I am currently unable to retrieve the member details for member number "0001". There might be an issue with the service. Please try again later or contact support for assistance."
From what I can tell, it doesn't know the structure of the output. I've tried a lot of different variations of the javascript code in my tool, but to no avail. I've attached the current version of what i have in there now:
toolJavaScript.js
I guess I just don't know how to provision this tool. I'd appreciate any insight. Thanks in advance for any help you can provide!
All reactions