The video and the bot template are great @fresh-fireman-491 ! I tried to implement the imageURL workflow first. Unfortunately, the code didn't quite work for me for whatever reason 😴 But now that I've changed it a bit, it works perfectly for me too. Here is the code I am using now: const openai = axios.create({
baseURL: "https://api.openai.com/v1",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer OPENAI_API_KEY",
},
});
async function createChatCompletion() {
try {
const response = await openai.post('/chat/completions', {
model: "gpt-4-vision-preview",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: workflow.prompt },
{
role: "assistant",
content: [
{
type: "image",
"image_url": workflow.imageUrl,
},
],
},
],
max_tokens: 500,
});
return response.data.choices;
} catch (error) {
console.error("Error during the chat completion: ", error.response ? error.response.data : error.message);
return null;
}
}
async function main() {
const choices = await createChatCompletion();
if (choices) {
workflow.response = choices[0].message.content;
console.log("Response:", workflow.response);
}
}
await main();