Skip to content

Using the ContentGenerator Class

Aidan Loughney edited this page Jun 11, 2023 · 2 revisions

Using the ContentGenerator Class

  1. Import the ContentGenerator class from the models.content_generator module.
  2. Create an instance of the ContentGenerator class with the necessary parameters, such as api_key, yml_files, csv_files, and template_mds.
  3. Use the create_completion() method to generate content based on a specific prompt.
  4. Use the create_output() method to generate content for a specific topic using the prompts, templates, and configurations provided.
  5. Use the write_output() method to save the generated content to a file.

When running the ContentGenerator Class you will need to use an OpenAI API key, refer to the readme for how to do this

Example

from models.content_generator import ContentGenerator

yml_files = ["data/prompts/prompts.yml"]
csv_files = ["data/csv/file_info.csv"]
template_mds = ["data/templates/template.md"]
output_dir = "output_test"

generator = ContentGenerator(api_key="your_api_key", yml_files=yml_files, csv_files=csv_files, template_mds=template_mds, output_dir=output_dir)

page = generator.file_info[1]
output = generator.create_output(page)
generator.write_output(page, output)

Clone this wiki locally