generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
356f2b8
commit 7fbcd19
Showing
2 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
_notebooks/2023-06-05-ProgressThroughFinalProject.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Learning Through The Final Project\n", | ||
"> This notebook will document my progress, learning, and problems I ran into while completing my final project for Data Structures 2.\n", | ||
"\n", | ||
"- title: AI Teaching Progress\n", | ||
"- toc: true\n", | ||
"- comments: false\n", | ||
"- categories: [Week-37]" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Week 1 (05/15)\n", | ||
"\n", | ||
"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.\n", | ||
"\n", | ||
"Resources:\n", | ||
"1. [Video 1 - How to deploy frontend project to Microsoft Azure](https://youtu.be/LX_DXLlaymg)\n", | ||
"2. [Video 2 - ChatGPT Chatbot Creation Using Python ](https://youtu.be/pGOyw_M1mNE)\n", | ||
"2. [Video 3 - How To Use OpenAI API](https://youtu.be/Vurdg6yrPL8)\n", | ||
"2. [OpenAI Documentation](https://platform.openai.com/docs/api-reference)" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Week 2 (05/22)\n", | ||
"\n", | ||
"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." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for root, dirs, files in os.walk(post_dir):\n", | ||
" for file in files:\n", | ||
" # For this to work, the auto-generated files have to be in a different folder than the \n", | ||
" if file.endswith(\".md\"):\n", | ||
" md_file_path = os.path.join(root, file)\n", | ||
"\n", | ||
" # Step 5: Parse Markdown or Jupyter Notebook content\n", | ||
" with open(md_file_path, \"r\") as f:\n", | ||
" content = f.read()\n", | ||
" tags_start = content.find(\"tags:\")\n", | ||
" tags_end = content.find(\"\\n\", tags_start)\n", | ||
" tags = content[tags_start + 5:tags_end].strip() if tags_start != -1 else \"\"\n", | ||
"\n", | ||
" # Step 6: Invoke ChatGPT API\n", | ||
" api_output = interact_with_api(tags)\n", | ||
"\n", | ||
" # Step 7: Update Markdown or Jupyter Notebook content\n", | ||
" # Modify the content as per your requirements\n", | ||
" # For example, append the output as a new section\n", | ||
" updated_content = f\"{content}\\n\\n## ChatGPT API Output\\n\\n{api_output}\"\n", | ||
"\n", | ||
" # Step 8: Save modified file\n", | ||
" with open(md_file_path, \"w\") as f:\n", | ||
" f.write(updated_content)" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Week 3 (05/29)\n", | ||
"\n", | ||
"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." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def process_notebooks(notebook_dir):\n", | ||
" for root, dirs, files in os.walk(notebook_dir):\n", | ||
" for file in files:\n", | ||
" if file.endswith(\".ipynb\"):\n", | ||
" notebook_path = os.path.join(root, file)\n", | ||
" notebook = nbformat.read(notebook_path, as_version=nbformat.NO_CONVERT)\n", | ||
"\n", | ||
" # Step 5: Parse Markdown or Jupyter Notebook content\n", | ||
" tags = notebook[\"metadata\"].get(\"tags\", [])\n", | ||
"\n", | ||
" # Step 6: Invoke ChatGPT API\n", | ||
" api_output = interact_with_api(tags)\n", | ||
"\n", | ||
" # Step 7: Update Markdown or Jupyter Notebook content\n", | ||
" # Modify the notebook as per your requirements\n", | ||
" # For example, append the output as a markdown cell at the end\n", | ||
" new_cell = nbformat.v4.new_markdown_cell(source=api_output)\n", | ||
" notebook[\"cells\"].append(new_cell)\n", | ||
"\n", | ||
" # Step 8: Save modified file\n", | ||
" nbformat.write(notebook, notebook_path)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python", | ||
"version": "3.9.7" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |