You need to return a string
here it seems you return a JSON object?
Would it better to use the option for csv/text? or convert it to a string with json:
const data = await response.json();
const dataString = JSON.stringify(data); // Convert JSON data to a string
return dataString
that returned the error of {
"status": 500,
"body": {
"message": "400 1 validation error for Request\nbody -> tool_outputs -> 0 -> output\n field required (type=value_error.missing)",
"code": "INTERNAL_SERVER_ERROR"
}
}
@Baptiste I have fixed this in that PR.
But you didn't include this and other fixes.
Ok, like I said I will publish it first thing in the morning
Sorry, my English is not great, and I don't think I was clear.
I meant that many bug fixes that were included in that pull request were not accepted by you.
Oh, thank you. I apologize for my poor English getting in the way. 🙂
Hmmm so I'm not getting an error anymore but the response isn't from using the function, chatgpt responds by telling me it will use the function getAddress to check for addresses rather than running the function - I've tested the process of calling the API using the webhook block which works in getting the data but would like to use the function calling to understand it for the future
and strange responses such as -
Sorry, I am not able to access external APIs in this environment. However, I can continue the conversation without knowing the specific address. Is there anything else I can assist you with?
The error persists if you do
return JSON.stringify(dataString)
I believe it is calling the function and Typebot is executing it.
However, when passing the value, it throws an error because Typebot is expecting a string.
ChatGPT receives the error when the function returns and responds as you're seeing.
P.S.: The OpenAI function calling is a "days-old" feature. We're still fine-tuning it.
Hmmm I've added that to my script but no luck unfortunately
try {
const response = await fetch(baseUrl, requestOptions);
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log(data); // Log the response data
return JSON.stringify(data);
} catch (error) { // Moved catch block to the correct position
console.error("Error fetching data:", error);
throw error; // Re-throw the error for handling outside the function
}
Unfortunetly, as it requires an API key, I won't be able to reproduce here.
I prefer to discuss it here. But sure, you can DM if you must.
Just for the API Key, don't want to post it publically
Tried it with the header Accept as application/json and text/csv
1) You missed the quotes in the url.
2) I'm getting 401 (Unauthorized). Guess your problem is your API key.
Ohhhh... just fixed. 😆
You missed an white space after "Basic ".
const requestOptions = {
method: "GET",
headers: {
Accept: "application/json",
Authorization: "Basic " + encodedAPI,
},
}
Booom thank you so much 🙂 Simple over looked quote 🙂
Recomend to code and run your code outside the bot, then just copy / paste.
Yeah that approach makes more sense, will use it in the future 🙂