Share feedback, ideas and get community help

Home
Members
José Eduardo
J
José Eduardo
Offline, last seen 2 months ago
Joined December 19, 2024
Greetings,
@Baptiste , is it possible to read the files generated by OpenAI Assistant and display them?

For example, if I ask to generate a chart with data x, y, z, OpenAI creates a PNG file and includes it in the response.
3 comments
m
B
!
Greetings,

I have created an HTTP block that returns a JWT token and saves it to the token variable.
I also wrote an OpenAI assistant block that consumes a service from my API, which requires passing this token.

Here is the code I wrote in the Function handler of the OpenAI block:

try {
// I have read about the parsed/evaluated options, but neither seems to work...
// Tried const, let, var
const jwt = token;
const jwt = {{token}};

const apiUrl = "https://api.acme.com.br/v1/database/query";
const response = await fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": Bearer ${jwt}
},
body: JSON.stringify({ sql_query: sql_query })
});
const data = await response.json(); // Fixed JSON parsing here
return data;
} catch (error) {
throw error;
}

However, when I test it, I get the following error in the logs:

docker logs
2024-12-19 08:06:16 typebot-viewer | ReferenceError: token is not defined
2024-12-19 08:06:16 typebot-viewer | at eval (eval at <anonymous> (<isolated-vm>:3:10), <anonymous>:4:17)
2024-12-19 08:06:16 typebot-viewer | at <isolated-vm>:3:31
2024-12-19 08:06:16 typebot-viewer | at <isolated-vm>:4:3
2024-12-19 08:06:16 typebot-viewer | Error while executing script

Could anyone help me understand why the token variable is not recognized? Is there something wrong with how I am referencing it in the code?

Thanks in advance!
8 comments
m
J