image
imagewidth (px)
1.28k
4.48k
messages
listlengths
3
3
[ { "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" } ]
[ { "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": "def generate_class_docstring(class_code: str, config: Config) -> str:\r\n prompt_formatted_str: str = get_class_prompt_template(\r\n class_code=class_code, config=config\r\n )\r\n class_and_docstring = llm.invoke(prompt_formatted_str)\r\n return class_and_docstring\r\n\r\n\r\ndef get_class_docstring(class_and_docstring: str) -> str:\r\n \"\"\"Get the class docstring.\"\"\"\r\n class_tree = ast.parse(class_and_docstring)\r\n for node in class_tree.body:\r\n if isinstance(node, ClassDef):\r\n cls_docstring: str = ast.get_docstring(node)\r\n return cls_docstring" } ]
[ { "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 ...agent import State\r\nfrom ..get_apartment_listings import GetApartmentListings\r\n\r\n\r\nclass GetApartmentDescription(State):\r\n def execute(self) -> None:\r\n self.agent.ui.get_apartment_description()\r\n self.agent.transition_to(GetApartmentListings())\r\n" } ]
[ { "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']" } ]
[ { "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(" } ]
[ { "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" } ]
[ { "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": "" } ]
[ { "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" } ]
[ { "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 setuptools import find_packages, setup\r\nfrom pip._vendor import tomli\r\n\r\n# For consistent encoding\r\nfrom codecs import open\r\nfrom os import path\r\n\r\n# The directory containing this file\r\nHERE = path.abspath(path.dirname(__file__))\r\n\r\n# Get the long description from the README file\r\nwith open(path.join(HERE, 'README.md'), encoding='utf-8') as f:\r\n LONG_DESCRIPTION = f.read()\r\n\r\nwith open('pyproject.toml', 'r') as f:\r\n VERSION = tomli.load(f)['tool']['commitizen']['version']\r\n\r\nDESCRIPTION = 'A python library for working with Google Drive.'\r\n\r\nkey_words = [\r\n 'drive', 'google-drive', 'google-drive-api', 'upload files to Google Drive',\r\n]\r\n\r\ninstall_requires = [\r\n 'oryks-google-oauth',\r\n 'pydantic',\r\n 'pydantic-settings'\r\n]\r\n\r\nsetup(\r\n name='oryks-google-drive',\r\n packages=find_packages(\r\n include=[\r\n 'google_drive',\r\n 'google_drive.exceptions',\r\n 'google_drive.models',\r\n 'google_drive.schemas',\r\n 'google_drive.resources'\r\n ]\r\n )," } ]
[ { "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" } ]
[ { "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" } ]
[ { "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 setuptools import find_packages, setup\r\nfrom pip._vendor import tomli\r\n\r\n# For consistent encoding\r\nfrom codecs import open\r\nfrom os import path\r\n\r\n# The directory containing this file\r\nHERE = path.abspath(path.dirname(__file__))\r\n\r\n# Get the long description from the README file\r\nwith open(path.join(HERE, 'README.md'), encoding='utf-8') as f:\r\n LONG_DESCRIPTION = f.read()\r\n\r\nwith open('pyproject.toml', 'r') as f:\r\n VERSION = tomli.load(f)['tool']['commitizen']['version']\r\n\r\nDESCRIPTION = 'A python library for working with Google Drive.'\r\n\r\nkey_words = [\r\n 'drive', 'google-drive', 'google-drive-api', 'upload files to Google Drive',\r\n]\r\n\r\ninstall_requires = [\r\n 'oryks-google-oauth',\r\n 'pydantic',\r\n 'pydantic-settings'\r\n]\r\n\r\nsetup(\r\n name='oryks-google-drive',\r\n packages=find_packages(\r\n include=[\r\n 'google_drive',\r\n 'google_drive.exceptions',\r\n 'google_drive.models',\r\n 'google_drive.schemas',\r\n 'google_drive.resources'\r\n ]\r\n )," } ]
[ { "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" } ]
[ { "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": "# Streamlit application for New York Housing Market Explorer\r\n\r\n# Required imports\r\nimport streamlit as st\r\nimport pandas as pd\r\nfrom llama_index import SimpleDirectoryReader, ServiceContext, StorageContext, VectorStoreIndex\r\nfrom llama_index.llms import OpenAI\r\nfrom llama_index.embeddings import FastEmbedEmbedding\r\nfrom qdrant_client import QdrantClient\r\nimport json\r\nimport os\r\nfrom sqlalchemy import create_engine\r\nfrom llama_index import SQLDatabase, ServiceContext\r\nfrom llama_index.indices.struct_store import NLSQLTableQueryEngine\r\nfrom pathlib import Path\r\nfrom llama_index.vector_stores.qdrant import QdrantVectorStore\r\nfrom llama_index.query_engine import (\r\n SQLAutoVectorQueryEngine,\r\n RetrieverQueryEngine,\r\n)\r\nfrom llama_index.tools.query_engine import QueryEngineTool\r\nfrom llama_index.indices.vector_store import VectorIndexAutoRetriever\r\n\r\nfrom llama_index.indices.vector_store.retrievers import (\r\n VectorIndexAutoRetriever,\r\n)\r\nfrom llama_index.vector_stores.types import MetadataInfo, VectorStoreInfo\r\nfrom llama_index.query_engine.retriever_query_engine import (\r\n RetrieverQueryEngine,\r\n)\r\nfrom dotenv import load_dotenv\r\nload_dotenv()\r\n\r\n\r\nst.set_page_config(layout=\"wide\")\r\nwrite_dir = Path(\"textdata\")\r\n\r\n# Initialize Qdrant client\r\nclient = QdrantClient(\r\n url=os.environ['QDRANT_URL'], " } ]
[ { "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()" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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.cli import FlaskGroup\r\nfrom api.helpers.data import create_data\r\nfrom api import create_app, db\r\n\r\napp = create_app()\r\ncli = FlaskGroup(create_app=create_app)\r\n\r\n\r\n@cli.command(\"create_db\")\r\ndef create_db():\r\n \"\"\"Create the database and all the tables.\"\"\"\r\n db.drop_all()\r\n db.create_all()\r\n db.session.commit()\r\n \r\n@cli.command(\"seed_db\")\r\ndef seed_db():\r\n \"\"\"Create the initial data.\"\"\"\r\n create_data()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n cli()\r\n" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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 pydantic_settings import BaseSettings\r\nfrom dotenv import load_dotenv\r\n\r\n\r\nload_dotenv()\r\n\r\n\r\nclass Config(BaseSettings):\r\n secret_file: str" } ]
[ { "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 setuptools import find_packages, setup\r\nfrom pip._vendor import tomli\r\n\r\n# For consistent encoding\r\nfrom codecs import open\r\nfrom os import path\r\n\r\n# The directory containing this file\r\nHERE = path.abspath(path.dirname(__file__))\r\n\r\n# Get the long description from the README file\r\nwith open(path.join(HERE, 'README.md'), encoding='utf-8') as f:\r\n LONG_DESCRIPTION = f.read()\r\n\r\nwith open('pyproject.toml', 'r') as f:\r\n VERSION = tomli.load(f)['tool']['commitizen']['version']\r\n\r\nDESCRIPTION = 'A python library for working with Google Drive.'\r\n\r\nkey_words = [\r\n 'drive', 'google-drive', 'google-drive-api', 'upload files to Google Drive',\r\n]\r\n\r\ninstall_requires = [\r\n 'oryks-google-oauth',\r\n 'pydantic',\r\n 'pydantic-settings'\r\n]\r\n\r\nsetup(\r\n name='oryks-google-drive',\r\n packages=find_packages(\r\n include=[\r\n 'google_drive',\r\n 'google_drive.exceptions',\r\n 'google_drive.models',\r\n 'google_drive.schemas',\r\n 'google_drive.resources'\r\n ]\r\n )," } ]
[ { "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 elasticsearch import Elasticsearch\r\nfrom elastic_transport import ApiError\r\nfrom .....config.logger_config import app_logger\r\n\r\ndef create_channel_index(es_client: Elasticsearch, channels_index: str = 'channels') -> None:\r\n body = {\r\n 'mappings': {\r\n 'properties': {\r\n 'channel_id': {'type': 'keyword'},\r\n 'channel_title': {\r\n 'type': 'text',\r\n 'fields': {\r\n 'raw': {\r\n 'type': 'keyword'\r\n }\r\n }\r\n },\r\n 'published_at': {'type': 'date'},\r\n 'custom_url': {'type': 'keyword'},\r\n 'channel_description': {'type': 'text'},\r\n 'channel_thumbnail': {'type': 'keyword'},\r\n 'views_count': {'type': 'long'},\r\n 'videos_count': {'type': 'long'},\r\n 'subscribers_count': {'type': 'long'}\r\n }\r\n }\r\n }\r\n try:\r\n es_client.indices.delete(index=channels_index, ignore=[400, 404])\r\n es_client.indices.create(index=channels_index, body=body)\r\n except ApiError:\r\n app_logger.error(f\"Unable to create index '{channels_index}'.\")\r\n else:\r\n app_logger.info(f\"Index '{channels_index}' created succsefully.\")\r\n " } ]
[ { "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" } ]
[ { "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 pymongo import MongoClient\r\n\r\ndef test_mongo_connection():\r\n try:\r\n # Create a MongoDB client\r\n client = MongoClient(\"mongodb://root:yourpassword@localhost:27017/\")\r\n \r\n # Get the database instance\r\n db = client.yourdbname\r\n\r\n # Create a new collection or get the existing collection\r\n collection = db.test_collection\r\n\r\n # Insert a new document\r\n result = collection.insert_one({\"message\": \"Hello, MongoDB!\"})\r\n \r\n # Retrieve the inserted document\r\n retrieved_document = collection.find_one({\"_id\": result.inserted_id})\r\n \r\n print(\"Document inserted successfully:\")\r\n print(retrieved_document)\r\n \r\n # Close the connection\r\n client.close()\r\n\r\n except Exception as e:\r\n print(f\"An error occurred: {e}\")\r\n\r\nif __name__ == \"__main__\":\r\n test_mongo_connection()\r\n\r\n" } ]
[ { "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\r\nimport os\r\n\r\n\r\nclient_secret_file: str = os.environ['CLIENT_SECRET']\r\nclient_secret_file: str = '/home/lyle/Downloads/client_secret.json'\r\ncredentials_file: str = os.environ['CREDENTIALS_FILE']\r\nyoutube: YouTube = YouTube(client_secret_file=client_secret_file)\r\nyoutube.authenticate()\r\n# youtube.authenticate_from_credentaisl(credentials_file)\r\n" } ]
[ { "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": "" } ]
[ { "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 assistant.agents import default_agent\r\nimport chainlit as cl\r\n\r\n\r\n@cl.on_chat_start\r\nasync def start():\r\n cl.user_session.set('agent', default_agent)\r\n\r\n\r\n@cl.on_message\r\nasync def main(message: cl.Message):\r\n agent = cl.user_session.get('agent')\r\n msg = cl.Message(content='')\r\n await msg.send()\r\n await cl.sleep(1)\r\n msg.content = agent.invoke({'input': message.content})['output']\r\n await msg.update()\r\n" } ]
[ { "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": "" } ]
[ { "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 contextlib import contextmanager\r\n\r\nfrom flask import current_app\r\nfrom sqlalchemy import create_engine\r\nfrom sqlalchemy.orm import DeclarativeBase, MappedAsDataclass, sessionmaker\r\n\r\nfrom ...config.config import BaseConfig\r\n\r\n\r\nclass Base(MappedAsDataclass, DeclarativeBase):\r\n pass\r\n\r\n\r\nSQLALCHEMY_DATABASE_URI = BaseConfig().db_conn_string\r\nengine = create_engine(SQLALCHEMY_DATABASE_URI)\r\nSession = sessionmaker(bind=engine, autocommit=False, autoflush=False)\r\n\r\n\r\ndef create_all():\r\n Base.metadata.create_all(bind=engine)\r\n\r\n\r\ndef drop_all():\r\n Base.metadata.drop_all(bind=engine)\r\n\r\n\r\n@contextmanager\r\ndef get_db():\r\n try:\r\n db = Session()\r\n yield db\r\n finally:\r\n db.close()\r\n" } ]
[ { "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": "" } ]
[ { "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:" } ]
[ { "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": "\"\"\"The Apple Framework builds require their own customization.\"\"\"\r\nfrom __future__ import annotations\r\n\r\nimport logging\r\nimport os\r\nimport struct\r\nimport subprocess\r\nfrom abc import ABCMeta, abstractmethod\r\nfrom pathlib import Path\r\nfrom textwrap import dedent\r\n\r\nfrom virtualenv.create.via_global_ref.builtin.ref import (\r\n ExePathRefToDest,\r\n PathRefToDest,\r\n RefMust,\r\n)\r\n\r\nfrom .common import CPython, CPythonPosix, is_mac_os_framework\r\nfrom .cpython3 import CPython3\r\n\r\n\r\nclass CPythonmacOsFramework(CPython, metaclass=ABCMeta):\r\n @classmethod\r\n def can_describe(cls, interpreter):\r\n return is_mac_os_framework(interpreter) and super().can_describe(interpreter)\r\n\r\n def create(self):\r\n super().create()\r\n\r\n # change the install_name of the copied python executables\r\n target = self.desired_mach_o_image_path()\r\n current = self.current_mach_o_image_path()\r\n for src in self._sources:\r\n if isinstance(src, ExePathRefToDest) and (src.must == RefMust.COPY or not self.symlinks):\r\n exes = [self.bin_dir / src.base]\r\n if not self.symlinks:\r\n exes.extend(self.bin_dir / a for a in src.aliases)\r\n for exe in exes:\r\n fix_mach_o(str(exe), current, target, self.interpreter.max_size)\r\n" } ]
[ { "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": "" } ]
[ { "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()" } ]
[ { "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 contains routes for the app.\"\"\"\r\nfrom flask import Blueprint, render_template, jsonify, url_for, request\r\nfrom flask_login import current_user, login_required\r\nfrom ..post.models.post_model import Post\r\nfrom datetime import datetime\r\nfrom .controller.home import handle_befriend\r\n\r\nfrom ..utils.http_status_codes import HTTP_200_OK\r\nfrom .controller.home import handle_load_posts\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\n@login_required\r\ndef home_page():\r\n \"\"\"Render the home page.\"\"\"\r\n return handle_load_posts()\r\n\r\n@home.route(\"/befriend\")\r\ndef befriend():\r\n \"\"\"Render the home page.\"\"\"\r\n return handle_befriend(request.args)\r\n\r\n@home.route(\"/unfriend\")\r\ndef unfriend():\r\n \"\"\"Render the home page.\"\"\"\r\n return jsonify({'success': 'unfriend'}), HTTP_200_OK" } ]
[ { "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": "# -*- coding: utf-8 -*-\r\nfrom __future__ import unicode_literals\r\n\r\nimport logging\r\n\r\nfrom oauthlib.common import extract_params\r\nfrom oauthlib.oauth1 import Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER\r\nfrom oauthlib.oauth1 import SIGNATURE_TYPE_BODY\r\nfrom requests.compat import is_py3\r\nfrom requests.utils import to_native_string\r\nfrom requests.auth import AuthBase\r\n\r\nCONTENT_TYPE_FORM_URLENCODED = \"application/x-www-form-urlencoded\"\r\nCONTENT_TYPE_MULTI_PART = \"multipart/form-data\"\r\n\r\nif is_py3:\r\n unicode = str\r\n\r\nlog = logging.getLogger(__name__)\r\n\r\n# OBS!: Correct signing of requests are conditional on invoking OAuth1\r\n# as the last step of preparing a request, or at least having the\r\n# content-type set properly.\r\nclass OAuth1(AuthBase):\r\n \"\"\"Signs the request using OAuth 1 (RFC5849)\"\"\"\r\n\r\n client_class = Client\r\n\r\n def __init__(\r\n self,\r\n client_key,\r\n client_secret=None,\r\n resource_owner_key=None,\r\n resource_owner_secret=None,\r\n callback_uri=None,\r\n signature_method=SIGNATURE_HMAC,\r\n signature_type=SIGNATURE_TYPE_AUTH_HEADER,\r\n rsa_key=None,\r\n verifier=None,\r\n decoding=\"utf-8\"," } ]
[ { "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 api import create_app\r\nfrom api.extensions.extensions import celery\r\n\r\napp = create_app()" } ]
[ { "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" } ]
[ { "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\r\n\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 'Home page'" } ]
[ { "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 ..resource import YouTubeResource\r\nfrom ..schemas import (\r\n YouTubeRequest, YouTubeResponse, CommentThreadFilter, CommentThreadOptionalParameters,\r\n CommentThreadPart\r\n)\r\nfrom ...models import CommentThread, Comment\r\nfrom datetime import datetime\r\n\r\n\r\nclass YouTubeCommentThread(YouTubeResource):\r\n def __init__(self, youtube_client: Any) -> None:\r\n super().__init__(youtube_client)\r\n \r\n def generate_optional_parameters(self, optional_params: CommentThreadOptionalParameters) -> dict:\r\n optional: dict = dict()\r\n for key, value in optional_params.model_dump().items():\r\n if value:\r\n optional[key] = value\r\n return optional\r\n \r\n def generate_filter(self, f: CommentThreadFilter) -> dict:\r\n comment_filter: dict = dict()\r\n for key, value in f.model_dump().items():\r\n if value:\r\n comment_filter[key] = value\r\n break\r\n return comment_filter\r\n \r\n def create_request_dict(self, search_schema: YouTubeRequest) -> dict[str, int|str|datetime]:\r\n request_dict: dict[str, int|str|datetime] = dict()\r\n request_dict['part'] = self.generate_part(search_schema.part)\r\n request_dict.update(self.generate_optional_parameters(search_schema.optional_parameters))\r\n request_dict.update(self.generate_filter(search_schema.filter))\r\n return request_dict\r\n \r\n def find_video_comments(self, request: YouTubeRequest) -> YouTubeResponse:\r\n \"\"\"Get a particular video's comments.\"\"\"\r\n comment_thread_req = self.youtube_client.commentThreads().list(\r\n **self.create_request_dict(request)" } ]
[ { "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 ..resource import YouTubeResource\r\nfrom typing import Any\r\nfrom ...models import ChannelSection\r\nfrom ..schemas import (\r\n YouTubeListResponse, YouTubeRequest, YouTubeResponse, ChannelSectionFilter,\r\n ChannelSectionPart, ChannelSectionOptionalParameters, InsertChannelSection\r\n)\r\n\r\n\r\nclass YouTubeChannelSection(YouTubeResource):\r\n def __init__(self, youtube_client: Any) -> None:\r\n super().__init__(youtube_client)\r\n \r\n def list_my_channel_sections(self) -> YouTubeListResponse:\r\n part: ChannelSectionPart = ChannelSectionPart()\r\n filter: ChannelSectionFilter = ChannelSectionFilter(\r\n mine=True\r\n )\r\n optional: ChannelSectionOptionalParameters = ChannelSectionOptionalParameters()\r\n request: YouTubeRequest = YouTubeRequest(\r\n part=part,\r\n filter=filter,\r\n optional_parameters=optional\r\n )\r\n channel_section_request = self.youtube_client.channelSections().list(\r\n **self.create_request_dict(request) \r\n )\r\n channel_section_response = channel_section_request.execute()\r\n return channel_section_response\r\n \r\n def list_channel_sections(self, channel_id: str) -> YouTubeListResponse:\r\n part: ChannelSectionPart = ChannelSectionPart()\r\n filter: ChannelSectionFilter = ChannelSectionFilter(\r\n channelId=channel_id\r\n )\r\n optional: ChannelSectionOptionalParameters = ChannelSectionOptionalParameters()\r\n request: YouTubeRequest = YouTubeRequest(\r\n part=part,\r\n filter=filter,\r\n optional_parameters=optional" } ]
[ { "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": "" } ]
[ { "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 dotenv import load_dotenv\r\nfrom rich.prompt import Prompt\r\nfrom src.utils.display import (\r\n display_intro,\r\n select_number_of_posts,\r\n select_topic,\r\n select_search_queries,\r\n)\r\nfrom src.utils.agent import Agent\r\nfrom src.utils.document_loader import RedditSubLoader, TwitterTweetLoader\r\n\r\nload_dotenv()\r\n\r\n\r\ndef main():\r\n display_intro()\r\n topic = select_topic()\r\n platform, keywords, accounts = select_search_queries(topic)\r\n number_of_posts = select_number_of_posts()\r\n\r\n if platform == \"reddit\":\r\n document_loader = RedditSubLoader(\r\n number_submissions=number_of_posts,\r\n keywords=keywords,\r\n subreddits=accounts,\r\n )\r\n elif platform == \"twitter\":\r\n document_loader = TwitterTweetLoader.from_bearer_token(\r\n oauth2_bearer_token=os.environ.get(\"TWITTER_BEARER_TOKEN\"),\r\n number_tweets=number_of_posts,\r\n twitter_users=accounts,\r\n keywords=keywords,\r\n )\r\n else:\r\n raise ValueError(f\"Platform {platform} not supported\")\r\n\r\n agent = Agent(loader=document_loader)\r\n\r\n agent.load_documents()" } ]
[ { "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" } ]
[ { "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 pydantic import BaseSettings\r\n\r\n\r\nclass Settings(BaseSettings):\r\n mongodb_uri: str\r\n mongodb_database: str\r\n\r\n\r\nsettings = Settings()\r\n" } ]
[ { "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 logging\r\nimport click\r\nfrom rich.logging import RichHandler\r\n\r\n\r\nLOGGER_NAME = \"reddit\"\r\nlogging.basicConfig(\r\n level=logging.INFO,\r\n format=\"%(asctime)s:%(levelname)s:%(name)s:%(message)s\",\r\n handlers=[RichHandler(rich_tracebacks=True, tracebacks_suppress=[click])],\r\n)\r\nlogger = logging.getLogger(LOGGER_NAME)\r\n\r\n\r\nlogging.getLogger(\"clickhouse_connect\").setLevel(logging.ERROR)\r\nlogging.getLogger(\"clickhouse_connect\").setLevel(logging.ERROR)\r\nlogging.getLogger(\"numexpr\").setLevel(logging.ERROR)\r\n" } ]
[ { "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" } ]
[ { "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 .google_drive import GoogleDrive\r\n" } ]
[ { "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": "" } ]
[ { "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 __future__ import annotations\r\n\r\nimport abc\r\nimport fnmatch\r\nfrom itertools import chain\r\nfrom operator import methodcaller as method\r\nfrom pathlib import Path\r\nfrom textwrap import dedent\r\n\r\nfrom virtualenv.create.describe import Python3Supports\r\nfrom virtualenv.create.via_global_ref.builtin.ref import PathRefToDest\r\nfrom virtualenv.create.via_global_ref.store import is_store_python\r\n\r\nfrom .common import CPython, CPythonPosix, CPythonWindows, is_mac_os_framework\r\n\r\n\r\nclass CPython3(CPython, Python3Supports, metaclass=abc.ABCMeta):\r\n \"\"\"CPython 3 or later.\"\"\"\r\n\r\n\r\nclass CPython3Posix(CPythonPosix, CPython3):\r\n @classmethod\r\n def can_describe(cls, interpreter):\r\n return is_mac_os_framework(interpreter) is False and super().can_describe(interpreter)\r\n\r\n def env_patch_text(self):\r\n text = super().env_patch_text()\r\n if self.pyvenv_launch_patch_active(self.interpreter):\r\n text += dedent(\r\n \"\"\"\r\n # for https://github.com/python/cpython/pull/9516, see https://github.com/pypa/virtualenv/issues/1704\r\n import os\r\n if \"__PYVENV_LAUNCHER__\" in os.environ:\r\n del os.environ[\"__PYVENV_LAUNCHER__\"]\r\n \"\"\",\r\n )\r\n return text\r\n\r\n @classmethod\r\n def pyvenv_launch_patch_active(cls, interpreter):" } ]
[ { "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": "#!/bin/python3\r\n\r\n# $Id: rst2latex.py 9115 2022-07-28 17:06:24Z milde $\r\n# Author: David Goodger <goodger@python.org>\r\n# Copyright: This module has been placed in the public domain.\r\n\r\n\"\"\"\r\nA minimal front end to the Docutils Publisher, producing LaTeX.\r\n\"\"\"\r\n\r\ntry:\r\n import locale\r\n locale.setlocale(locale.LC_ALL, '')\r\nexcept Exception:\r\n pass\r\n\r\nfrom docutils.core import publish_cmdline\r\n\r\ndescription = ('Generates LaTeX documents from standalone reStructuredText '\r\n 'sources. '\r\n 'Reads from <source> (default is stdin) and writes to '\r\n '<destination> (default is stdout). See '\r\n '<https://docutils.sourceforge.io/docs/user/latex.html> for '\r\n 'the full reference.')\r\n\r\npublish_cmdline(writer_name='latex', description=description)\r\n" } ]
[ { "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, Optional\r\n\r\nfrom oryks_google_oauth import GoogleDriveScopes, GoogleOAuth\r\nfrom pydantic import BaseModel\r\n\r\n\r\nclass GoogleDrive(BaseModel):\r\n \"\"\"Provides methods for interacting with the Drive API.\r\n\r\n This class acts as an interface to the Drive API, providing methods for interacting with\r\n the Drive API.\r\n\r\n Attributes\r\n ----------\r\n client_secret_file: str\r\n The path to the json file containing your authentication information.\r\n \"\"\"\r\n\r\n client_secret_file: Optional[str] = None\r\n authenticated: Optional[bool] = False\r\n drive_client: Optional[Any] = None\r\n\r\n def authenticate(self, client_secret_file: Optional[str] = None) -> None:\r\n \"\"\"Authenticate the requests made to drive.\r\n\r\n Used to generate the credentials that are used when authenticating requests to drive.\r\n\r\n Parameters\r\n ----------\r\n client_secret_file: str\r\n The path to clients secret json file from Google\r\n\r\n Raises\r\n ------\r\n ValueError:\r\n When the client secrets file is not provided\r\n FileNotFoundError:\r\n When the secrets file path is not found\r\n \"\"\"\r\n if client_secret_file:" } ]
[ { "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 assistant.agents import default_agent\r\nimport chainlit as cl\r\n\r\n\r\n@cl.on_chat_start\r\nasync def start():\r\n cl.user_session.set('agent', default_agent)\r\n\r\n\r\n@cl.on_message\r\nasync def main(message: cl.Message):\r\n agent = cl.user_session.get('agent')\r\n msg = cl.Message(content='')\r\n await msg.send()\r\n await cl.sleep(1)\r\n msg.content = agent.invoke({'input': message.content})['output']\r\n await msg.update()\r\n" } ]
[ { "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 ...post.models.post_model import Post\r\nfrom ...post.models.like_model import Like\r\nfrom ...post.models.comment_model import Comment\r\nfrom flask import url_for, render_template, jsonify\r\nfrom datetime import datetime\r\nfrom ...utils.http_status_codes import HTTP_200_OK, HTTP_201_CREATED\r\nimport random\r\nfrom flask_login import current_user\r\n# from ..models.friend_model import Friend\r\nfrom ...extensions.extensions import db\r\nfrom ...post.models.bookmark_model import Bookmark\r\n\r\n\r\ndef handle_load_posts() -> tuple[str, int]:\r\n \"\"\"Load the initial posts.\"\"\"\r\n user = {\r\n 'user_name': current_user.username,\r\n 'image': url_for('static', filename=f'img/{current_user.image_file}'),\r\n 'user_id': current_user.id,\r\n 'email': current_user.email,\r\n 'handle': f'@{\"\".join(current_user.username.split())}'\r\n }\r\n posts_raw = Post.query.limit(5)\r\n posts = [\r\n {\r\n 'id': post.id,\r\n 'user_id': post.author_id,\r\n 'author_image': url_for('static', filename=f'img/{post.author.image_file}'),\r\n 'author_name': post.author.username,\r\n 'location': post.location,\r\n 'publish_time': int((post.date_published - datetime.now()).total_seconds() / 60),\r\n 'text': post.text,\r\n 'photo': url_for('static', filename=f'img/{post.image}'),\r\n 'likes_count': Like.query.filter_by(post_id=post.id).count(),\r\n 'influencer': random.choice(Like.query.all()).user.username,\r\n 'liked_by': [\r\n url_for('static', filename=f'img/{like.user.image_file}') for like in Like.query.filter_by(post_id=post.id).limit(3)\r\n ],\r\n 'comments_count': Comment.query.filter_by(post_id=post.id).count(),\r\n 'comment': {" } ]
[ { "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": "" } ]
[ { "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" } ]
[ { "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 .comment_thread import YouTubeCommentThread" } ]
[ { "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" } ]
[ { "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 ..resource import YouTubeResource\r\nfrom ...models import Video, Localized, Statistics, Status, VideoCategory\r\nfrom typing import Any, Callable, Optional\r\nfrom ..schemas.video import VideoFilter, VideoOptionalParameters, VideoPart\r\nfrom ..schemas.resource import Filter, RequestSchema, YouTubeResponse\r\nfrom ..schemas.rating import YouTubeRatingResponse\r\nfrom datetime import datetime\r\nfrom googleapiclient.http import MediaFileUpload\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 get_video_ratings(self, video_ids: list[str]) -> YouTubeRatingResponse:\r\n filters: dict = self.generate_filter(self.generate_video_ids, VideoFilter(id=video_ids))\r\n find_video_rating_request: dict = self.youtube_client.videos().getRating(\r\n **filters\r\n )\r\n find_video_rating_result: dict[str, int|str] = find_video_rating_request.execute()\r\n return self.parse_user_video_rating(find_video_rating_result)\r\n \r\n def generate_video_ids(self, video_filter: VideoFilter) -> dict[str, str]:\r\n video_ids: str = ','.join(video_filter.id)\r\n return dict(id=video_ids)\r\n\r\n def find_video_by_id(self, video_id: str) -> Video:\r\n return self.find_videos_by_ids(video_id)[0]\r\n\r\n def find_videos_by_ids(self, video_ids: list[str]) -> list[Video]:\r\n filters: dict = self.generate_filter(self.generate_video_ids, VideoFilter(id=[video_ids]))\r\n part: VideoPart = VideoPart()\r\n optional_params: VideoOptionalParameters = VideoOptionalParameters()\r\n request_schema: RequestSchema = RequestSchema(part=part, filter=filters, optional_parameters=optional_params)\r\n request_dict = self.create_request_dict(request_schema)\r\n request_dict.update(filters)\r\n find_video_request: dict = self.youtube_client.videos().list(\r\n **request_dict\r\n )\r\n find_video_result: dict[str, int|str] = find_video_request.execute()" } ]
[ { "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": "" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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": "" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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" } ]
[ { "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 argparse import Namespace\r\n\r\nfrom .config import Config\r\nfrom .docstring_generator import generate_project_docstrings\r\nfrom .extensions import function_code_queue, source_code_queue\r\nfrom .ui import create_application_config, parse_arguments\r\n\r\n\r\ndef main():\r\n args: Namespace = parse_arguments()\r\n config: Config = create_application_config(args)\r\n generate_project_docstrings(\r\n config=config,\r\n source_code_queue=source_code_queue,\r\n function_code_queue=function_code_queue,\r\n )\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n" } ]
[ { "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 pymongo import MongoClient\r\n\r\ndef test_mongo_connection():\r\n try:\r\n # Create a MongoDB client\r\n client = MongoClient(\"mongodb://root:yourpassword@localhost:27017/\")\r\n \r\n # Get the database instance\r\n db = client.yourdbname\r\n\r\n # Create a new collection or get the existing collection\r\n collection = db.test_collection\r\n\r\n # Insert a new document\r\n result = collection.insert_one({\"message\": \"Hello, MongoDB!\"})\r\n \r\n # Retrieve the inserted document\r\n retrieved_document = collection.find_one({\"_id\": result.inserted_id})\r\n \r\n print(\"Document inserted successfully:\")\r\n print(retrieved_document)\r\n \r\n # Close the connection\r\n client.close()\r\n\r\n except Exception as e:\r\n print(f\"An error occurred: {e}\")\r\n\r\nif __name__ == \"__main__\":\r\n test_mongo_connection()\r\n\r\n" } ]
[ { "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" } ]
[ { "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 List\r\nimport os\r\nfrom functools import lru_cache\r\nimport tweepy\r\nfrom src import logger\r\nfrom src.utils.config import BLACKLIST, SEARCH_FILTERS\r\n\r\nfrom praw import Reddit\r\nfrom praw.models import Subreddit\r\n\r\n\r\n@lru_cache(maxsize=None)\r\ndef get_api():\r\n auth = tweepy.OAuth2BearerHandler(os.environ.get(\"TWITTER_BEARER_TOKEN\"))\r\n api = tweepy.API(auth, parser=tweepy.parsers.JSONParser())\r\n return api\r\n\r\n\r\ndef search_users(q, count):\r\n api = get_api()\r\n users = api.search_users(q=q, count=count)\r\n extracted_users = []\r\n\r\n for user in users:\r\n screen_name = user[\"screen_name\"]\r\n followers_count = user[\"followers_count\"]\r\n statuses_count = user[\"statuses_count\"]\r\n description = user[\"description\"]\r\n profile_url = f\"https://twitter/{screen_name}\"\r\n lang = user[\"lang\"]\r\n\r\n extracted_user = dict(\r\n screen_name=screen_name,\r\n profile_url=profile_url,\r\n description=description,\r\n followers_count=followers_count,\r\n statuses_count=statuses_count,\r\n lang=lang,\r\n )\r\n extracted_users.append(extracted_user)" } ]
[ { "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": "\"\"\"Toctree adapter for sphinx.environment.\"\"\"\r\n\r\nfrom __future__ import annotations\r\n\r\nfrom typing import TYPE_CHECKING, Any, TypeVar\r\n\r\nfrom docutils import nodes\r\nfrom docutils.nodes import Element, Node\r\n\r\nfrom sphinx import addnodes\r\nfrom sphinx.locale import __\r\nfrom sphinx.util import logging, url_re\r\nfrom sphinx.util.matching import Matcher\r\nfrom sphinx.util.nodes import _only_node_keep_children, clean_astext\r\n\r\nif TYPE_CHECKING:\r\n from collections.abc import Iterable, Set\r\n\r\n from sphinx.builders import Builder\r\n from sphinx.environment import BuildEnvironment\r\n from sphinx.util.tags import Tags\r\n\r\n\r\nlogger = logging.getLogger(__name__)\r\n\r\n\r\ndef note_toctree(env: BuildEnvironment, docname: str, toctreenode: addnodes.toctree) -> None:\r\n \"\"\"Note a TOC tree directive in a document and gather information about\r\n file relations from it.\r\n \"\"\"\r\n if toctreenode['glob']:\r\n env.glob_toctrees.add(docname)\r\n if toctreenode.get('numbered'):\r\n env.numbered_toctrees.add(docname)\r\n include_files = toctreenode['includefiles']\r\n for include_file in include_files:\r\n # note that if the included file is rebuilt, this one must be\r\n # too (since the TOC of the included file could have changed)\r\n env.files_to_rebuild.setdefault(include_file, set()).add(docname)\r\n env.toctree_includes.setdefault(docname, []).extend(include_files)" } ]
[ { "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 " } ]
[ { "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": "" } ]
[ { "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()" } ]
[ { "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 assistant.agents import default_agent\r\nimport chainlit as cl\r\n\r\n\r\n@cl.on_chat_start\r\nasync def start():\r\n cl.user_session.set('agent', default_agent)\r\n\r\n\r\n@cl.on_message\r\nasync def main(message: cl.Message):\r\n agent = cl.user_session.get('agent')\r\n msg = cl.Message(content='')\r\n await msg.send()\r\n await cl.sleep(1)\r\n msg.content = agent.invoke({'input': message.content})['output']\r\n await msg.update()\r\n" } ]
[ { "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 .bookmark import Bookmark\r\nfrom .comment import Comment\r\nfrom .like import Like\r\nfrom .post import Post\r\nfrom .user import User\r\nfrom .view import View\r\n" } ]
[ { "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 .search import SearchSchema\r\n" } ]
[ { "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])" } ]
[ { "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": "" } ]
[ { "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 pydantic import BaseModel\r\nfrom datetime import datetime\r\nfrom typing import Optional\r\n\r\n\r\nclass AuthorBase(BaseModel):\r\n author_profile_image_url: str\r\n author_channel_url: str\r\n author_channel_id: str\r\n author_display_name: str\r\n \r\nclass AuthorCreate(AuthorBase):\r\n pass\r\n\r\nclass Author(AuthorBase):\r\n author_id: int\r\n \r\nclass CommentBase(BaseModel):\r\n comment_id: str\r\n video_id: str\r\n parent_id: Optional[str]\r\n comment_text: str\r\n like_count: int\r\n published_at: datetime\r\n updated_at: datetime\r\n \r\nclass CommentCreate(CommentBase):\r\n author: AuthorCreate\r\n \r\nclass Comment(CommentBase):\r\n author_id: int\r\n\r\nclass CommentsCreate(BaseModel):\r\n comments: list[CommentCreate]\r\n\r\nclass Comments(BaseModel):\r\n comments: list[Comment]\r\n \r\nclass GetComment(BaseModel):\r\n comment_id: str" } ]
[ { "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']" } ]
[ { "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": "" } ]
[ { "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)" } ]
[ { "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\nimport chainlit as cl\r\n\r\nfrom calendar_assistant.usecases.agent import agent_executor\r\n\r\n\r\n@cl.on_message\r\nasync def main(message: cl.Message):\r\n msg = cl.Message(content=\"\")\r\n await msg.send()\r\n await cl.sleep(1)\r\n msg.content = agent_executor.invoke({\"input\": message.content})['output']\r\n await msg.update()" } ]
[ { "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" } ]
[ { "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 google_drive import GoogleDrive\r\n\r\n\r\nclient_secrets_file = 'drive.json'\r\ndrive = GoogleDrive(client_secret_file=client_secrets_file)\r\ndrive.authenticate()\r\n" } ]
[ { "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 datetime import datetime\r\n\r\nfrom sqlalchemy import ForeignKey\r\nfrom sqlalchemy.orm import Mapped, mapped_column, relationship\r\n\r\nfrom ..database import Base\r\n\r\n\r\nclass Comment(Base):\r\n __tablename__ = \"comments\"\r\n\r\n id: Mapped[str] = mapped_column(primary_key=True)\r\n author_id: Mapped[str] = mapped_column(ForeignKey(\"users.id\"))\r\n post_id: Mapped[str] = mapped_column(ForeignKey(\"posts.id\"))\r\n comment_text: Mapped[str]\r\n comment_date: Mapped[datetime] = mapped_column(default_factory=datetime.utcnow)\r\n\r\n author = relationship(\"User\", back_populates=\"comments\")\r\n post = relationship(\"Post\", back_populates=\"comments\")\r\n" } ]
[ { "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" } ]
[ { "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 atexit\r\nimport os\r\nimport sys\r\nimport json\r\nfrom rich.console import Console\r\nfrom langchain.vectorstores import Chroma\r\nfrom langchain.embeddings.openai import OpenAIEmbeddings\r\nimport chromadb\r\nfrom chromadb.config import Settings\r\nimport tiktoken\r\nfrom src import logger\r\nfrom src.utils.chains import (\r\n get_retrieval_qa_chain,\r\n summarize_tweets,\r\n)\r\nfrom src.utils.data_processing import (\r\n get_texts_from_documents,\r\n get_metadatas_from_documents,\r\n)\r\nfrom src.utils.display import display_bot_answer, display_summary_and_questions\r\nfrom src.utils.document_loader import TwitterTweetLoader\r\nfrom src.utils.prompts import summarization_question_template, summarization_template\r\n\r\n\r\nclass TwitterAgent(object):\r\n def __init__(\r\n self,\r\n twitter_users,\r\n keywords,\r\n number_tweets,\r\n persist_db=True,\r\n ):\r\n self.twitter_users = twitter_users\r\n self.keywords = keywords\r\n self.number_tweets = number_tweets\r\n self.loaded_documents = []\r\n self.embeddings = OpenAIEmbeddings()\r\n self.persist_db = persist_db\r\n self.chain = None\r\n self.client = None" } ]
[ { "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": "def add(a, b):\r\n \"\"\"\r\n Add two numbers together.\r\n\r\n Parameters\r\n ----------\r\n a : int or float\r\n First number to be added.\r\n b : int or float\r\n Second number to be added.\r\n\r\n Returns\r\n -------\r\n int or float\r\n Sum of a and b.\r\n\r\n Raises\r\n ------\r\n TypeError\r\n If a or b is not an int or float.\r\n \"\"\"\r\n try:\r\n return operator.add(a, b)\r\n except TypeError:\r\n raise TypeError(\"a and b must be either int or float\")\r\n\r\n # Example 1: Adding two integers\r\n result = add(5, 10)\r\n print(result) # Output: 15\r\n\r\n # Example 2: Adding two floats\r\n result = add(3.5, 2.5)\r\n print(result) # Output: 6.0\r\n\r\n # Example 3: Adding an integer and a string\r\n result = add(5, \"10\")\r\n # Output: TypeError: a and b must be either int or float\r\n \r\n \r\n " } ]
[ { "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.models import Channel\r\nfrom datetime import datetime\r\nfrom uuid import uuid4\r\n\r\n\r\ndef get_channels() -> list[Channel]:\r\n \"\"\"Get a list fo channels.\"\"\"\r\n channels: list[Channel] = [\r\n Channel(\r\n id=1,\r\n title='Tech Investment',\r\n description='This channel helps the user to invest in disruptive technologies.',\r\n subscribers=200,\r\n date_created=datetime.now()\r\n )\r\n ]\r\n return channels" } ]
[ { "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 setuptools import find_packages, setup\r\nfrom pip._vendor import tomli\r\n\r\n# For consistent encoding\r\nfrom codecs import open\r\nfrom os import path\r\n\r\n# The directory containing this file\r\nHERE = path.abspath(path.dirname(__file__))\r\n\r\n# Get the long description from the README file\r\nwith open(path.join(HERE, \"README.md\"), encoding=\"utf-8\") as f:\r\n LONG_DESCRIPTION = f.read()\r\n\r\nwith open(\"pyproject.toml\", \"r\") as f:\r\n VERSION = tomli.load(f)[\"tool\"][\"commitizen\"][\"version\"]\r\n\r\nDESCRIPTION = \"A python library for generating docstrings for functions and classes.\"\r\n\r\nkey_words = [\"dosctrings\", \"documentation\"]\r\n\r\ninstall_requires = [\r\n \"langchain\",\r\n \"langchain-openai\",\r\n \"black\",\r\n \"pydantic\",\r\n \"pydantic-settings\",\r\n]\r\n\r\nsetup(\r\n name=\"docstring_generator\",\r\n packages=find_packages(\r\n include=[\r\n \"docstring_generator\",\r\n ]\r\n ),\r\n version=VERSION,\r\n description=DESCRIPTION,\r\n long_description_content_type=\"text/markdown\",\r\n long_description=LONG_DESCRIPTION," } ]
[ { "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 datetime import datetime\r\nfrom typing import Optional\r\n\r\nfrom pydantic import BaseModel, Field\r\n\r\n\r\nclass SearchSchema(BaseModel):\r\n id: Optional[str] = None\r\n type: Optional[str] = None\r\n published_at: Optional[datetime] = None\r\n channel_id: Optional[str] = None\r\n title: Optional[str] = None\r\n description: Optional[str] = None\r\n channel_title: Optional[str] = None\r\n live_broadcast_content: Optional[str] = None\r\n publish_time: Optional[str] = None\r\n" } ]
[ { "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" } ]
[ { "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 pydantic_settings import BaseSettings\r\n\r\n\r\nclass BaseConfig(BaseSettings):\r\n max_results: int = 10" } ]
[ { "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 google_calendar import GoogleCalendar\r\nimport os\r\n\r\nclient_secret: str = os.environ['CLIENT_SECRET_FILE']\r\ngoogle_calendar: GoogleCalendar = GoogleCalendar(secret_file=client_secret)\r\ngoogle_calendar.authenticate()" } ]
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
504
Edit dataset card