https://discord.gg/botpress logo
Generate Content error: "data/messages must be arr...
# 🤝help
g
I'm trying to analyze some text data stored in face_analysis_result using the "Generate Content" action, but I keep getting the following error: Error: array type is only allowed Here’s the full error message when I run the action: Execute Integration Action OpenAI | Generate Content Errors: 1 Input model: undefined reasoningEffort: undefined systemPrompt: "あなたは顧客に寄り添うプロのヘアスタイリストです。" messages: "{face_analysis_result}" responseFormat: undefined maxTokens: 1200 temperature: 0.69 topP: 1 stopSequences: [] 0 items tools: undefined toolChoice: undefined userId: undefined debug: undefined meta: undefined Error data/messages must be array In the messages field, I'm passing this: [ { "role": "user", "content": "{{face_analysis_result}}" } ] Is there something wrong with my configuration? Could it be that the face_analysis_result variable is not being passed as an array or properly formatted? Any advice would be appreciated. Thanks! https://cdn.discordapp.com/attachments/1422967096744345682/1422967097209917471/image.png?ex=68de98e1&is=68dd4761&hm=46f2540567574ec509ddbcb801e960a6982bd313467e367f88cfd30ac469a5cd&
w
that could be the result of a bug happening with the generate content card -> https://discord.com/channels/1108396290624213082/1422543031801745508/1422597108736856184
l
Hey @glamorous-planet-66489 🙂 As I had mentioned in our previous help thread, the Generate Content card is not working as intended, the issues have been reported to the team and they will investigate.
g
@wide-umbrella-5226 @loud-crowd-60573 Thankyou!!!
I’m wondering if there’s a way to process text data stored in a variable without using the Generate Content card. For example, I have a variable face_analysis_result that contains some text output, and I’d like to manipulate or reformat it. Are there alternative approaches, such as using a Code card, text utilities, regex extraction, or JSON parsing (depending on the data format)? What’s the recommended way to handle this?
w
all of those are valid options, but it really depends on what type of data and how you want to manipulate it
can you give a little bit more info?
g
try { console.log('Vision Agent結果取得開始'); // Vision Agentの分析結果を取得 const visionContent = turn.VisionAgent?.content || ''; console.log('Vision Agent結果:', visionContent); // 結果を保存 if (visionContent && visionContent.length > 0) { workflow.face_analysis_result = visionContent; workflow.vision_success = true; } else { workflow.face_analysis_result = '画像から顔の特徴を検出できませんでした。一般的な診断を行います。'; workflow.vision_success = false; } console.log('保存された分析結果:', workflow.face_analysis_result); } catch (error) { console.error('Vision結果取得エラー:', error); workflow.face_analysis_result = '顔分析でエラーが発生しました。性格診断のみで提案を行います。'; workflow.vision_success = false; } https://cdn.discordapp.com/attachments/1422967096744345682/1423106392658677830/image.png?ex=68df1a9c&is=68ddc91c&hm=f65549808b7895ae42e387d7c6bbfc333960ee06126c9c159ad89a29aa8bc3b1&
@wide-umbrella-5226 What I’d like to achieve is: Import an image and convert it into text data Send the text data stored in a variable to OpenAI for analysis Output the analysis result in the chat The current issue is that when I try to send the variable data to OpenAI, it fails with the error I mentioned earlier, and the process cannot be executed.
w
well since that block isn't working right now, you can try this execute code card
Copy code
javascript
const url = 'https://api.openai.com/v1/chat/completions';

const headers = {
  'Authorization': 'Bearer YOUR_OPENAI_API_KEY', 
  'Content-Type': 'application/json',
};


const systemPrompt = `your system prompt here`;

const userPrompt = `your prompt here`;

const data = {
  "model": "your model here",
  "messages": [
    {
      "role": "system",
      "content": systemPrompt
    },
    {
      "role": "user", 
      "content": userPrompt
    }
  ],
  "max_tokens": 8000, 
  "temperature": 1

};


const retryRequest = async (requestFn, maxRetries = 3) => {
  for (let i = 0; i <= maxRetries; i++) {
    const response = await requestFn();
    if (response.status !== 429 || i === maxRetries) {
      return response;
    }
    const delay = Math.pow(2, i) * 1000; 
    await new Promise(resolve => setTimeout(resolve, delay));
  }
};


const response = await retryRequest(() => axios.post(url, data, { headers }));

// Extract the response
const generatedMessage = response.data.choices[0].message.content;
yourvariablehere = generatedMessage;
please make sure to change the placeholder values (api key, system prompt, prompt, final variable) and feel free to change the model, temperature and max tokens
@glamorous-planet-66489
g
@wide-umbrella-5226 Thank you!! I will try!!!!!!
🙇‍♂️
@wide-umbrella-5226
3 Views