Hello
I have this code:
const OPENAI_API_KEY = 'xxxxxxx';
async function fetchCarBrandModel() {
try {
const response = await axios.post('https://api.openai.com/v1/chat/completions', {
model: 'gpt-3.5-turbo-0613',
messages: [
........
// Select the content of the assistant's reply
const assistantMessage = response.data.choices[0].message.content;
let gptFound = false;
let carbrand = "";
// If assistantMessage is not 'undefined', set it to workflow.GPTAnswer
if (assistantMessage !== 'undefined') {
carbrand = assistantMessage;
console.log(carbrand)
gptFound = true;
console.log(gptFound)
}
// Return the result
return { carbrand, gptFound };
} catch (error) {
console.error(error.response.data);
}
}
// Use the function
(async () => {
const result = await fetchCarBrandModel();
// Now you can update
workflow
here, where it is in scope
if (result) {
workflow.carBrandModel = result.carbrand;
workflow.GPTfoundAnswer = result.gptFound;
}
console.log(result.carbrand + " " + result.gptFound)
console.log(workflow.carBrandModel)
})();
What happends is that i cannot update my actual workflow variables. It somehow creates new variables and does not update the actual values.
Can somebode help me please?