Upload 56 files
Browse files- 00b73ec1-e836-4233-adfc-41bd938dc645.png +3 -0
- 086c78c8-2912-4660-bbf0-3a16e93d30cd.png +3 -0
- 0d7a8cad-0210-4d1e-bb62-db0dbe2049e4.png +3 -0
- 0ee621d6-12d8-4ba1-82e6-5ed1f60fa52b.png +3 -0
- 2144fdf3-12bc-44da-879f-1bdef98214a0.png +3 -0
- 3293433e-19c9-4acc-985a-b7f376f0cf96.png +3 -0
- 458bda7f-d288-4c94-8cd7-b975f8ad35df.png +3 -0
- 487282f1-3b1b-4815-a53c-7d82cbfc20aa.png +3 -0
- 540f7d82-c37c-4921-97b6-97dadbdeff26.png +3 -0
- 57ee718f-676a-4575-8253-6f2dbf6fb09d.png +3 -0
- 58cd394a-618d-4845-9ac2-471b88c1ed22.png +3 -0
- 60cd02c7-5e46-4679-9e18-4ba4191bb1cc.png +3 -0
- 6409d577-ea9f-4658-9318-766a6d889e3a.png +3 -0
- 6845b982-29c4-4b53-b2d5-31d7bfe71602.png +3 -0
- 6ac702bc-c36b-461b-8de2-51da07b644cc.png +3 -0
- 6bdc8cec-1088-4fd4-b15a-aad803b655b6.png +3 -0
- 732dbfdd-3209-4cdf-a2fc-6d8b3904dd93.png +3 -0
- 78f04ae2-fedd-4232-8088-eeb68cb81bcd.png +3 -0
- 7ae1d30d-179c-4f57-814a-401bbf3c9859.png +3 -0
- 7e7a9a4d-72a4-4f7a-82b4-bfc45c798d6b.png +3 -0
- 7f4d828e-b9e2-49f7-8050-2e4cae59e147.png +3 -0
- 81292535-e2b3-46a2-98a7-cf3c5d84828d.png +3 -0
- 82c1ab23-9a5b-499e-a3ec-62e187cbbbde.png +3 -0
- 8e114b65-14b6-4779-8e4a-6a1f4f0b31f5.png +3 -0
- a197717f-291a-4388-9a00-49aa5a0af549.png +3 -0
- a5278a88-ac75-4d6c-9182-2bc36c03bd16.png +3 -0
- aacd3a6d-68f8-4041-9b75-a06962a8acb8.png +3 -0
- ab37af6c-621b-48e6-8b41-36699498ca0f.png +3 -0
- c0db2cc2-9ce6-49a7-8e1b-ac78a415db4a.png +3 -0
- ca2964e8-306b-417e-bf64-88c52768157e.png +3 -0
- cb9da896-520c-4c7d-93a6-0cd604cf98f4.png +3 -0
- cfebe0f2-2e67-481b-a58e-31ef568b41e0.png +3 -0
- d1193d14-d21c-4a72-b441-66b0ae9e9d85.png +3 -0
- d52128b0-46ac-4e0b-85fa-6ba976a10c46.png +3 -0
- dfea396a-2bd2-4a9a-bc72-5484800394fe.png +3 -0
- e4aa925b-7224-4599-b046-53bce2b60838.png +3 -0
- f10ddec3-f257-4a9f-aa69-31cfde3450f0.png +3 -0
- metadata.jsonl +37 -0
00b73ec1-e836-4233-adfc-41bd938dc645.png
ADDED
Git LFS Details
|
086c78c8-2912-4660-bbf0-3a16e93d30cd.png
ADDED
Git LFS Details
|
0d7a8cad-0210-4d1e-bb62-db0dbe2049e4.png
ADDED
Git LFS Details
|
0ee621d6-12d8-4ba1-82e6-5ed1f60fa52b.png
ADDED
Git LFS Details
|
2144fdf3-12bc-44da-879f-1bdef98214a0.png
ADDED
Git LFS Details
|
3293433e-19c9-4acc-985a-b7f376f0cf96.png
ADDED
Git LFS Details
|
458bda7f-d288-4c94-8cd7-b975f8ad35df.png
ADDED
Git LFS Details
|
487282f1-3b1b-4815-a53c-7d82cbfc20aa.png
ADDED
Git LFS Details
|
540f7d82-c37c-4921-97b6-97dadbdeff26.png
ADDED
Git LFS Details
|
57ee718f-676a-4575-8253-6f2dbf6fb09d.png
ADDED
Git LFS Details
|
58cd394a-618d-4845-9ac2-471b88c1ed22.png
ADDED
Git LFS Details
|
60cd02c7-5e46-4679-9e18-4ba4191bb1cc.png
ADDED
Git LFS Details
|
6409d577-ea9f-4658-9318-766a6d889e3a.png
ADDED
Git LFS Details
|
6845b982-29c4-4b53-b2d5-31d7bfe71602.png
ADDED
Git LFS Details
|
6ac702bc-c36b-461b-8de2-51da07b644cc.png
ADDED
Git LFS Details
|
6bdc8cec-1088-4fd4-b15a-aad803b655b6.png
ADDED
Git LFS Details
|
732dbfdd-3209-4cdf-a2fc-6d8b3904dd93.png
ADDED
Git LFS Details
|
78f04ae2-fedd-4232-8088-eeb68cb81bcd.png
ADDED
Git LFS Details
|
7ae1d30d-179c-4f57-814a-401bbf3c9859.png
ADDED
Git LFS Details
|
7e7a9a4d-72a4-4f7a-82b4-bfc45c798d6b.png
ADDED
Git LFS Details
|
7f4d828e-b9e2-49f7-8050-2e4cae59e147.png
ADDED
Git LFS Details
|
81292535-e2b3-46a2-98a7-cf3c5d84828d.png
ADDED
Git LFS Details
|
82c1ab23-9a5b-499e-a3ec-62e187cbbbde.png
ADDED
Git LFS Details
|
8e114b65-14b6-4779-8e4a-6a1f4f0b31f5.png
ADDED
Git LFS Details
|
a197717f-291a-4388-9a00-49aa5a0af549.png
ADDED
Git LFS Details
|
a5278a88-ac75-4d6c-9182-2bc36c03bd16.png
ADDED
Git LFS Details
|
aacd3a6d-68f8-4041-9b75-a06962a8acb8.png
ADDED
Git LFS Details
|
ab37af6c-621b-48e6-8b41-36699498ca0f.png
ADDED
Git LFS Details
|
c0db2cc2-9ce6-49a7-8e1b-ac78a415db4a.png
ADDED
Git LFS Details
|
ca2964e8-306b-417e-bf64-88c52768157e.png
ADDED
Git LFS Details
|
cb9da896-520c-4c7d-93a6-0cd604cf98f4.png
ADDED
Git LFS Details
|
cfebe0f2-2e67-481b-a58e-31ef568b41e0.png
ADDED
Git LFS Details
|
d1193d14-d21c-4a72-b441-66b0ae9e9d85.png
ADDED
Git LFS Details
|
d52128b0-46ac-4e0b-85fa-6ba976a10c46.png
ADDED
Git LFS Details
|
dfea396a-2bd2-4a9a-bc72-5484800394fe.png
ADDED
Git LFS Details
|
e4aa925b-7224-4599-b046-53bce2b60838.png
ADDED
Git LFS Details
|
f10ddec3-f257-4a9f-aa69-31cfde3450f0.png
ADDED
Git LFS Details
|
metadata.jsonl
CHANGED
@@ -16,3 +16,40 @@
|
|
16 |
{"file_name": "971e49b9-8c03-4ef7-9f9b-7b79ad73c251.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
17 |
{"file_name": "4cfc2840-b1d8-48d7-9999-964f9b6b56db.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
18 |
{"file_name": "b10574d0-3cb1-441b-8c66-646a95c809d9.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
{"file_name": "971e49b9-8c03-4ef7-9f9b-7b79ad73c251.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
17 |
{"file_name": "4cfc2840-b1d8-48d7-9999-964f9b6b56db.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
18 |
{"file_name": "b10574d0-3cb1-441b-8c66-646a95c809d9.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
19 |
+
{"file_name": "6bdc8cec-1088-4fd4-b15a-aad803b655b6.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "# utils.py\r\n\r\nfrom playwright.sync_api import sync_playwright\r\nimport uuid\r\nfrom PIL import Image\r\nimport io\r\nfrom os import path\r\nimport json\r\n\r\n\r\ndef take_screenshot_from_url(url, session_data):\r\n with sync_playwright() as playwright:\r\n webkit = playwright.webkit\r\n browser = webkit.launch()\r\n browser_context = browser.new_context(device_scale_factor=2)\r\n browser_context.add_cookies([session_data])\r\n page = browser_context.new_page()\r\n page.goto(url)\r\n screenshot_bytes = page.locator(\".code\").screenshot()\r\n browser.close()\r\n return screenshot_bytes\r\n \r\n \r\ndef save_data(image_bytes: bytes, code: str) -> None:\r\n SYSTEM_MESSAGE: str = \"\"\"You are a helpful assistant that knows how to extract python code from images.\"\"\"\r\n USER_MESSAGE: str = \"\"\"Extract python code from the given image.\"\"\"\r\n file_name: str = str(uuid.uuid4())\r\n image: Image = Image.open(io.BytesIO(image_bytes))\r\n file_path: str = \"data-v1\"\r\n image_path: str = path.join(file_path, f\"{file_name}.png\")\r\n image.save(image_path)\r\n code_path: str = path.join(file_path, \"metadata.jsonl\")\r\n metadata: dict = {\r\n \"file_name\": f\"{file_name}.png\",\r\n \"messages\": [\r\n {\r\n \"role\": \"SYSTEM\",\r\n \"content\": SYSTEM_MESSAGE\r\n },\r\n { \"role\": \"USER\",\r\n \"content\": USER_MESSAGE\r\n },\r\n {\r\n \"role\": \"ASSISTANT\",\r\n \"content\": code\r\n }\r\n ]\r\n }\r\n print(metadata)\r\n with open(code_path, \"a+\", encoding=\"utf-8\") as f:\r\n f.write(json.dumps(metadata) + \"\\n\")"}]}
|
20 |
+
{"file_name": "8e114b65-14b6-4779-8e4a-6a1f4f0b31f5.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "import os\r\nfrom .config import Config\r\nfrom flask import Flask\r\n\r\n\r\ndef set_configuration(app: Flask):\r\n \"\"\"Set the application configuration.\r\n\r\n The application configuration will depend on the\r\n environment i.e Test, Development, Staging or Production.\r\n\r\n Parameters\r\n ----------\r\n app: flask.Flask\r\n A flask app instance\r\n\r\n Returns\r\n -------\r\n bool:\r\n Whether the config was set up successfully.\r\n \"\"\"\r\n config_name = os.environ.get(\"FLASK_ENV\")\r\n app.config.from_object(Config[config_name])\r\n\r\n return True"}]}
|
21 |
+
{"file_name": "a197717f-291a-4388-9a00-49aa5a0af549.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .set_config import set_configuration"}]}
|
22 |
+
{"file_name": "6409d577-ea9f-4658-9318-766a6d889e3a.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}]}
|
23 |
+
{"file_name": "732dbfdd-3209-4cdf-a2fc-6d8b3904dd93.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\"\"\"This module declares the app configuration.\r\n\r\nThe classes include:\r\n\r\nBaseConfig:\r\n Has all the configurations shared by all the environments.\r\n\r\n\"\"\"\r\nimport os\r\n\r\nfrom dotenv import load_dotenv\r\n\r\nload_dotenv()\r\n\r\n\r\nclass BaseConfig:\r\n \"\"\"Base configuration.\"\"\"\r\n\r\n DEBUG = True\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\r\n \"SECRET_KEY\", \"df0331cefc6c2b9a5d0208a726a5d1c0fd37324feba25506\"\r\n )\r\n\r\n\r\nclass DevelopmentConfig(BaseConfig):\r\n \"\"\"Development confuguration.\"\"\"\r\n\r\n DEBUG = True\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\r\n \"SECRET_KEY\", \"df0331cefc6c2b9a5d0208a726a5d1c0fd37324feba25506\"\r\n )\r\n\r\n\r\nclass TestingConfig(BaseConfig):\r\n \"\"\"Testing configuration.\"\"\"\r\n\r\n TESTING = True\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\nclass ProductionConfig(BaseConfig):\r\n \"\"\"Production configuration.\"\"\"\r\n\r\n TESTING = False\r\n SECRET_KEY = os.environ.get(\"SECRET_KEY\", \"secret-key\")\r\n\r\n\r\nConfig = {\r\n \"development\": DevelopmentConfig,\r\n \"test\": TestingConfig,\r\n \"production\": ProductionConfig,\r\n \"staging\": ProductionConfig,\r\n}\r\n"}]}
|
24 |
+
{"file_name": "d1193d14-d21c-4a72-b441-66b0ae9e9d85.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from flask import Flask\r\nfrom .home import code\r\n\r\n\r\ndef register_blueprints(app: Flask) -> bool:\r\n \"\"\"Register the application blueprints.\r\n\r\n Parameters\r\n ----------\r\n app: flask.Flask\r\n A flask app instance\r\n\r\n Returns\r\n -------\r\n bool:\r\n Whether all the blueprints were registered.\r\n \"\"\"\r\n app.register_blueprint(code)\r\n return True"}]}
|
25 |
+
{"file_name": "81292535-e2b3-46a2-98a7-cf3c5d84828d.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .register_blueprints import register_blueprints"}]}
|
26 |
+
{"file_name": "e4aa925b-7224-4599-b046-53bce2b60838.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .view import code"}]}
|
27 |
+
{"file_name": "0d7a8cad-0210-4d1e-bb62-db0dbe2049e4.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from selenium import webdriver\r\nfrom selenium.webdriver.common.keys import Keys\r\nfrom selenium.webdriver.common.by import By\r\nfrom selenium.webdriver.chrome.service import Service as ChromeService\r\nfrom webdriver_manager.chrome import ChromeDriverManager\r\nfrom selenium.webdriver.chrome.options import Options\r\ni\r\n\r\noptions = Options()\r\noptions.add_argument(\"--headless=new\")\r\ndriver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)\r\ndriver.get(\"https://leetcode.com/problems/remove-linked-list-elements\")\r\nparagraphs = driver.find_elements(By.TAG_NAME, \"p\")\r\nprint(paragraphs)\r\ndriver.quit()"}]}
|
28 |
+
{"file_name": "a5278a88-ac75-4d6c-9182-2bc36c03bd16.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from youtube import YouTube\r\nfrom youtube.models import Search\r\nfrom youtube.schemas import (\r\n YouTubeRequest, YouTubeListResponse, YouTubeResponse,\r\n SearchFilter, SearchOptionalParameters, SearchPart\r\n)\r\nfrom typing import Iterator\r\n\r\n\r\nclient_secrets_file = \"/home/lyle/oryks/backend/api/libraries/youtube.json\"\r\ndef get_youtube_client(client_secrets_file: str = client_secrets_file) -> YouTube:\r\n youtube: YouTube = YouTube(client_secret_file=client_secrets_file)\r\n client = youtube.authenticate()\r\n youtube.youtube_client = client\r\n return youtube\r\n\r\nyoutube: YouTube = get_youtube_client(client_secrets_file=\"/home/lyle/Downloads/test.json\")\r\n\r\n\r\n# query: str = ''\r\n# part: SearchPart = SearchPart()\r\n# optional_parameters: SearchOptionalParameters = SearchOptionalParameters(\r\n# q=query,\r\n# type=['video'],\r\n# channelId=\"UCtAcpQcYerN8xxZJYTfWBMw\"\r\n# )\r\n# search_request: YouTubeRequest = YouTubeRequest(\r\n# part=part, \r\n# optional_parameters=optional_parameters\r\n# )\r\n# search_results: YouTubeResponse = youtube.search(search_request)\r\n# search_iterator: Iterator = youtube.get_search_iterator(search_request)\r\n# # res: YouTubeResponse = youtube.find_channel_by_name(display_name=\"Umar Jamil\")\r\n# # print(res.items[0])\r\n# res = next(search_iterator)\r\n# final = []\r\n# for x in search_iterator:\r\n# for search in x:\r\n# final.append(\r\n# dict("}]}
|
29 |
+
{"file_name": "3293433e-19c9-4acc-985a-b7f376f0cf96.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}]}
|
30 |
+
{"file_name": "6ac702bc-c36b-461b-8de2-51da07b644cc.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": ""}]}
|
31 |
+
{"file_name": "458bda7f-d288-4c94-8cd7-b975f8ad35df.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from langchain_community.document_loaders.generic import GenericLoader\r\nfrom langchain_community.document_loaders.parsers import OpenAIWhisperParser\r\nfrom langchain_community.document_loaders.blob_loaders.youtube_audio import (\r\n YoutubeAudioLoader,\r\n)\r\nfrom langchain_core.documents import Document\r\nfrom os import path\r\n\r\n# Two Karpathy lecture videos\r\nurls = [\"https://www.youtube.com/watch?v=altvPR7x9IA\"]\r\n\r\n# Directory to save audio files\r\ndata_dir = \"data\"\r\nvideo_data_dir = \"video\"\r\ntranscribed_data = \"transcriptions\"\r\nvideo_title = \"sample\"\r\nsave_video_dir = path.join(data_dir, video_data_dir, video_title)\r\nsave_transcript_dir = path.join(data_dir, transcribed_data, video_title + \".txt\")\r\n\r\napi_key: str = \"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\"\r\n\r\nloader = GenericLoader(\r\n YoutubeAudioLoader(urls, save_video_dir), OpenAIWhisperParser(api_key=api_key)\r\n)\r\ndocs = loader.load()\r\n\r\nfull_transcript = \"\"\r\nfor doc in docs:\r\n full_transcript += doc.page_content\r\n\r\nwith open(save_transcript_dir, \"w\", encoding=\"utf-8\") as f:\r\n f.write(full_transcript)\r\n\r\nprint(full_transcript)\r\n\r\n\r\ndef transcribe_video(video_id: str, save_video_dir: str, api_key: str) -> str:\r\n url: str = f\"https://www.youtube.com/watch?v={video_id}\"\r\n loader: GenericLoader = GenericLoader(\r\n YoutubeAudioLoader([url], save_video_dir), OpenAIWhisperParser(api_key=api_key)"}]}
|
32 |
+
{"file_name": "540f7d82-c37c-4921-97b6-97dadbdeff26.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from dotenv import load_dotenv\r\nload_dotenv()\r\nfrom flask.cli import FlaskGroup\r\nfrom api import create_app\r\n\r\napp = create_app()\r\ncli = FlaskGroup(create_app=create_app)\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n cli()"}]}
|
33 |
+
{"file_name": "57ee718f-676a-4575-8253-6f2dbf6fb09d.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from dotenv import load_dotenv\r\nload_dotenv()\r\nfrom flask.cli import FlaskGroup\r\nfrom api import create_app\r\n\r\napp = create_app()\r\ncli = FlaskGroup(create_app=create_app)\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n cli()"}]}
|
34 |
+
{"file_name": "2144fdf3-12bc-44da-879f-1bdef98214a0.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "# Define here the models for your scraped items\r\n#\r\n# See documentation in:\r\n# https://docs.scrapy.org/en/latest/topics/items.html\r\n\r\nimport scrapy\r\n\r\n\r\nclass SlidesgoItem(scrapy.Item):\r\n # define the fields for your item here like:\r\n # name = scrapy.Field()\r\n pass\r\n"}]}
|
35 |
+
{"file_name": "086c78c8-2912-4660-bbf0-3a16e93d30cd.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "# Define your item pipelines here\r\n#\r\n# Don't forget to add your pipeline to the ITEM_PIPELINES setting\r\n# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html\r\n\r\n\r\n# useful for handling different item types with a single interface\r\nfrom itemadapter import ItemAdapter\r\n\r\n\r\nclass SlidesgoPipeline:\r\n def process_item(self, item, spider):\r\n return item\r\n"}]}
|
36 |
+
{"file_name": "cfebe0f2-2e67-481b-a58e-31ef568b41e0.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": ""}]}
|
37 |
+
{"file_name": "00b73ec1-e836-4233-adfc-41bd938dc645.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "# Define here the models for your spider middleware\r\n#\r\n# See documentation in:\r\n# https://docs.scrapy.org/en/latest/topics/spider-middleware.html\r\n\r\nfrom scrapy import signals\r\n\r\n# useful for handling different item types with a single interface\r\nfrom itemadapter import is_item, ItemAdapter\r\n\r\n\r\nclass SlidesgoSpiderMiddleware:\r\n # Not all methods need to be defined. If a method is not defined,\r\n # scrapy acts as if the spider middleware does not modify the\r\n # passed objects.\r\n\r\n @classmethod\r\n def from_crawler(cls, crawler):\r\n # This method is used by Scrapy to create your spiders.\r\n s = cls()\r\n crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)\r\n return s\r\n\r\n def process_spider_input(self, response, spider):\r\n # Called for each response that goes through the spider\r\n # middleware and into the spider.\r\n\r\n # Should return None or raise an exception.\r\n return None\r\n\r\n def process_spider_output(self, response, result, spider):\r\n # Called with the results returned from the Spider, after\r\n # it has processed the response.\r\n\r\n # Must return an iterable of Request, or item objects.\r\n for i in result:\r\n yield i\r\n\r\n def process_spider_exception(self, response, exception, spider):\r\n # Called when a spider or process_spider_input() method"}]}
|
38 |
+
{"file_name": "7f4d828e-b9e2-49f7-8050-2e4cae59e147.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from typing import Any\r\nfrom scrapy import Spider\r\nfrom scrapy.http import Response\r\nfrom scrapy.linkextractors import LinkExtractor \r\n\r\n\r\nclass SlidesLinkExtractor(Spider):\r\n name: str = \"links-extractor\"\r\n \r\n start_urls: list[str] = [\r\n \"https://slidesgo.com/\"\r\n ]\r\n \r\n def __init__(self, name=None, **kwargs): \r\n super().__init__(name, **kwargs) \r\n \r\n self.link_extractor = LinkExtractor(unique=True) \r\n \r\n def parse(self, response: Response, **kwargs: Any) -> Any: \r\n self.logger.info(\"Links spider\")\r\n links = response.css('li.w-1\\/2 a::attr(href)') \r\n \r\n for link in links: \r\n yield {\r\n \"url\": link.get(), \r\n }"}]}
|
39 |
+
{"file_name": "7e7a9a4d-72a4-4f7a-82b4-bfc45c798d6b.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "# This package will contain the spiders of your Scrapy project\r\n#\r\n# Please refer to the documentation for information on how to create and manage\r\n# your spiders.\r\n"}]}
|
40 |
+
{"file_name": "58cd394a-618d-4845-9ac2-471b88c1ed22.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from typing import Any\r\nfrom scrapy import Spider\r\nfrom scrapy.http import Response\r\nfrom scrapy import Request\r\n# from slidesmodel.items import SlidesModelItem\r\nfrom scrapy.loader import ItemLoader\r\nfrom scrapy.utils.project import get_project_settings\r\nimport json\r\n\r\n\r\nclass SlidesGospider(Spider):\r\n name: str = \"slides\"\r\n \r\n def __init__(self, name: str | None = None, **kwargs: Any):\r\n super().__init__(name, **kwargs)\r\n # self.start_urls: list[str] = self.load_start_urls()\r\n self.start_urls: list[str] = [\r\n \"https://slidesgo.com/food#rs=home\"\r\n ]\r\n \r\n \r\n def parse(self, response: Response, **kwargs: Any) -> Any:\r\n self.logger.info(\"This is my first spider.\")\r\n slide_links = response.css('div.theme_post a::attr(href)')\r\n for slide_link in slide_links:\r\n # title = problem_link.css('a::text')[0].get()\r\n link = slide_link.get()\r\n yield{\r\n \"link\": link,\r\n }\r\n # yield Request(link, callback=self.parse_problem)\r\n # for slide in slides:\r\n # loader: ItemLoader = ItemLoader(item=SlidesModelItem(), selector=slide)\r\n # loader.add_css(\"title\", \".item a::text\")\r\n # loader.add_css(\"category\", \".category::text\")\r\n # slide_item = loader.load_item()\r\n # link = slide.css(\".item a::attr(href)\").get()\r\n # self.logger.info(\"Parsing the slide\")\r\n # yield Request(link, callback=self.parse_slide, meta={\"slide_item\": slide_item})\r\n "}]}
|
41 |
+
{"file_name": "d52128b0-46ac-4e0b-85fa-6ba976a10c46.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "# This package will contain the spiders of your Scrapy project\r\n#\r\n# Please refer to the documentation for information on how to create and manage\r\n# your spiders.\r\n"}]}
|
42 |
+
{"file_name": "82c1ab23-9a5b-499e-a3ec-62e187cbbbde.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .view import home"}]}
|
43 |
+
{"file_name": "60cd02c7-5e46-4679-9e18-4ba4191bb1cc.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}]}
|
44 |
+
{"file_name": "487282f1-3b1b-4815-a53c-7d82cbfc20aa.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from flask import Blueprint, render_template\r\nfrom http import HTTPStatus\r\n\r\nhome = Blueprint(\"home\", __name__)\r\n\r\n\r\n@home.route(\"/\")\r\n@home.route(\"/home\")\r\n@home.route(\"/index\")\r\ndef home_page():\r\n \"\"\"Render the home page.\"\"\"\r\n return render_template(\"home/index.html\"), HTTPStatus.OK"}]}
|
45 |
+
{"file_name": "0ee621d6-12d8-4ba1-82e6-5ed1f60fa52b.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .view import auth, google_blueprint"}]}
|
46 |
+
{"file_name": "c0db2cc2-9ce6-49a7-8e1b-ac78a415db4a.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\"\"\"This module declares methods for the login module.\"\"\"\r\nimport sys\r\nimport os\r\nfrom dotenv import load_dotenv\r\nfrom flask import Blueprint, redirect, url_for\r\nfrom flask_dance.consumer import oauth_authorized\r\nfrom flask_dance.consumer.storage.sqla import SQLAlchemyStorage\r\nfrom flask_dance.contrib.google import google, make_google_blueprint\r\nfrom flask_login import current_user, login_required, login_user, logout_user\r\nfrom sqlalchemy.exc import OperationalError\r\nfrom sqlalchemy.orm.exc import NoResultFound\r\n\r\n\r\n# from ..extensions.extensions import db\r\n# from .models.models import OAuth, User\r\n\r\n\r\nauth = Blueprint(\"auth\", __name__)\r\n\r\n\r\ngoogle_blueprint = make_google_blueprint(\r\n client_id=os.environ[\"GOOGLE_OAUTH_CLIENT_ID\"],\r\n client_secret=os.environ[\"GOOGLE_OAUTH_CLIENT_SECRET\"],\r\n scope=[\"profile\", \"email\"]\r\n)\r\n"}]}
|
47 |
+
{"file_name": "7ae1d30d-179c-4f57-814a-401bbf3c9859.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from llama_index.embeddings.huggingface import HuggingFaceEmbedding\r\n\r\n# loads BAAI/bge-small-en\r\n# embed_model = HuggingFaceEmbedding()\r\n\r\n# loads BAAI/bge-small-en-v1.5\r\nembed_model = HuggingFaceEmbedding(model_name=\"BAAI/bge-small-en-v1.5\")\r\n\r\nembeddings = embed_model.get_text_embedding(\"Hello World!\")\r\nprint(len(embeddings))\r\nprint(embeddings[:5])"}]}
|
48 |
+
{"file_name": "ca2964e8-306b-417e-bf64-88c52768157e.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "import torch\r\nimport open_clip\r\nimport cv2\r\nfrom sentence_transformers import util\r\nfrom PIL import Image\r\n\r\n# image processing model\r\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\r\nmodel, _, preprocess = open_clip.create_model_and_transforms('ViT-B-16-plus-240', \r\n pretrained=\"laion400m_e32\")\r\nmodel.to(device)\r\n\r\n\r\ndef imageEncoder(img):\r\n img1 = Image.fromarray(img).convert('RGB')\r\n img1 = preprocess(img1).unsqueeze(0).to(device)\r\n img1 = model.encode_image(img1)\r\n return img1\r\n\r\n\r\ndef generateScore(image1, image2):\r\n test_img = cv2.imread(image1, cv2.IMREAD_UNCHANGED)\r\n data_img = cv2.imread(image2, cv2.IMREAD_UNCHANGED)\r\n img1 = imageEncoder(test_img)\r\n img2 = imageEncoder(data_img)\r\n cos_scores = util.pytorch_cos_sim(img1, img2)\r\n score = round(float(cos_scores[0][0])*100, 2)\r\n return score\r\n\r\n\r\nimage1: str = \"cat.jpeg\"\r\nimage2: str = \"cat2.jpeg\"\r\n\r\nprint(f\"similarity Score: \", round(generateScore(image1, image2), 2))"}]}
|
49 |
+
{"file_name": "6845b982-29c4-4b53-b2d5-31d7bfe71602.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "import whisper\r\nimport speech_recognition as sr\r\n\r\n\r\n# model = whisper.load_model(\"base\")\r\nfile_path: str = \"audio.wav\"\r\n# result = model.transcribe(file_path)\r\n# print(f' The text in video: \\n {result[\"text\"]}')\r\ndef audio_to_text(audio_path):\r\n \"\"\"\r\n Convert an audio file to text.\r\n\r\n Parameters:\r\n audio_path (str): The path to the audio file.\r\n\r\n Returns:\r\n test (str): The text recognized from the audio.\r\n\r\n \"\"\"\r\n recognizer = sr.Recognizer()\r\n audio = sr.AudioFile(audio_path)\r\n\r\n with audio as source:\r\n # Record the audio data\r\n audio_data = recognizer.record(source)\r\n\r\n try:\r\n # Recognize the speech\r\n text = recognizer.recognize_whisper(audio_data)\r\n except sr.UnknownValueError:\r\n print(\"Speech recognition could not understand the audio.\")\r\n except sr.RequestError as e:\r\n print(f\"Could not request results from service; {e}\")\r\n\r\n return text\r\n\r\ntext = audio_to_text(file_path)\r\nprint(text)"}]}
|
50 |
+
{"file_name": "f10ddec3-f257-4a9f-aa69-31cfde3450f0.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "import torch\r\nimport clip\r\nfrom PIL import Image\r\n\r\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\r\nmodel, preprocess = clip.load(\"ViT-B/32\", device=device)\r\n\r\nimage = preprocess(Image.open(\"cat.jpeg\")).unsqueeze(0).to(device)\r\nlabels: list[str] = [\"a diagram\", \"a dog\", \"a cat\"]\r\ntext = clip.tokenize(labels).to(device)\r\n\r\nwith torch.no_grad():\r\n image_features = model.encode_image(image)\r\n text_features = model.encode_text(text)\r\n \r\n logits_per_image, logits_per_text = model(image, text)\r\n probs = logits_per_image.softmax(dim=-1).cpu().numpy()\r\n\r\nprint(\"Label probs:\", probs) # prints: [[0.9927937 0.00421068 0.00299572]]\r\nprint(labels[probs.argmax(-1)[0]])\r\n"}]}
|
51 |
+
{"file_name": "ab37af6c-621b-48e6-8b41-36699498ca0f.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}]}
|
52 |
+
{"file_name": "78f04ae2-fedd-4232-8088-eeb68cb81bcd.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .....libraries.youtube import YouTube"}]}
|
53 |
+
{"file_name": "cb9da896-520c-4c7d-93a6-0cd604cf98f4.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from collections import defaultdict\r\nfrom typing import Any\r\n\r\nfrom googleapiclient.http import MediaFileUpload\r\n\r\nfrom ...models import (\r\n BaseContentDetails,\r\n BaseSnippet,\r\n Language,\r\n LanguageSnippet,\r\n Region,\r\n RegionSnippet,\r\n Video,\r\n VideoAbuseReportReason,\r\n VideoAbuseReportReasonSnippet,\r\n VideoCategory,\r\n VideoCategorySnippet,\r\n)\r\nfrom ...schemas import (\r\n UploadVideo,\r\n VideoFilter,\r\n VideoOptionalParameters,\r\n VideoPart,\r\n VideoReportReasonSchema,\r\n YouTubeListResponse,\r\n YouTubeRatingResponse,\r\n YouTubeRequest,\r\n)\r\nfrom ..resource import YouTubeResource\r\n\r\n\r\nclass YouTubeVideo(YouTubeResource):\r\n def __init__(self, youtube_client: Any) -> None:\r\n super().__init__(youtube_client)\r\n\r\n def parse_snippet(self, snippet_data: dict[str, Any]) -> dict[str, Any]:\r\n base_snippet: BaseSnippet = self.parse_base_snippet(snippet_data)\r\n parsed_snippet: dict[str, Any] = base_snippet.model_dump()\r\n parsed_snippet['channel_id'] = snippet_data['channelId']\r\n parsed_snippet['channel_title'] = snippet_data['channelTitle']"}]}
|
54 |
+
{"file_name": "dfea396a-2bd2-4a9a-bc72-5484800394fe.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from .video import YouTubeVideo\r\n"}]}
|
55 |
+
{"file_name": "aacd3a6d-68f8-4041-9b75-a06962a8acb8.png", "messages": [{"role": "SYSTEM", "content": "You are a helpful assistant that knows how to extract python code from images."}, {"role": "USER", "content": "Extract python code from the given image."}, {"role": "ASSISTANT", "content": "from typing import Any\r\n\r\nfrom ...models import (\r\n Channel,\r\n ChannelContentDetails,\r\n ChannelSnippet,\r\n ChannelStatistics,\r\n ChannelStatus,\r\n)\r\nfrom ...schemas import (\r\n ChannelFilter,\r\n ChannelOptionalParameters,\r\n ChannelPart,\r\n YouTubeListResponse,\r\n YouTubeRequest,\r\n)\r\nfrom ..resource import YouTubeResource\r\n\r\n\r\nclass YouTubeChannel(YouTubeResource):\r\n def __init__(self, youtube_client: Any) -> None:\r\n super().__init__(youtube_client)\r\n\r\n def parse_snippet(self, snippet_data: dict[str, Any]) -> ChannelSnippet:\r\n snippet: dict = dict(**self.parse_base_snippet(snippet_data).model_dump())\r\n snippet['custom_url'] = snippet_data['customUrl']\r\n snippet['country'] = snippet_data.get('country', '')\r\n snippet['localized'] = self.parse_localizations(snippet_data['localized'])\r\n return ChannelSnippet(**snippet)\r\n\r\n def parse_content_details(\r\n self, content_details_data: dict\r\n ) -> ChannelContentDetails:\r\n content_details: dict = dict(\r\n **self.parse_base_content_details(content_details_data).model_dump()\r\n )\r\n content_details['related_playlists'] = content_details_data['relatedPlaylists']\r\n return ChannelContentDetails(**content_details)\r\n\r\n def parse_statistics(self, statistics_data: dict) -> ChannelStatistics:"}]}
|