Dall e not able to create resume image for mock data, content_policy_violation,

I am creating a resume evaluator I want the ai to give suggestion how a resume can be enhanced. And then in the second prompt I want a mock image of resume based on that data

const pdfData = await pdfToText(pdfBuffer);
const resumeText = pdfData.text;
const chatCompletion = await openai.chat.completions.create({
messages: [
{
role: ‘system’,
content: ‘You are a resume evaluator. You are given a resume. You give response in json only. Do not write anything extra in begining or end’
},
{
role: ‘user’,
content: You are provided with a text extracted from a pdf resume. You have to return response with these keys. Name, email, contact, address(string), skills(array). Also you can give suggestion(array) to improve user resume. Here is the text ${resumeText}
}
],
model: ‘gpt-4o’,
response_format: { type: “json_object” },
});

        const data = JSON.parse(chatCompletion.choices[0].message.content);

//Till above it works fine problem starts from the below api
const resumeAiImage = await openai.images.generate({
model: “dall-e-3”,
prompt: Generate a mock image of a resume based on this mock data ${data},
n: 1,
size: “1024x1024”,
});

        return res.status(200).json({data, resumeAiImage});

I get error => “code”: “content_policy_violation”,
“message”: “Your request was rejected as a result of our safety system. Your prompt may contain text that is not allowed by our safety system.”,

The data that is returned by first api call is like this

{
“data”: {
“Name”: “Zainul Khan”,
“email”: “kzainul22@gmail.com”,
“contact”: null,
“address”: “Bhopal, Madhya Pradesh, India”,
“skills”: [
“React.js”,
“Node.js”,
“MongoDB”
],
“suggestion”: [
“Add a contact number to your resume.”,
“Provide specific details about your roles and responsibilities for each job experience.”,
“Include any certifications, awards, or notable achievements to make your resume stand out.”,
“Consider formatting your resume more clearly, breaking sections with appropriate headings.”,
“Include a section for your personal projects or contributions to open-source projects if applicable.”
]
}
}

Likely PII? Personally identifiable information in the resumes…

1 Like

Do you have a solution how can I achieve what I am trying to do. Like if it is generate mock data then also it will work

DALL-E cannot write text well. It is made for creative imagery. The image model also doesn’t accept much actual text length; the prompt you send is rewritten by AI. To show you what you’d get with the best prompting:

You instead might incorporate a function for the AI to use in your code that can typographically render a page sent by the tool you provide to the AI. You can brainstorm with the AI how to do this with some Python libraries for document creation.

As I just did with ChatGPT to see what it can do with its own Python code interpreter:

The Python environment has the following key libraries available:

  • WeasyPrint: Can be used to convert HTML/CSS to PDF and directly to an image.
  • Markdown2: Useful for converting Markdown to HTML.
  • PIL (Pillow): Allows for direct image manipulation, including drawing text.
  • pdf2image: Converts PDF documents into images.

Given these tools, the most efficient and high-quality method to produce an image of a resume would be:

  1. Format the resume in HTML/CSS: This allows for precise control over the styling and layout.
  2. Convert HTML/CSS to PDF using WeasyPrint: This ensures the document is rendered accurately and in a print-ready format.
  3. Convert the PDF to an image using pdf2image: This step will render the PDF into a high-resolution image.

This approach combines the strength of web technologies for layout with robust PDF to image conversion, ensuring a high-quality result. If you’d like, I can proceed with this method to create the image of the resume for you.

1 Like

@_j Thanks for your valuable insights only but the thing is I am using node js instead of python. I guess there maybe libraries for the same use case in node too, also can you still help me if its in node ?