Week 1 (05/15)

During this week, I was doing mainly research to help me find out how to attack the project. I was mainly using YouTube videos and documentation from OpenAI's API documentation page.

Resources:

  1. Video 1 - How to deploy frontend project to Microsoft Azure
  2. Video 2 - ChatGPT Chatbot Creation Using Python
  3. Video 3 - How To Use OpenAI API
  4. OpenAI Documentation

Week 2 (05/22)

During this week, I have started building the project and experimenting with different types of files that I could add this program to. I ran into a few problems when trying to iterate through the _posts directory and adding the ChatGPT materials, because most of the files in the _posts directory were auto-generated .md files that were converted from Jupyter Notebooks for deployment.

for root, dirs, files in os.walk(post_dir):
    for file in files:
        # For this to work, the auto-generated files have to be in a different folder than the 
        if file.endswith(".md"):
            md_file_path = os.path.join(root, file)

            # Step 5: Parse Markdown or Jupyter Notebook content
            with open(md_file_path, "r") as f:
                content = f.read()
            tags_start = content.find("tags:")
            tags_end = content.find("\n", tags_start)
            tags = content[tags_start + 5:tags_end].strip() if tags_start != -1 else ""

            # Step 6: Invoke ChatGPT API
            api_output = interact_with_api(tags)

            # Step 7: Update Markdown or Jupyter Notebook content
            # Modify the content as per your requirements
            # For example, append the output as a new section
            updated_content = f"{content}\n\n## ChatGPT API Output\n\n{api_output}"

            # Step 8: Save modified file
            with open(md_file_path, "w") as f:
                f.write(updated_content)

Week 3 (05/29)

This week, I finished the notebook directory function and finished off the project and started on the fully deployed CodeGPT website. I have not finished the project, but will have it done in the next two weeks or so.

def process_notebooks(notebook_dir):
    for root, dirs, files in os.walk(notebook_dir):
        for file in files:
            if file.endswith(".ipynb"):
                notebook_path = os.path.join(root, file)
                notebook = nbformat.read(notebook_path, as_version=nbformat.NO_CONVERT)

                # Step 5: Parse Markdown or Jupyter Notebook content
                tags = notebook["metadata"].get("tags", [])

                # Step 6: Invoke ChatGPT API
                api_output = interact_with_api(tags)

                # Step 7: Update Markdown or Jupyter Notebook content
                # Modify the notebook as per your requirements
                # For example, append the output as a markdown cell at the end
                new_cell = nbformat.v4.new_markdown_cell(source=api_output)
                notebook["cells"].append(new_cell)

                # Step 8: Save modified file
                nbformat.write(notebook, notebook_path)