diff --git a/AI Maniacs Project Submission/AI_AID.HTML b/AI Maniacs Project Submission/AI_AID.HTML new file mode 100644 index 0000000..f8b1e31 --- /dev/null +++ b/AI Maniacs Project Submission/AI_AID.HTML @@ -0,0 +1,47 @@ + + + + + + AI Aid + + + +

AI Aid

+ + + diff --git a/AI Maniacs Project Submission/AI_Aid.ipynb b/AI Maniacs Project Submission/AI_Aid.ipynb new file mode 100644 index 0000000..4ac1642 --- /dev/null +++ b/AI Maniacs Project Submission/AI_Aid.ipynb @@ -0,0 +1,301 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "paFgtKg-BqsR", + "outputId": "fa0e51d7-a08d-48cd-efcc-111a28c7ec61" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting groq\n", + " Downloading groq-0.11.0-py3-none-any.whl.metadata (13 kB)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from groq) (3.7.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from groq) (1.7.0)\n", + "Collecting httpx<1,>=0.23.0 (from groq)\n", + " Downloading httpx-0.27.2-py3-none-any.whl.metadata (7.1 kB)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from groq) (2.9.2)\n", + "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from groq) (1.3.1)\n", + "Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from groq) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->groq) (3.10)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->groq) (1.2.2)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->groq) (2024.8.30)\n", + "Collecting httpcore==1.* (from httpx<1,>=0.23.0->groq)\n", + " Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)\n", + "Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx<1,>=0.23.0->groq)\n", + " Downloading h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->groq) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->groq) (2.23.4)\n", + "Downloading groq-0.11.0-py3-none-any.whl (106 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m106.5/106.5 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading httpx-0.27.2-py3-none-any.whl (76 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.4/76.4 kB\u001b[0m \u001b[31m3.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading httpcore-1.0.5-py3-none-any.whl (77 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading h11-0.14.0-py3-none-any.whl (58 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m2.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: h11, httpcore, httpx, groq\n", + "Successfully installed groq-0.11.0 h11-0.14.0 httpcore-1.0.5 httpx-0.27.2\n", + "Collecting gradio\n", + " Downloading gradio-4.44.0-py3-none-any.whl.metadata (15 kB)\n", + "Collecting aiofiles<24.0,>=22.0 (from gradio)\n", + " Downloading aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)\n", + "Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n", + "Collecting fastapi<1.0 (from gradio)\n", + " Downloading fastapi-0.115.0-py3-none-any.whl.metadata (27 kB)\n", + "Collecting ffmpy (from gradio)\n", + " Downloading ffmpy-0.4.0-py3-none-any.whl.metadata (2.9 kB)\n", + "Collecting gradio-client==1.3.0 (from gradio)\n", + " Downloading gradio_client-1.3.0-py3-none-any.whl.metadata (7.1 kB)\n", + "Requirement already satisfied: httpx>=0.24.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.27.2)\n", + "Requirement already satisfied: huggingface-hub>=0.19.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.24.7)\n", + "Requirement already satisfied: importlib-resources<7.0,>=1.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.4.5)\n", + "Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.4)\n", + "Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.5)\n", + "Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n", + "Requirement already satisfied: numpy<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.26.4)\n", + "Collecting orjson~=3.0 (from gradio)\n", + " Downloading orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (50 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.4/50.4 kB\u001b[0m \u001b[31m138.2 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (24.1)\n", + "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.4)\n", + "Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (10.4.0)\n", + "Requirement already satisfied: pydantic>=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.9.2)\n", + "Collecting pydub (from gradio)\n", + " Downloading pydub-0.25.1-py2.py3-none-any.whl.metadata (1.4 kB)\n", + "Collecting python-multipart>=0.0.9 (from gradio)\n", + " Downloading python_multipart-0.0.11-py3-none-any.whl.metadata (1.9 kB)\n", + "Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.2)\n", + "Collecting ruff>=0.2.2 (from gradio)\n", + " Downloading ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)\n", + "Collecting semantic-version~=2.0 (from gradio)\n", + " Downloading semantic_version-2.10.0-py2.py3-none-any.whl.metadata (9.7 kB)\n", + "Collecting tomlkit==0.12.0 (from gradio)\n", + " Downloading tomlkit-0.12.0-py3-none-any.whl.metadata (2.7 kB)\n", + "Requirement already satisfied: typer<1.0,>=0.12 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.12.5)\n", + "Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.12.2)\n", + "Requirement already satisfied: urllib3~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.2.3)\n", + "Collecting uvicorn>=0.14.0 (from gradio)\n", + " Downloading uvicorn-0.31.0-py3-none-any.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.3.0->gradio) (2024.6.1)\n", + "Collecting websockets<13.0,>=10.0 (from gradio-client==1.3.0->gradio)\n", + " Downloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (3.10)\n", + "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.3.1)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.2.2)\n", + "Collecting starlette<0.39.0,>=0.37.2 (from fastapi<1.0->gradio)\n", + " Downloading starlette-0.38.6-py3-none-any.whl.metadata (6.0 kB)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (1.0.5)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (3.16.1)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (2.32.3)\n", + "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (4.66.5)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.3.0)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (4.53.1)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.4.7)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (3.1.4)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n", + "Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (2.23.4)\n", + "Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n", + "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\n", + "Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (13.8.1)\n", + "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n", + "Downloading gradio-4.44.0-py3-none-any.whl (18.1 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.1/18.1 MB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading gradio_client-1.3.0-py3-none-any.whl (318 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m318.7/318.7 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading tomlkit-0.12.0-py3-none-any.whl (37 kB)\n", + "Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)\n", + "Downloading fastapi-0.115.0-py3-none-any.whl (94 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.6/94.6 kB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.9/141.9 kB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading python_multipart-0.0.11-py3-none-any.whl (22 kB)\n", + "Downloading ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.9/10.9 MB\u001b[0m \u001b[31m1.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n", + "Downloading uvicorn-0.31.0-py3-none-any.whl (63 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m63.7/63.7 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading ffmpy-0.4.0-py3-none-any.whl (5.8 kB)\n", + "Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n", + "Downloading starlette-0.38.6-py3-none-any.whl (71 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.5/71.5 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (130 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m1.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: pydub, websockets, uvicorn, tomlkit, semantic-version, ruff, python-multipart, orjson, ffmpy, aiofiles, starlette, gradio-client, fastapi, gradio\n", + "Successfully installed aiofiles-23.2.1 fastapi-0.115.0 ffmpy-0.4.0 gradio-4.44.0 gradio-client-1.3.0 orjson-3.10.7 pydub-0.25.1 python-multipart-0.0.11 ruff-0.6.8 semantic-version-2.10.0 starlette-0.38.6 tomlkit-0.12.0 uvicorn-0.31.0 websockets-12.0\n" + ] + } + ], + "source": [ + "!pip install groq\n", + "!pip install gradio\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "y0h30k5pCY3X" + }, + "outputs": [], + "source": [ + "question=\"Write code to print factorial using functions and loops in python\"\n", + "apiKey = \"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\"" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 645 + }, + "id": "n2WNObL-B77U", + "outputId": "7eca3ea0-952d-4740-c49a-e7efbab057fd" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Setting queue=True in a Colab notebook requires sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n", + "\n", + "Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n", + "Running on public URL: https://8af799ebd5264850d8.gradio.live\n", + "\n", + "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [] + }, + "metadata": {}, + "execution_count": 5 + } + ], + "source": [ + "import gradio as gr\n", + "from groq import Groq\n", + "\n", + "\n", + "def getResponse(code):\n", + " client = Groq(api_key=\"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\")\n", + "\n", + " chat_completion = client.chat.completions.create(\n", + " messages=[\n", + " {\n", + " \"role\": \"system\",\n", + " \"content\": (\n", + " \"You are a computer science professor and You know knowledge about various programming languages. I will give you detailed information about writing a code or for making something using coding languages. The type of the output should be a string with proper alignment for ease of readability for user.\"\n", + " )\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": (\n", + " \"Code: \" + code\n", + " )\n", + " }\n", + " ],\n", + " model=\"llama3-8b-8192\",\n", + " temperature=0.5,\n", + " max_tokens=1024,\n", + " top_p=1,\n", + " stop=None,\n", + " stream=False,\n", + " )\n", + "\n", + " return chat_completion.choices[0].message.content\n", + "\n", + "\n", + "def generate_response(input_code):\n", + " return getResponse(input_code)\n", + "\n", + "iface = gr.Interface(\n", + " fn=generate_response,\n", + " inputs=\"text\",\n", + " outputs=\"text\",\n", + " title=\"AI Code Helper\",\n", + " description=\"Input your code to get AI-generated suggestions and feedback.\"\n", + ")\n", + "\n", + "iface.launch()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 139 + }, + "id": "IGpIvu_gFLTt", + "outputId": "50cdc4cf-1c21-4a4e-f7fd-9667e0c56e9e" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "'Here is a Python code that calculates the factorial of a given number using a function and a loop:\\n\\n```Python\\ndef factorial(n):\\n if n == 0:\\n return 1\\n else:\\n result = 1\\n for i in range(1, n + 1):\\n result *= i\\n return result\\n\\nnum = int(input(\"Enter a positive integer: \"))\\nprint(\"Factorial of\", num, \"is\", factorial(num))\\n```\\n\\nTo run this code, you can save it in a file with a `.py` extension (for example, `factorial.py`) and then run it using Python (for example, `python factorial.py`). When you run the code, it will ask you to enter a positive integer. After you enter the number, it will print the factorial of that number.\\n\\nHere\\'s how the output will look like:\\n\\n```\\nEnter a positive integer: 5\\nFactorial of 5 is 120\\n```\\n\\nIn this code, we define a function `factorial` that takes an integer `n` as input and returns its factorial. The function uses a loop to calculate the factorial. If `n` is 0, the function returns 1, because the factorial of 0 is 1.\\n\\nThe main part of the code asks the user to enter a positive integer, calculates its factorial using the `factorial` function, and then prints the result.'" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + } + }, + "metadata": {}, + "execution_count": 4 + } + ], + "source": [ + "getResponse(question)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/AI Maniacs Project Submission/Blue_and_Pink_Minimalist_Video_Game_Developer_Studio_Logo__1_-removebg-preview.png b/AI Maniacs Project Submission/Blue_and_Pink_Minimalist_Video_Game_Developer_Studio_Logo__1_-removebg-preview.png new file mode 100644 index 0000000..94b677d Binary files /dev/null and b/AI Maniacs Project Submission/Blue_and_Pink_Minimalist_Video_Game_Developer_Studio_Logo__1_-removebg-preview.png differ diff --git a/AI Maniacs Project Submission/C.jpg b/AI Maniacs Project Submission/C.jpg new file mode 100644 index 0000000..046dd72 Binary files /dev/null and b/AI Maniacs Project Submission/C.jpg differ diff --git a/AI Maniacs Project Submission/Generate_Notes.ipynb b/AI Maniacs Project Submission/Generate_Notes.ipynb new file mode 100644 index 0000000..1c0e803 --- /dev/null +++ b/AI Maniacs Project Submission/Generate_Notes.ipynb @@ -0,0 +1,642 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "fjHiZA0MkhcE", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "81906e09-e904-4d73-9cef-683c33dd402b" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting groq\n", + " Downloading groq-0.11.0-py3-none-any.whl.metadata (13 kB)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from groq) (3.7.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from groq) (1.7.0)\n", + "Collecting httpx<1,>=0.23.0 (from groq)\n", + " Downloading httpx-0.27.2-py3-none-any.whl.metadata (7.1 kB)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from groq) (2.9.2)\n", + "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from groq) (1.3.1)\n", + "Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from groq) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->groq) (3.10)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->groq) (1.2.2)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->groq) (2024.8.30)\n", + "Collecting httpcore==1.* (from httpx<1,>=0.23.0->groq)\n", + " Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)\n", + "Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx<1,>=0.23.0->groq)\n", + " Downloading h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->groq) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->groq) (2.23.4)\n", + "Downloading groq-0.11.0-py3-none-any.whl (106 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m106.5/106.5 kB\u001b[0m \u001b[31m5.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading httpx-0.27.2-py3-none-any.whl (76 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.4/76.4 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading httpcore-1.0.5-py3-none-any.whl (77 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading h11-0.14.0-py3-none-any.whl (58 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: h11, httpcore, httpx, groq\n", + "Successfully installed groq-0.11.0 h11-0.14.0 httpcore-1.0.5 httpx-0.27.2\n", + "Collecting gradio\n", + " Downloading gradio-4.44.0-py3-none-any.whl.metadata (15 kB)\n", + "Collecting aiofiles<24.0,>=22.0 (from gradio)\n", + " Downloading aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)\n", + "Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n", + "Collecting fastapi<1.0 (from gradio)\n", + " Downloading fastapi-0.115.0-py3-none-any.whl.metadata (27 kB)\n", + "Collecting ffmpy (from gradio)\n", + " Downloading ffmpy-0.4.0-py3-none-any.whl.metadata (2.9 kB)\n", + "Collecting gradio-client==1.3.0 (from gradio)\n", + " Downloading gradio_client-1.3.0-py3-none-any.whl.metadata (7.1 kB)\n", + "Requirement already satisfied: httpx>=0.24.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.27.2)\n", + "Requirement already satisfied: huggingface-hub>=0.19.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.24.7)\n", + "Requirement already satisfied: importlib-resources<7.0,>=1.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.4.5)\n", + "Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.4)\n", + "Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.5)\n", + "Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n", + "Requirement already satisfied: numpy<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.26.4)\n", + "Collecting orjson~=3.0 (from gradio)\n", + " Downloading orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (50 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.4/50.4 kB\u001b[0m \u001b[31m875.6 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (24.1)\n", + "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.4)\n", + "Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (10.4.0)\n", + "Requirement already satisfied: pydantic>=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.9.2)\n", + "Collecting pydub (from gradio)\n", + " Downloading pydub-0.25.1-py2.py3-none-any.whl.metadata (1.4 kB)\n", + "Collecting python-multipart>=0.0.9 (from gradio)\n", + " Downloading python_multipart-0.0.11-py3-none-any.whl.metadata (1.9 kB)\n", + "Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.2)\n", + "Collecting ruff>=0.2.2 (from gradio)\n", + " Downloading ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)\n", + "Collecting semantic-version~=2.0 (from gradio)\n", + " Downloading semantic_version-2.10.0-py2.py3-none-any.whl.metadata (9.7 kB)\n", + "Collecting tomlkit==0.12.0 (from gradio)\n", + " Downloading tomlkit-0.12.0-py3-none-any.whl.metadata (2.7 kB)\n", + "Requirement already satisfied: typer<1.0,>=0.12 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.12.5)\n", + "Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.12.2)\n", + "Requirement already satisfied: urllib3~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.2.3)\n", + "Collecting uvicorn>=0.14.0 (from gradio)\n", + " Downloading uvicorn-0.31.0-py3-none-any.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.3.0->gradio) (2024.6.1)\n", + "Collecting websockets<13.0,>=10.0 (from gradio-client==1.3.0->gradio)\n", + " Downloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (3.10)\n", + "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.3.1)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.2.2)\n", + "Collecting starlette<0.39.0,>=0.37.2 (from fastapi<1.0->gradio)\n", + " Downloading starlette-0.38.6-py3-none-any.whl.metadata (6.0 kB)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (1.0.5)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (3.16.1)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (2.32.3)\n", + "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (4.66.5)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.3.0)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (4.53.1)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.4.7)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (3.1.4)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n", + "Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (2.23.4)\n", + "Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n", + "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\n", + "Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (13.8.1)\n", + "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n", + "Downloading gradio-4.44.0-py3-none-any.whl (18.1 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.1/18.1 MB\u001b[0m \u001b[31m45.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading gradio_client-1.3.0-py3-none-any.whl (318 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m318.7/318.7 kB\u001b[0m \u001b[31m18.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading tomlkit-0.12.0-py3-none-any.whl (37 kB)\n", + "Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)\n", + "Downloading fastapi-0.115.0-py3-none-any.whl (94 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.6/94.6 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.9/141.9 kB\u001b[0m \u001b[31m8.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading python_multipart-0.0.11-py3-none-any.whl (22 kB)\n", + "Downloading ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.9/10.9 MB\u001b[0m \u001b[31m62.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n", + "Downloading uvicorn-0.31.0-py3-none-any.whl (63 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m63.7/63.7 kB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading ffmpy-0.4.0-py3-none-any.whl (5.8 kB)\n", + "Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n", + "Downloading starlette-0.38.6-py3-none-any.whl (71 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.5/71.5 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (130 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m7.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: pydub, websockets, uvicorn, tomlkit, semantic-version, ruff, python-multipart, orjson, ffmpy, aiofiles, starlette, gradio-client, fastapi, gradio\n", + "Successfully installed aiofiles-23.2.1 fastapi-0.115.0 ffmpy-0.4.0 gradio-4.44.0 gradio-client-1.3.0 orjson-3.10.7 pydub-0.25.1 python-multipart-0.0.11 ruff-0.6.8 semantic-version-2.10.0 starlette-0.38.6 tomlkit-0.12.0 uvicorn-0.31.0 websockets-12.0\n" + ] + } + ], + "source": [ + "!pip install groq\n", + "!pip install gradio\n" + ] + }, + { + "cell_type": "code", + "source": [ + "import gradio as gr\n", + "from groq import Groq\n", + "\n", + "def getResponse(Topic, SubTopic):\n", + " client = Groq(api_key=\"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\")\n", + "\n", + " chat_completion = client.chat.completions.create(\n", + " messages=[\n", + " {\n", + " \"role\": \"system\",\n", + " \"content\": (\n", + " \"You are a computer science professor and I will give you the topic name, sub-topic \"\n", + " \"You need to generate notes and add important points as well\"\n", + " \"The type of the output should be a string with proper alignment for ease readability for user\"\n", + "\n", + " )\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": (\n", + " \"Topic: \" + Topic + \" Sub-topic: \" + SubTopic\n", + " )\n", + " }\n", + " ],\n", + " model=\"llama3-8b-8192\",\n", + " temperature=0.5,\n", + " max_tokens=1024,\n", + " top_p=1,\n", + " stop=None,\n", + " stream=False,\n", + " )\n", + "\n", + " return chat_completion.choices[0].message.content\n", + "\n", + "def update_subtopics(topic):\n", + " if topic == \"Python\":\n", + " return gr.update(choices=[\n", + " \"Introduction to Python\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Comparison, Logical)\",\n", + " \"Control Flow (if, else, loops)\",\n", + " \"Functions and Lambda Functions\",\n", + " \"Lists, Tuples, Sets, and Dictionaries\",\n", + " \"List Comprehensions\",\n", + " \"File Handling\",\n", + " \"Exception Handling\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Encapsulation and Abstraction\",\n", + " \"Modules and Packages\",\n", + " \"Iterators and Generators\",\n", + " \"Decorators and Closures\",\n", + " \"Regular Expressions\",\n", + " \"Multithreading and Concurrency\",\n", + " \"Asynchronous Programming (asyncio)\",\n", + " \"Working with Databases (SQLite, MySQL)\",\n", + " \"Web Development (Flask, Django)\",\n", + " \"Web Scraping (BeautifulSoup, Scrapy)\",\n", + " \"Unit Testing (unittest, pytest)\",\n", + " \"Virtual Environments\",\n", + " \"Standard Libraries and External Libraries\",\n", + " \"Metaprogramming\",\n", + " \"Context Managers\",\n", + " \"Memory Management and Garbage Collection\",\n", + " \"Networking (Sockets, HTTP Requests)\"\n", + "])\n", + " elif topic == \"Java\":\n", + " return gr.update(choices=[\n", + " \"Introduction to Java\",\n", + " \"Variables and Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Classes and Objects\",\n", + " \"Methods and Constructors\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Abstraction and Encapsulation\",\n", + " \"Interfaces and Abstract Classes\",\n", + " \"Exception Handling\",\n", + " \"File Handling (IO)\",\n", + " \"Collections Framework (List, Set, Map, etc.)\",\n", + " \"Generics\",\n", + " \"Multithreading and Concurrency\",\n", + " \"Java Input/Output (Streams and File I/O)\",\n", + " \"Lambda Expressions\",\n", + " \"Streams API\",\n", + " \"JDBC (Java Database Connectivity)\",\n", + " \"Annotations\",\n", + " \"Enums\",\n", + " \"Inner Classes\",\n", + " \"JavaFX (GUI Programming)\",\n", + " \"Java Memory Management\",\n", + " \"JVM Architecture\",\n", + " \"Garbage Collection\",\n", + " \"Networking (Sockets, HTTP)\",\n", + " \"Unit Testing (JUnit)\",\n", + " \"Spring Framework Basics\",\n", + " \"Maven and Gradle (Build Tools)\",\n", + " \"JAR and WAR Files\"\n", + "])\n", + " elif topic == \"C++\":\n", + " return gr.update(choices=[\n", + " \"Introduction to C++\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Logical, Bitwise)\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Pointers and References\",\n", + " \"Arrays and Strings\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Classes and Objects\",\n", + " \"Constructors and Destructors\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Encapsulation and Abstraction\",\n", + " \"Friend Functions and Friend Classes\",\n", + " \"Function Overloading and Operator Overloading\",\n", + " \"Templates (Function and Class Templates)\",\n", + " \"STL (Standard Template Library)\",\n", + " \"Exception Handling\",\n", + " \"File Handling\",\n", + " \"Multithreading\",\n", + " \"Lambda Expressions\",\n", + " \"Smart Pointers\",\n", + " \"Namespaces\",\n", + " \"Memory Management (Dynamic Memory, new and delete)\",\n", + " \"Input/Output Streams\",\n", + " \"Move Semantics and R-value References\",\n", + " \"C++11, C++14, C++17, and C++20 Features\"\n", + "])\n", + " elif topic == \"C\":\n", + " return gr.update(choices=[\n", + " \"Introduction to C\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Logical, Bitwise)\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Pointers\",\n", + " \"Arrays and Strings\",\n", + " \"Structures and Unions\",\n", + " \"Dynamic Memory Allocation (malloc, calloc, free)\",\n", + " \"Preprocessor Directives\",\n", + " \"File Handling\",\n", + " \"Standard Input/Output (printf, scanf)\",\n", + " \"Command Line Arguments\",\n", + " \"Recursion\",\n", + " \"Bitwise Operations\",\n", + " \"Storage Classes\",\n", + " \"Function Pointers\",\n", + " \"Linked Lists\",\n", + " \"Stacks and Queues\",\n", + " \"Memory Management\",\n", + " \"Multithreading (POSIX Threads)\",\n", + " \"Macros and Inline Functions\"\n", + "])\n", + " elif topic == \"JavaScript\":\n", + " return gr.update(choices=[\n", + " \"Introduction to JavaScript\",\n", + " \"Variables (var, let, const)\",\n", + " \"Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Arrow Functions\",\n", + " \"Objects and Arrays\",\n", + " \"Prototypes and Inheritance\",\n", + " \"Closures\",\n", + " \"Callbacks and Promises\",\n", + " \"Async/Await\",\n", + " \"Event Handling\",\n", + " \"DOM Manipulation\",\n", + " \"Form Validation\",\n", + " \"Error Handling\",\n", + " \"Modules (ES6)\",\n", + " \"Classes (ES6)\",\n", + " \"JSON Handling\",\n", + " \"LocalStorage and SessionStorage\",\n", + " \"AJAX and Fetch API\",\n", + " \"REST APIs\",\n", + " \"WebSockets\",\n", + " \"JavaScript Frameworks (React, Angular, Vue)\",\n", + " \"Browser APIs (Geolocation, Canvas, etc.)\",\n", + " \"Node.js Basics\",\n", + " \"Event Loop and Concurrency\",\n", + " \"Testing (Jest, Mocha)\"\n", + "])\n", + " elif topic == \"HTML\":\n", + " return gr.update(choices=[\n", + " \"Introduction to HTML\",\n", + " \"Basic Structure of an HTML Document\",\n", + " \"HTML Tags and Attributes\",\n", + " \"Headings, Paragraphs, and Text Formatting\",\n", + " \"Links and Anchor Tags\",\n", + " \"Images and Image Maps\",\n", + " \"Lists (Ordered, Unordered)\",\n", + " \"Tables\",\n", + " \"Forms (Input, Button, Textarea)\",\n", + " \"Form Validation\",\n", + " \"HTML5 Semantic Elements (header, footer, article, section)\",\n", + " \"Multimedia (Audio, Video)\",\n", + " \"HTML5 APIs (Canvas, Geolocation, Web Storage)\",\n", + " \"Meta Tags and SEO\",\n", + " \"Inline vs Block Elements\",\n", + " \"iframes\",\n", + " \"Responsive Web Design (Viewport, Media Queries)\"\n", + "])\n", + "\n", + " elif topic == \"CSS\":\n", + " return gr.update(choices=[\n", + " \"Introduction to CSS\",\n", + " \"CSS Syntax and Selectors\",\n", + " \"Colors and Backgrounds\",\n", + " \"Fonts and Typography\",\n", + " \"Box Model (Padding, Margin, Border)\",\n", + " \"CSS Units (px, %, em, rem, vh, vw)\",\n", + " \"Positioning (Static, Relative, Absolute, Fixed)\",\n", + " \"Flexbox\",\n", + " \"CSS Grid\",\n", + " \"Responsive Web Design (Media Queries)\",\n", + " \"CSS Transitions and Animations\",\n", + " \"Pseudo-classes and Pseudo-elements\",\n", + " \"CSS Variables\",\n", + " \"CSS Preprocessors (Sass, LESS)\",\n", + " \"CSS Frameworks (Bootstrap, Tailwind)\",\n", + " \"CSS Specificity and Inheritance\",\n", + " \"CSS Layout Techniques (Float, Clear, etc.)\"\n", + "])\n", + "\n", + " elif topic == \"Kotlin\":\n", + " return gr.update(choices=[\n", + " \"Introduction to Kotlin\",\n", + " \"Variables and Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, when, loops)\",\n", + " \"Functions\",\n", + " \"Null Safety\",\n", + " \"Classes and Objects\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Interfaces and Abstract Classes\",\n", + " \"Extension Functions\",\n", + " \"Lambda Expressions\",\n", + " \"Higher-Order Functions\",\n", + " \"Collections and Iterators\",\n", + " \"Coroutines\",\n", + " \"Exception Handling\",\n", + " \"Type Inference\",\n", + " \"Smart Casts\",\n", + " \"Data Classes\",\n", + " \"Sealed Classes\",\n", + " \"Generics\",\n", + " \"Companion Objects\",\n", + " \"Kotlin for Android Development\",\n", + " \"Kotlin DSL\"\n", + "])\n", + "\n", + " elif topic == \"PHP\":\n", + " return gr.update(choices=[\n", + " \"Introduction to PHP\",\n", + " \"Variables and Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Arrays\",\n", + " \"Superglobals ($_GET, $_POST, $_SESSION)\",\n", + " \"Forms and User Input\",\n", + " \"Cookies and Sessions\",\n", + " \"File Handling\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Classes and Objects\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Error Handling\",\n", + " \"Working with Databases (MySQL, PDO)\",\n", + " \"Prepared Statements\",\n", + " \"AJAX with PHP\",\n", + " \"Security (SQL Injection, XSS, CSRF)\",\n", + " \"PHP Frameworks (Laravel, Symfony)\",\n", + " \"REST API with PHP\",\n", + " \"Email Handling\"\n", + "])\n", + "\n", + " elif topic == \"SQL\":\n", + " return gr.update(choices=[\n", + " \"Introduction to SQL\",\n", + " \"Database Basics\",\n", + " \"Data Types\",\n", + " \"DDL (Data Definition Language)\",\n", + " \"DML (Data Manipulation Language)\",\n", + " \"DCL (Data Control Language)\",\n", + " \"Creating Tables\",\n", + " \"Inserting Data\",\n", + " \"Updating Data\",\n", + " \"Deleting Data\",\n", + " \"Basic SELECT Queries\",\n", + " \"WHERE Clauses and Operators\",\n", + " \"JOINs (INNER, LEFT, RIGHT, FULL)\",\n", + " \"GROUP BY and HAVING\",\n", + " \"Aggregate Functions (SUM, AVG, COUNT)\",\n", + " \"Subqueries\",\n", + " \"Indexes\",\n", + " \"Views\",\n", + " \"Stored Procedures and Functions\",\n", + " \"Transactions\",\n", + " \"Normalization\",\n", + " \"Constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, etc.)\",\n", + " \"SQL Triggers\",\n", + " \"Database Security\",\n", + " \"SQL Optimization Techniques\"\n", + "])\n", + "\n", + " else:\n", + " return gr.update(choices=[])\n", + "\n", + "def clear_inputs():\n", + " return \"\", \"\", 1, \"Easy\", \"\"\n", + "\n", + "css = \"\"\"\n", + "/* Styling for glowing buttons */\n", + "button {\n", + " background-color: #1e3a8a;\n", + " color: white;\n", + " border: none;\n", + " padding: 10px 20px;\n", + " border-radius: 5px;\n", + " box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);\n", + " transition: 0.3s;\n", + "}\n", + "\n", + "/* Button hover effect for glowing effect */\n", + "button:hover {\n", + " box-shadow: 0 0 10px #4ade80, 0 0 30px #34d399, 0 0 50px #10b981;\n", + " transform: scale(1.05);\n", + "}\n", + "\n", + "/* Background for the whole interface */\n", + "body {\n", + " background-color: #f3f4f6;\n", + " color: #1f2937;\n", + "}\n", + "\n", + "/* Styling for textboxes and dropdowns */\n", + ".gradio-container {\n", + " font-family: 'Arial', sans-serif;\n", + " color: #1e40af;\n", + "}\n", + "\n", + "/* Container for the text output */\n", + ".gr-textbox {\n", + " background-color: #e0f2fe;\n", + " border: 1px solid #0284c7;\n", + " border-radius: 10px;\n", + " padding: 15px;\n", + "}\n", + "\n", + "# /* Slider theme */\n", + "# input[type=range] {\n", + "# accent-color: #2563eb;\n", + "# }\n", + "\"\"\"\n", + "\n", + "with gr.Blocks(css=css) as demo:\n", + "\n", + " topic_dropdown = gr.Dropdown(choices=[\"Python\", \"Java\", \"C++\",\"C\",\"JavaScript\",\"HTML\",\"CSS\",\"Kotlin\",\"PHP\",\"SQL\"], label=\"Select Topic\", value=\"Python\")\n", + "\n", + " subtopic_dropdown = gr.Dropdown(choices=[\n", + " \"Introduction to Python\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Comparison, Logical)\",\n", + " \"Control Flow (if, else, loops)\",\n", + " \"Functions and Lambda Functions\",\n", + " \"Lists, Tuples, Sets, and Dictionaries\",\n", + " \"List Comprehensions\",\n", + " \"File Handling\",\n", + " \"Exception Handling\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Encapsulation and Abstraction\",\n", + " \"Modules and Packages\",\n", + " \"Iterators and Generators\",\n", + " \"Decorators and Closures\",\n", + " \"Regular Expressions\",\n", + " \"Multithreading and Concurrency\",\n", + " \"Asynchronous Programming (asyncio)\",\n", + " \"Working with Databases (SQLite, MySQL)\",\n", + " \"Web Development (Flask, Django)\",\n", + " \"Web Scraping (BeautifulSoup, Scrapy)\",\n", + " \"Unit Testing (unittest, pytest)\",\n", + " \"Virtual Environments\",\n", + " \"Standard Libraries and External Libraries\",\n", + " \"Metaprogramming\",\n", + " \"Context Managers\",\n", + " \"Memory Management and Garbage Collection\",\n", + " \"Networking (Sockets, HTTP Requests)\"\n", + "], label=\"Select Sub-topic\", value=\"Basics\")\n", + "\n", + "\n", + " submit_button = gr.Button(\"Generate Notes\")\n", + "\n", + " clear_button = gr.Button(\"Clear Inputs\")\n", + "\n", + " cancel_button = gr.Button(\"Cancel\")\n", + "\n", + " output_text = gr.Textbox(label=\"Notes\", placeholder=\"Notes will appear here...\")\n", + "\n", + " topic_dropdown.change(fn=update_subtopics, inputs=topic_dropdown, outputs=subtopic_dropdown)\n", + "\n", + " submit_button.click(\n", + " fn=getResponse,\n", + " inputs=[topic_dropdown, subtopic_dropdown],\n", + " outputs=output_text\n", + " )\n", + "\n", + " clear_button.click(\n", + " fn=clear_inputs,\n", + " inputs=[],\n", + " outputs=[topic_dropdown, subtopic_dropdown, output_text]\n", + " )\n", + "\n", + " cancel_button.click(\n", + " fn=lambda: \"Action Cancelled!\",\n", + " inputs=[],\n", + " outputs=output_text\n", + " )\n", + "\n", + "demo.launch(share=True)\n" + ], + "metadata": { + "id": "qoVcCrfLpmXG", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 645 + }, + "outputId": "07e8be2c-b1e2-4404-a488-7fbf0a3ee8e5" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.10/dist-packages/gradio/components/dropdown.py:188: UserWarning: The value passed into gr.Dropdown() is not in the list of choices. Please update the list of choices to include: Basics or set allow_custom_value=True.\n", + " warnings.warn(\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n", + "Running on public URL: https://339ee461b1caa01357.gradio.live\n", + "\n", + "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [] + }, + "metadata": {}, + "execution_count": 3 + } + ] + } + ] +} \ No newline at end of file diff --git a/AI Maniacs Project Submission/Gradio_is_Generating_Questions.ipynb b/AI Maniacs Project Submission/Gradio_is_Generating_Questions.ipynb new file mode 100644 index 0000000..2d14525 --- /dev/null +++ b/AI Maniacs Project Submission/Gradio_is_Generating_Questions.ipynb @@ -0,0 +1,660 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "source": [ + "!pip install groq\n", + "!pip install gradio\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "pBrHRvAY9Cfb", + "outputId": "0f02e796-b51a-4adf-d90f-5a3500168465" + }, + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting groq\n", + " Downloading groq-0.11.0-py3-none-any.whl.metadata (13 kB)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from groq) (3.7.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from groq) (1.7.0)\n", + "Collecting httpx<1,>=0.23.0 (from groq)\n", + " Downloading httpx-0.27.2-py3-none-any.whl.metadata (7.1 kB)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from groq) (2.9.2)\n", + "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from groq) (1.3.1)\n", + "Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from groq) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->groq) (3.10)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->groq) (1.2.2)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->groq) (2024.8.30)\n", + "Collecting httpcore==1.* (from httpx<1,>=0.23.0->groq)\n", + " Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)\n", + "Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx<1,>=0.23.0->groq)\n", + " Downloading h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->groq) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->groq) (2.23.4)\n", + "Downloading groq-0.11.0-py3-none-any.whl (106 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m106.5/106.5 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading httpx-0.27.2-py3-none-any.whl (76 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.4/76.4 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading httpcore-1.0.5-py3-none-any.whl (77 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading h11-0.14.0-py3-none-any.whl (58 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: h11, httpcore, httpx, groq\n", + "Successfully installed groq-0.11.0 h11-0.14.0 httpcore-1.0.5 httpx-0.27.2\n", + "Collecting gradio\n", + " Downloading gradio-4.44.0-py3-none-any.whl.metadata (15 kB)\n", + "Collecting aiofiles<24.0,>=22.0 (from gradio)\n", + " Downloading aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)\n", + "Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n", + "Collecting fastapi<1.0 (from gradio)\n", + " Downloading fastapi-0.115.0-py3-none-any.whl.metadata (27 kB)\n", + "Collecting ffmpy (from gradio)\n", + " Downloading ffmpy-0.4.0-py3-none-any.whl.metadata (2.9 kB)\n", + "Collecting gradio-client==1.3.0 (from gradio)\n", + " Downloading gradio_client-1.3.0-py3-none-any.whl.metadata (7.1 kB)\n", + "Requirement already satisfied: httpx>=0.24.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.27.2)\n", + "Requirement already satisfied: huggingface-hub>=0.19.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.24.7)\n", + "Requirement already satisfied: importlib-resources<7.0,>=1.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.4.5)\n", + "Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.4)\n", + "Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.5)\n", + "Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n", + "Requirement already satisfied: numpy<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.26.4)\n", + "Collecting orjson~=3.0 (from gradio)\n", + " Downloading orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (50 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.4/50.4 kB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (24.1)\n", + "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.4)\n", + "Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (10.4.0)\n", + "Requirement already satisfied: pydantic>=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.9.2)\n", + "Collecting pydub (from gradio)\n", + " Downloading pydub-0.25.1-py2.py3-none-any.whl.metadata (1.4 kB)\n", + "Collecting python-multipart>=0.0.9 (from gradio)\n", + " Downloading python_multipart-0.0.11-py3-none-any.whl.metadata (1.9 kB)\n", + "Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.2)\n", + "Collecting ruff>=0.2.2 (from gradio)\n", + " Downloading ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)\n", + "Collecting semantic-version~=2.0 (from gradio)\n", + " Downloading semantic_version-2.10.0-py2.py3-none-any.whl.metadata (9.7 kB)\n", + "Collecting tomlkit==0.12.0 (from gradio)\n", + " Downloading tomlkit-0.12.0-py3-none-any.whl.metadata (2.7 kB)\n", + "Requirement already satisfied: typer<1.0,>=0.12 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.12.5)\n", + "Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.12.2)\n", + "Requirement already satisfied: urllib3~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.2.3)\n", + "Collecting uvicorn>=0.14.0 (from gradio)\n", + " Downloading uvicorn-0.31.0-py3-none-any.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.3.0->gradio) (2024.6.1)\n", + "Collecting websockets<13.0,>=10.0 (from gradio-client==1.3.0->gradio)\n", + " Downloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (3.10)\n", + "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.3.1)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.2.2)\n", + "Collecting starlette<0.39.0,>=0.37.2 (from fastapi<1.0->gradio)\n", + " Downloading starlette-0.38.6-py3-none-any.whl.metadata (6.0 kB)\n", + "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (1.0.5)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (3.16.1)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (2.32.3)\n", + "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (4.66.5)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.3.0)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (4.53.1)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.4.7)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (3.1.4)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n", + "Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (2.23.4)\n", + "Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n", + "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\n", + "Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (13.8.1)\n", + "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n", + "Downloading gradio-4.44.0-py3-none-any.whl (18.1 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.1/18.1 MB\u001b[0m \u001b[31m53.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading gradio_client-1.3.0-py3-none-any.whl (318 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m318.7/318.7 kB\u001b[0m \u001b[31m23.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading tomlkit-0.12.0-py3-none-any.whl (37 kB)\n", + "Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)\n", + "Downloading fastapi-0.115.0-py3-none-any.whl (94 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.6/94.6 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading orjson-3.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.9/141.9 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading python_multipart-0.0.11-py3-none-any.whl (22 kB)\n", + "Downloading ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.9/10.9 MB\u001b[0m \u001b[31m70.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n", + "Downloading uvicorn-0.31.0-py3-none-any.whl (63 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m63.7/63.7 kB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading ffmpy-0.4.0-py3-none-any.whl (5.8 kB)\n", + "Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n", + "Downloading starlette-0.38.6-py3-none-any.whl (71 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.5/71.5 kB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (130 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: pydub, websockets, uvicorn, tomlkit, semantic-version, ruff, python-multipart, orjson, ffmpy, aiofiles, starlette, gradio-client, fastapi, gradio\n", + "Successfully installed aiofiles-23.2.1 fastapi-0.115.0 ffmpy-0.4.0 gradio-4.44.0 gradio-client-1.3.0 orjson-3.10.7 pydub-0.25.1 python-multipart-0.0.11 ruff-0.6.8 semantic-version-2.10.0 starlette-0.38.6 tomlkit-0.12.0 uvicorn-0.31.0 websockets-12.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 645 + }, + "id": "viNzXYwE7YY_", + "outputId": "75357b5f-aa68-4d6e-cea7-d725a50aa29a" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.10/dist-packages/gradio/components/dropdown.py:188: UserWarning: The value passed into gr.Dropdown() is not in the list of choices. Please update the list of choices to include: Basics or set allow_custom_value=True.\n", + " warnings.warn(\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n", + "Running on public URL: https://8bb1d8e4db7904ca14.gradio.live\n", + "\n", + "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "
" + ] + }, + "metadata": {} + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [] + }, + "metadata": {}, + "execution_count": 5 + } + ], + "source": [ + "import gradio as gr\n", + "from groq import Groq\n", + "\n", + "def getResponse(Topic, SubTopic, QuestionNumbers, level):\n", + " client = Groq(api_key=\"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\")\n", + "\n", + " chat_completion = client.chat.completions.create(\n", + " messages=[\n", + " {\n", + " \"role\": \"system\",\n", + " \"content\": (\n", + " \"You are a computer science professor and I will give you the topic name, sub-topic, number of questions, \"\n", + " \"and level of the questions. You have to generate practice questions and \"\n", + " \"also give answers. The type of the output should be a string with proper alignment for ease readability for user\"\n", + " \"generate questions only if the topic is related to coding and technology\"\n", + " )\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": (\n", + " \"Topic: \" + Topic + \" Sub-topic: \" + SubTopic + \" Number of questions: \" + str(QuestionNumbers) +\n", + " \" Level: \" + level\n", + " )\n", + " }\n", + " ],\n", + " model=\"llama3-8b-8192\",\n", + " temperature=0.5,\n", + " max_tokens=1024,\n", + " top_p=1,\n", + " stop=None,\n", + " stream=False,\n", + " )\n", + "\n", + " return chat_completion.choices[0].message.content\n", + "\n", + "\n", + "def update_subtopics(topic):\n", + " if topic == \"Python\":\n", + " return gr.update(choices=[\n", + " \"Introduction to Python\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Comparison, Logical)\",\n", + " \"Control Flow (if, else, loops)\",\n", + " \"Functions and Lambda Functions\",\n", + " \"Lists, Tuples, Sets, and Dictionaries\",\n", + " \"List Comprehensions\",\n", + " \"File Handling\",\n", + " \"Exception Handling\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Encapsulation and Abstraction\",\n", + " \"Modules and Packages\",\n", + " \"Iterators and Generators\",\n", + " \"Decorators and Closures\",\n", + " \"Regular Expressions\",\n", + " \"Multithreading and Concurrency\",\n", + " \"Asynchronous Programming (asyncio)\",\n", + " \"Working with Databases (SQLite, MySQL)\",\n", + " \"Web Development (Flask, Django)\",\n", + " \"Web Scraping (BeautifulSoup, Scrapy)\",\n", + " \"Unit Testing (unittest, pytest)\",\n", + " \"Virtual Environments\",\n", + " \"Standard Libraries and External Libraries\",\n", + " \"Metaprogramming\",\n", + " \"Context Managers\",\n", + " \"Memory Management and Garbage Collection\",\n", + " \"Networking (Sockets, HTTP Requests)\"\n", + "])\n", + " elif topic == \"Java\":\n", + " return gr.update(choices=[\n", + " \"Introduction to Java\",\n", + " \"Variables and Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Classes and Objects\",\n", + " \"Methods and Constructors\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Abstraction and Encapsulation\",\n", + " \"Interfaces and Abstract Classes\",\n", + " \"Exception Handling\",\n", + " \"File Handling (IO)\",\n", + " \"Collections Framework (List, Set, Map, etc.)\",\n", + " \"Generics\",\n", + " \"Multithreading and Concurrency\",\n", + " \"Java Input/Output (Streams and File I/O)\",\n", + " \"Lambda Expressions\",\n", + " \"Streams API\",\n", + " \"JDBC (Java Database Connectivity)\",\n", + " \"Annotations\",\n", + " \"Enums\",\n", + " \"Inner Classes\",\n", + " \"JavaFX (GUI Programming)\",\n", + " \"Java Memory Management\",\n", + " \"JVM Architecture\",\n", + " \"Garbage Collection\",\n", + " \"Networking (Sockets, HTTP)\",\n", + " \"Unit Testing (JUnit)\",\n", + " \"Spring Framework Basics\",\n", + " \"Maven and Gradle (Build Tools)\",\n", + " \"JAR and WAR Files\"\n", + "])\n", + " elif topic == \"C++\":\n", + " return gr.update(choices=[\n", + " \"Introduction to C++\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Logical, Bitwise)\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Pointers and References\",\n", + " \"Arrays and Strings\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Classes and Objects\",\n", + " \"Constructors and Destructors\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Encapsulation and Abstraction\",\n", + " \"Friend Functions and Friend Classes\",\n", + " \"Function Overloading and Operator Overloading\",\n", + " \"Templates (Function and Class Templates)\",\n", + " \"STL (Standard Template Library)\",\n", + " \"Exception Handling\",\n", + " \"File Handling\",\n", + " \"Multithreading\",\n", + " \"Lambda Expressions\",\n", + " \"Smart Pointers\",\n", + " \"Namespaces\",\n", + " \"Memory Management (Dynamic Memory, new and delete)\",\n", + " \"Input/Output Streams\",\n", + " \"Move Semantics and R-value References\",\n", + " \"C++11, C++14, C++17, and C++20 Features\"\n", + "])\n", + " elif topic == \"C\":\n", + " return gr.update(choices=[\n", + " \"Introduction to C\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Logical, Bitwise)\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Pointers\",\n", + " \"Arrays and Strings\",\n", + " \"Structures and Unions\",\n", + " \"Dynamic Memory Allocation (malloc, calloc, free)\",\n", + " \"Preprocessor Directives\",\n", + " \"File Handling\",\n", + " \"Standard Input/Output (printf, scanf)\",\n", + " \"Command Line Arguments\",\n", + " \"Recursion\",\n", + " \"Bitwise Operations\",\n", + " \"Storage Classes\",\n", + " \"Function Pointers\",\n", + " \"Linked Lists\",\n", + " \"Stacks and Queues\",\n", + " \"Memory Management\",\n", + " \"Multithreading (POSIX Threads)\",\n", + " \"Macros and Inline Functions\"\n", + "])\n", + " elif topic == \"JavaScript\":\n", + " return gr.update(choices=[\n", + " \"Introduction to JavaScript\",\n", + " \"Variables (var, let, const)\",\n", + " \"Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Arrow Functions\",\n", + " \"Objects and Arrays\",\n", + " \"Prototypes and Inheritance\",\n", + " \"Closures\",\n", + " \"Callbacks and Promises\",\n", + " \"Async/Await\",\n", + " \"Event Handling\",\n", + " \"DOM Manipulation\",\n", + " \"Form Validation\",\n", + " \"Error Handling\",\n", + " \"Modules (ES6)\",\n", + " \"Classes (ES6)\",\n", + " \"JSON Handling\",\n", + " \"LocalStorage and SessionStorage\",\n", + " \"AJAX and Fetch API\",\n", + " \"REST APIs\",\n", + " \"WebSockets\",\n", + " \"JavaScript Frameworks (React, Angular, Vue)\",\n", + " \"Browser APIs (Geolocation, Canvas, etc.)\",\n", + " \"Node.js Basics\",\n", + " \"Event Loop and Concurrency\",\n", + " \"Testing (Jest, Mocha)\"\n", + "])\n", + " elif topic == \"HTML\":\n", + " return gr.update(choices=[\n", + " \"Introduction to HTML\",\n", + " \"Basic Structure of an HTML Document\",\n", + " \"HTML Tags and Attributes\",\n", + " \"Headings, Paragraphs, and Text Formatting\",\n", + " \"Links and Anchor Tags\",\n", + " \"Images and Image Maps\",\n", + " \"Lists (Ordered, Unordered)\",\n", + " \"Tables\",\n", + " \"Forms (Input, Button, Textarea)\",\n", + " \"Form Validation\",\n", + " \"HTML5 Semantic Elements (header, footer, article, section)\",\n", + " \"Multimedia (Audio, Video)\",\n", + " \"HTML5 APIs (Canvas, Geolocation, Web Storage)\",\n", + " \"Meta Tags and SEO\",\n", + " \"Inline vs Block Elements\",\n", + " \"iframes\",\n", + " \"Responsive Web Design (Viewport, Media Queries)\"\n", + "])\n", + "\n", + " elif topic == \"CSS\":\n", + " return gr.update(choices=[\n", + " \"Introduction to CSS\",\n", + " \"CSS Syntax and Selectors\",\n", + " \"Colors and Backgrounds\",\n", + " \"Fonts and Typography\",\n", + " \"Box Model (Padding, Margin, Border)\",\n", + " \"CSS Units (px, %, em, rem, vh, vw)\",\n", + " \"Positioning (Static, Relative, Absolute, Fixed)\",\n", + " \"Flexbox\",\n", + " \"CSS Grid\",\n", + " \"Responsive Web Design (Media Queries)\",\n", + " \"CSS Transitions and Animations\",\n", + " \"Pseudo-classes and Pseudo-elements\",\n", + " \"CSS Variables\",\n", + " \"CSS Preprocessors (Sass, LESS)\",\n", + " \"CSS Frameworks (Bootstrap, Tailwind)\",\n", + " \"CSS Specificity and Inheritance\",\n", + " \"CSS Layout Techniques (Float, Clear, etc.)\"\n", + "])\n", + "\n", + " elif topic == \"Kotlin\":\n", + " return gr.update(choices=[\n", + " \"Introduction to Kotlin\",\n", + " \"Variables and Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, when, loops)\",\n", + " \"Functions\",\n", + " \"Null Safety\",\n", + " \"Classes and Objects\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Interfaces and Abstract Classes\",\n", + " \"Extension Functions\",\n", + " \"Lambda Expressions\",\n", + " \"Higher-Order Functions\",\n", + " \"Collections and Iterators\",\n", + " \"Coroutines\",\n", + " \"Exception Handling\",\n", + " \"Type Inference\",\n", + " \"Smart Casts\",\n", + " \"Data Classes\",\n", + " \"Sealed Classes\",\n", + " \"Generics\",\n", + " \"Companion Objects\",\n", + " \"Kotlin for Android Development\",\n", + " \"Kotlin DSL\"\n", + "])\n", + "\n", + " elif topic == \"PHP\":\n", + " return gr.update(choices=[\n", + " \"Introduction to PHP\",\n", + " \"Variables and Data Types\",\n", + " \"Operators\",\n", + " \"Control Flow (if, else, switch, loops)\",\n", + " \"Functions\",\n", + " \"Arrays\",\n", + " \"Superglobals ($_GET, $_POST, $_SESSION)\",\n", + " \"Forms and User Input\",\n", + " \"Cookies and Sessions\",\n", + " \"File Handling\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Classes and Objects\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Error Handling\",\n", + " \"Working with Databases (MySQL, PDO)\",\n", + " \"Prepared Statements\",\n", + " \"AJAX with PHP\",\n", + " \"Security (SQL Injection, XSS, CSRF)\",\n", + " \"PHP Frameworks (Laravel, Symfony)\",\n", + " \"REST API with PHP\",\n", + " \"Email Handling\"\n", + "])\n", + "\n", + " elif topic == \"SQL\":\n", + " return gr.update(choices=[\n", + " \"Introduction to SQL\",\n", + " \"Database Basics\",\n", + " \"Data Types\",\n", + " \"DDL (Data Definition Language)\",\n", + " \"DML (Data Manipulation Language)\",\n", + " \"DCL (Data Control Language)\",\n", + " \"Creating Tables\",\n", + " \"Inserting Data\",\n", + " \"Updating Data\",\n", + " \"Deleting Data\",\n", + " \"Basic SELECT Queries\",\n", + " \"WHERE Clauses and Operators\",\n", + " \"JOINs (INNER, LEFT, RIGHT, FULL)\",\n", + " \"GROUP BY and HAVING\",\n", + " \"Aggregate Functions (SUM, AVG, COUNT)\",\n", + " \"Subqueries\",\n", + " \"Indexes\",\n", + " \"Views\",\n", + " \"Stored Procedures and Functions\",\n", + " \"Transactions\",\n", + " \"Normalization\",\n", + " \"Constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, etc.)\",\n", + " \"SQL Triggers\",\n", + " \"Database Security\",\n", + " \"SQL Optimization Techniques\"\n", + "])\n", + "\n", + " else:\n", + " return gr.update(choices=[])\n", + "\n", + "def clear_inputs():\n", + " return \"\", \"\", 1, \"Easy\", \"\"\n", + "\n", + "css = \"\"\"\n", + "/* Styling for glowing buttons */\n", + "button {\n", + " background-color: #1e3a8a;\n", + " color: white;\n", + " border: none;\n", + " padding: 10px 20px;\n", + " border-radius: 5px;\n", + " box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);\n", + " transition: 0.3s;\n", + "}\n", + "\n", + "/* Button hover effect for glowing effect */\n", + "button:hover {\n", + " box-shadow: 0 0 10px #4ade80, 0 0 30px #34d399, 0 0 50px #10b981;\n", + " transform: scale(1.05);\n", + "}\n", + "\n", + "/* Background for the whole interface */\n", + "body {\n", + " background-color: #f3f4f6;\n", + " color: #1f2937;\n", + "}\n", + "\n", + "/* Styling for textboxes and dropdowns */\n", + ".gradio-container {\n", + " font-family: 'Arial', sans-serif;\n", + " color: #1e40af;\n", + "}\n", + "\n", + "/* Container for the text output */\n", + ".gr-textbox {\n", + " background-color: #e0f2fe;\n", + " border: 1px solid #0284c7;\n", + " border-radius: 10px;\n", + " padding: 15px;\n", + "}\n", + "\n", + "/* Slider theme */\n", + "input[type=range] {\n", + " accent-color: #2563eb;\n", + "}\n", + "\"\"\"\n", + "\n", + "\n", + "with gr.Blocks(css=css) as demo:\n", + "\n", + " topic_dropdown = gr.Dropdown(choices=[\"Python\", \"Java\", \"C++\",\"C\",\"JavaScript\",\"HTML\",\"CSS\",\"Kotlin\",\"PHP\",\"SQL\"], label=\"Select Topic\", value=\"Python\")\n", + "\n", + "\n", + " subtopic_dropdown = gr.Dropdown(choices=[\n", + " \"Introduction to Python\",\n", + " \"Variables and Data Types\",\n", + " \"Operators (Arithmetic, Comparison, Logical)\",\n", + " \"Control Flow (if, else, loops)\",\n", + " \"Functions and Lambda Functions\",\n", + " \"Lists, Tuples, Sets, and Dictionaries\",\n", + " \"List Comprehensions\",\n", + " \"File Handling\",\n", + " \"Exception Handling\",\n", + " \"Object-Oriented Programming (OOP)\",\n", + " \"Inheritance and Polymorphism\",\n", + " \"Encapsulation and Abstraction\",\n", + " \"Modules and Packages\",\n", + " \"Iterators and Generators\",\n", + " \"Decorators and Closures\",\n", + " \"Regular Expressions\",\n", + " \"Multithreading and Concurrency\",\n", + " \"Asynchronous Programming (asyncio)\",\n", + " \"Working with Databases (SQLite, MySQL)\",\n", + " \"Web Development (Flask, Django)\",\n", + " \"Web Scraping (BeautifulSoup, Scrapy)\",\n", + " \"Unit Testing (unittest, pytest)\",\n", + " \"Virtual Environments\",\n", + " \"Standard Libraries and External Libraries\",\n", + " \"Metaprogramming\",\n", + " \"Context Managers\",\n", + " \"Memory Management and Garbage Collection\",\n", + " \"Networking (Sockets, HTTP Requests)\"\n", + "], label=\"Select Sub-topic\", value=\"Basics\")\n", + "\n", + "\n", + " question_slider = gr.Slider(1, 20, step=1, label=\"Number of Questions\", value=1)\n", + "\n", + "\n", + " difficulty_radio = gr.Radio(choices=[\"Easy\", \"Medium\", \"Hard\", \"Expert\"], label=\"Select Difficulty Level\", value=\"Easy\")\n", + "\n", + "\n", + " submit_button = gr.Button(\"Generate Questions\")\n", + "\n", + "\n", + " clear_button = gr.Button(\"Clear Inputs\")\n", + "\n", + "\n", + " cancel_button = gr.Button(\"Cancel\")\n", + "\n", + "\n", + " output_text = gr.Textbox(label=\"Generated Questions\", placeholder=\"Questions will appear here...\")\n", + "\n", + "\n", + " topic_dropdown.change(fn=update_subtopics, inputs=topic_dropdown, outputs=subtopic_dropdown)\n", + "\n", + "\n", + " submit_button.click(\n", + " fn=getResponse,\n", + " inputs=[topic_dropdown, subtopic_dropdown, question_slider, difficulty_radio],\n", + " outputs=output_text\n", + " )\n", + "\n", + "\n", + " clear_button.click(\n", + " fn=clear_inputs,\n", + " inputs=[],\n", + " outputs=[topic_dropdown, subtopic_dropdown, question_slider, difficulty_radio, output_text]\n", + " )\n", + "\n", + "\n", + " cancel_button.click(\n", + " fn=lambda: \"Action Cancelled!\",\n", + " inputs=[],\n", + " outputs=output_text\n", + " )\n", + "\n", + "demo.launch(share=True)\n", + "\n" + ] + } + ] +} \ No newline at end of file diff --git a/AI Maniacs Project Submission/HTML.png b/AI Maniacs Project Submission/HTML.png new file mode 100644 index 0000000..4bf7c1f Binary files /dev/null and b/AI Maniacs Project Submission/HTML.png differ diff --git a/AI Maniacs Project Submission/Kotlin.png b/AI Maniacs Project Submission/Kotlin.png new file mode 100644 index 0000000..c6d3c53 Binary files /dev/null and b/AI Maniacs Project Submission/Kotlin.png differ diff --git a/AI Maniacs Project Submission/README.md b/AI Maniacs Project Submission/README.md new file mode 100644 index 0000000..22a0765 --- /dev/null +++ b/AI Maniacs Project Submission/README.md @@ -0,0 +1,103 @@ +# Codify - Elevate Your Coding with AI + +Welcome to **Codify**, your all-in-one platform to master coding effortlessly with AI-driven tools and curated resources. This project offers practice questions, coding assistance, and theoretical notes tailored for coders and aspiring developers. + +## Table of Contents + +- [Project Overview](#project-overview) +- [Features](#features) +- [Installation](#installation) +- [Usage](#usage) +- [Gradio Integration](#gradio-integration) +- [Temporary Links](#temporary-links) +- [Credits](#credits) + +## Project Overview + +Codify is designed to simplify and enhance your coding journey by leveraging AI technologies. The website provides: + +- AI-generated coding challenges +- Curated notes and project guidance +- Multi-language programming support + +The frontend is built with HTML and CSS, providing a smooth user experience and modern design. + +## Features + +1. **AI-Powered Practice Questions** + Access personalized coding challenges tailored to your skill level, using advanced AI models for accuracy and relevance. + +2. **Short Notes & Theory** + Simplified notes and explanations for complex coding concepts. + +3. **Problem-Solving Assistance** + AI-driven insights to debug and assist in solving coding problems. + +4. **Project Guidance** + Receive AI support and advice for completing coding projects. + +5. **Multi-Language Support** + Learn and practice different programming languages with specialized content. + +## Live Demo +https://drive.google.com/file/d/15LzAtiv5cwjOrLmpYP6n5Rj7vAJdp02G/view?usp=sharing + + +## Installation + +1. Clone the repository: + + ```bash + git clone https://github.com/Dilip0552/hackathon-projects/tree/main/AI%20Maniacs%20Project%20Submission + cd codify + ``` + +2. Open the `index.html` file in your preferred browser. + + +## Usage + +To run the project locally, simply open the `index.html` in a web browser. The website provides a user-friendly interface for exploring features like AI-powered practice questions, notes, and project guidance. + +### Gradio Integration + +Codify uses Gradio via Colab notebooks to generate temporary links for interactive AI-driven coding tools. + +#### Gradio Process: + +1. In your Google Colab notebook, ensure the required libraries like `gradio` and `groq` are installed: + + ```python + !pip install gradio + !pip install groq + ``` + +3. Used Gradio's `Interface` to expose the model: + +4. Once executed, Colab will generate a **temporary link** to access your Gradio interface. + +## Temporary Links + +Here are the three temporary Gradio links generated from Colab: + +1. [https://8bb1d8e4db7904ca14.gradio.live] + For Generating Questons + {Generated from (Gradio is Generating Questions.ipynb) and used in (generate_questions.html)} + +3. [https://339ee461b1caa01357.gradio.live] + For Generating Notes + {Generated from (Generate Notes.ipynb) and used in (generate_notes.html)} + +4. [https://8af799ebd5264850d8.gradio.live] + For AI Aid + {Generated from (AI Aid.ipynb) and used in (AI_AID.HTML)} + + +Note: These links are temporary and will expire once the Colab session ends. + +## Credits + +- **Frontend Design:** HTML, CSS, and Google Fonts +- **AI Integration:** Gradio and Google Colab +- **Temporary Links:** Gradio temporary links were generated using Colab notebooks. + diff --git a/AI Maniacs Project Submission/SQL.jpeg b/AI Maniacs Project Submission/SQL.jpeg new file mode 100644 index 0000000..7147f84 Binary files /dev/null and b/AI Maniacs Project Submission/SQL.jpeg differ diff --git a/AI Maniacs Project Submission/about-us.html b/AI Maniacs Project Submission/about-us.html new file mode 100644 index 0000000..c943559 --- /dev/null +++ b/AI Maniacs Project Submission/about-us.html @@ -0,0 +1,133 @@ + + + + + + Codify - About Us + + + + +
+ +
+ +
+

About Us

+

We are four friends who came together with a shared passion for coding and innovation. Our journey began during a hackathon where we decided to create a platform that not only simplifies coding practice but also harnesses the power of AI to offer personalized learning experiences. We believe in breaking down complex coding concepts into manageable steps, making learning fun, interactive, and effective for developers of all skill levels.

+
+

Codify was born out of our desire to help others improve their coding skills by providing an intuitive platform that adapts to each user's learning style. Whether you are a beginner looking to learn the fundamentals or an experienced developer aiming to hone advanced skills, Codify is designed to cater to your needs.

+
+

Our platform offers a wide range of features, including AI-powered practice questions, concise notes, theory explanations, and real-time problem-solving assistance. We’ve also integrated curated resources and expert project guidance, making Codify a one-stop solution for your coding journey.

+
+

As a team, we are committed to constantly evolving and enhancing Codify based on user feedback and the latest technological advancements. Together, we aim to inspire a new generation of coders to reach their full potential by leveraging the power of artificial intelligence.

+
+

Thank you for joining us on this journey. We are excited to be part of your coding adventure and look forward to helping you achieve your goals!

+
+ +
+

Copyright © 2024 Codify. All Rights Reserved.

+
+ + diff --git a/AI Maniacs Project Submission/c-.png b/AI Maniacs Project Submission/c-.png new file mode 100644 index 0000000..59e7c2c Binary files /dev/null and b/AI Maniacs Project Submission/c-.png differ diff --git a/AI Maniacs Project Submission/contact.html b/AI Maniacs Project Submission/contact.html new file mode 100644 index 0000000..8391cbd --- /dev/null +++ b/AI Maniacs Project Submission/contact.html @@ -0,0 +1,187 @@ + + + + + + Contact Us - Codify + + + + +
+ +
+ +
+

Contact Us

+

If you have any questions or need support, feel free to reach out to us!

+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+
+ +
+

Copyright © 2024 Codify. All Rights Reserved.

+
+ + diff --git a/AI Maniacs Project Submission/generate_notes.html b/AI Maniacs Project Submission/generate_notes.html new file mode 100644 index 0000000..c93400f --- /dev/null +++ b/AI Maniacs Project Submission/generate_notes.html @@ -0,0 +1,48 @@ + + + + + + AI Notes Generator + + + +

AI Notes Generator

+ + + + diff --git a/AI Maniacs Project Submission/generate_questions.html b/AI Maniacs Project Submission/generate_questions.html new file mode 100644 index 0000000..d8a87be --- /dev/null +++ b/AI Maniacs Project Submission/generate_questions.html @@ -0,0 +1,48 @@ + + + + + + AI Question Generator + + + +

AI Question Generator

+ + + + diff --git a/AI Maniacs Project Submission/get_started.html b/AI Maniacs Project Submission/get_started.html new file mode 100644 index 0000000..ce7ed72 --- /dev/null +++ b/AI Maniacs Project Submission/get_started.html @@ -0,0 +1,174 @@ + + + + + + Codify Dashboard + + + + + + + + + + +
Dashboard
+ + +
+ + + + + + + + + + + +
+ +
+

© 2024 Codify. All Rights Reserved.

+
+ + + diff --git a/AI Maniacs Project Submission/index.html b/AI Maniacs Project Submission/index.html new file mode 100644 index 0000000..aec310f --- /dev/null +++ b/AI Maniacs Project Submission/index.html @@ -0,0 +1,346 @@ + + + + + + Codify - Elevate Your Coding with AI + + + + +
+ +
+ +
+
+

Welcome to Codify

+

Your all-in-one platform to master coding effortlessly with the power of AI.
Practice, learn, and grow with curated resources tailored just for you.

+ +
+
+ +
+

Explore Our Features

+

Discover how Codify can transform your coding journey with AI-powered tools and curated content.

+
+
+

AI-Powered Practice Questions

+

Access personalized coding challenges tailored to your skill level, all generated using advanced AI models for accuracy and relevance.

+ +
+
+

Short Notes & Theory

+

Dive into concise notes and theoretical explanations that simplify complex concepts, neatly arranged for your convenience.

+ +
+
+

Problem-Solving Assistance

+

Utilize AI-driven insights to debug your code and overcome challenges swiftly, enhancing your problem-solving skills.

+ +
+
+

Project Guidance

+

Receive expert advice and AI support for your projects, ensuring you stay on the right track from start to finish.

+ +
+
+

Curated Content

+

Benefit from well-organized resources, curated using multiple AI models to provide the most accurate and helpful information.

+ +
+
+

Multi-Language Support

+

Learn and practice coding in various programming languages with content tailored to each language's specifics.

+ +
+
+ +
+

What Users Say

+
+
+

"Codify helped me solve complex coding problems with ease. Highly recommended!"

+
+
+

"The curated notes and project guidance were exactly what I needed to improve my coding skills."

+
+
+

"A fantastic app for any aspiring developer, especially with its AI-powered insights!"

+
+
+
+ +
+

Copyright © 2024 Codify. All Rights Reserved.

+
+ + diff --git a/AI Maniacs Project Submission/java-script.png b/AI Maniacs Project Submission/java-script.png new file mode 100644 index 0000000..c87fcf9 Binary files /dev/null and b/AI Maniacs Project Submission/java-script.png differ diff --git a/AI Maniacs Project Submission/java.png b/AI Maniacs Project Submission/java.png new file mode 100644 index 0000000..0d157a4 Binary files /dev/null and b/AI Maniacs Project Submission/java.png differ diff --git a/AI Maniacs Project Submission/languages.html b/AI Maniacs Project Submission/languages.html new file mode 100644 index 0000000..920b278 --- /dev/null +++ b/AI Maniacs Project Submission/languages.html @@ -0,0 +1,170 @@ + + + + + Languages - Codify + + + + +
+ +
+ +
+

Programming Languages Supported

+
+
+ Python +

Python

+
+
+ JavaScript +

JavaScript

+
+
+ Java +

Java

+
+
+ C++ +

C++

+
+
+ C +

C

+
+
+ Kotlin +

Kotlin

+
+
+ HTML +

HTML

+
+ + +
+
+ +
+

© 2024 Codify. All Rights Reserved.

+
+ + diff --git a/AI Maniacs Project Submission/progress_bar.html b/AI Maniacs Project Submission/progress_bar.html new file mode 100644 index 0000000..8ad9673 --- /dev/null +++ b/AI Maniacs Project Submission/progress_bar.html @@ -0,0 +1,14 @@ +
+

Your Progress

+
+
50%
+
+
+ + diff --git a/AI Maniacs Project Submission/python-logo-only.png b/AI Maniacs Project Submission/python-logo-only.png new file mode 100644 index 0000000..20f36f4 Binary files /dev/null and b/AI Maniacs Project Submission/python-logo-only.png differ diff --git a/AI Maniacs Project Submission/take_test.html b/AI Maniacs Project Submission/take_test.html new file mode 100644 index 0000000..bc6f46e --- /dev/null +++ b/AI Maniacs Project Submission/take_test.html @@ -0,0 +1,485 @@ + + + + + + Codify Test Platform + + + + + + +

Welcome to Codify's Coding Test!

+ + +
+

Test Settings

+ + + + + + + + + + + + +
Start Test
+
+ + + + + +
+

Test Solutions

+
+
+ + + + + + + + + +