From b80aaa3a894b2bd2c7d7f518919c41af5c99219f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Daems?= <73901882+chloedia@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:56:47 +0100 Subject: [PATCH] fix: unnecessary dep and readme (#107) * fix: unnecessary dep and readme * fix: rename src to megaparse_sdk * fix: rename src to megaparse_sdk --- megaparse/sdk/README.md | 84 +++++++++++++++++- megaparse/sdk/__init__.py | 2 +- .../sdk/{src => megaparse_sdk}/__init__.py | 0 .../sdk/{src => megaparse_sdk}/client.py | 0 .../endpoints/__init__.py | 0 .../endpoints/file_upload.py | 5 +- .../endpoints/url_upload.py | 2 +- megaparse/sdk/pyproject.toml | 1 - megaparse/sdk/utils/type.py | 86 +++++++++++++++++++ 9 files changed, 172 insertions(+), 8 deletions(-) rename megaparse/sdk/{src => megaparse_sdk}/__init__.py (100%) rename megaparse/sdk/{src => megaparse_sdk}/client.py (100%) rename megaparse/sdk/{src => megaparse_sdk}/endpoints/__init__.py (100%) rename megaparse/sdk/{src => megaparse_sdk}/endpoints/file_upload.py (86%) rename megaparse/sdk/{src => megaparse_sdk}/endpoints/url_upload.py (83%) diff --git a/megaparse/sdk/README.md b/megaparse/sdk/README.md index 8eab727..954e7e3 100644 --- a/megaparse/sdk/README.md +++ b/megaparse/sdk/README.md @@ -1,4 +1,84 @@ ## MegaParse SDK -What if you just don't care about the code and just want to call a service that does everythink for you ? -We thought of that (since we do to), just use our SDK. +Welcome to the MegaParse SDK! This SDK allows you to easily interact with the MegaParse API to upload URLs and files for processing. + +### Installation + +To install the MegaParse SDK, use pip: + +```sh +pip install megaparse-sdk +``` + +### Usage + +Here is an example of how to use the MegaParse SDK: + +#### Uploading URLs + +```python +import asyncio +import os + +from megaparse.sdk import MegaParseSDK + +async def upload_url(): + api_key = str(os.getenv("MEGAPARSE_API_KEY")) + megaparse = MegaParseSDK(api_key) + + url = "https://www.quivr.com" + + # Upload a URL + url_response = await megaparse.url.upload(url) + print(f"\n----- URL Response : {url} -----\n") + print(url_response) + + await megaparse.close() + +if __name__ == "__main__": + asyncio.run(upload_url()) +``` + +#### Uploading Files + +```python +import asyncio +import os + +from megaparse.sdk import MegaParseSDK + +async def upload_file(): + api_key = str(os.getenv("MEGAPARSE_API_KEY")) + megaparse = MegaParseSDK(api_key) + + file_path = "your/file/path.pdf" + # Upload a file + response = await megaparse.file.upload( + file_path=file_path, + method="unstructured", # unstructured, llama_parser, megaparse_vision + strategy="auto", + ) + print(f"\n----- File Response : {file_path} -----\n") + print(response) + + await megaparse.close() + +if __name__ == "__main__": + asyncio.run(upload_file()) +``` + +### Features + +- **Upload URLs**: Easily upload URLs for processing. +- **Upload Files**: Upload files with different processing methods and strategies. + +### Getting Started + +1. **Set up your API key**: Make sure to set the `MEGAPARSE_API_KEY` environment variable with your MegaParse API key. +2. **Run the example**: Use the provided example to see how to upload URLs and files. + +For more details, refer to the [usage example](#file:usage_example.py-context). + +We hope you find the MegaParse SDK useful for your projects! + +Enjoy, *Quivr Team* ! \ No newline at end of file diff --git a/megaparse/sdk/__init__.py b/megaparse/sdk/__init__.py index 28e7eac..3211451 100644 --- a/megaparse/sdk/__init__.py +++ b/megaparse/sdk/__init__.py @@ -1,3 +1,3 @@ -from megaparse.sdk.src import MegaParseSDK +from megaparse.sdk.megaparse_sdk import MegaParseSDK __all__ = ["MegaParseSDK"] diff --git a/megaparse/sdk/src/__init__.py b/megaparse/sdk/megaparse_sdk/__init__.py similarity index 100% rename from megaparse/sdk/src/__init__.py rename to megaparse/sdk/megaparse_sdk/__init__.py diff --git a/megaparse/sdk/src/client.py b/megaparse/sdk/megaparse_sdk/client.py similarity index 100% rename from megaparse/sdk/src/client.py rename to megaparse/sdk/megaparse_sdk/client.py diff --git a/megaparse/sdk/src/endpoints/__init__.py b/megaparse/sdk/megaparse_sdk/endpoints/__init__.py similarity index 100% rename from megaparse/sdk/src/endpoints/__init__.py rename to megaparse/sdk/megaparse_sdk/endpoints/__init__.py diff --git a/megaparse/sdk/src/endpoints/file_upload.py b/megaparse/sdk/megaparse_sdk/endpoints/file_upload.py similarity index 86% rename from megaparse/sdk/src/endpoints/file_upload.py rename to megaparse/sdk/megaparse_sdk/endpoints/file_upload.py index e16a2ea..9b699ff 100644 --- a/megaparse/sdk/src/endpoints/file_upload.py +++ b/megaparse/sdk/megaparse_sdk/endpoints/file_upload.py @@ -1,10 +1,9 @@ from typing import Optional from httpx import Response -from llama_parse.utils import Language -from megaparse.sdk.src.client import MegaParseClient -from megaparse.sdk.utils.type import ParserType, StrategyEnum +from megaparse.sdk.megaparse_sdk.client import MegaParseClient +from megaparse.sdk.utils.type import Language, ParserType, StrategyEnum class FileUpload: diff --git a/megaparse/sdk/src/endpoints/url_upload.py b/megaparse/sdk/megaparse_sdk/endpoints/url_upload.py similarity index 83% rename from megaparse/sdk/src/endpoints/url_upload.py rename to megaparse/sdk/megaparse_sdk/endpoints/url_upload.py index 6b392c5..11b6801 100644 --- a/megaparse/sdk/src/endpoints/url_upload.py +++ b/megaparse/sdk/megaparse_sdk/endpoints/url_upload.py @@ -1,4 +1,4 @@ -from megaparse.sdk.src.client import MegaParseClient +from megaparse.sdk.megaparse_sdk.client import MegaParseClient class URLUpload: diff --git a/megaparse/sdk/pyproject.toml b/megaparse/sdk/pyproject.toml index d00e714..ca30a97 100644 --- a/megaparse/sdk/pyproject.toml +++ b/megaparse/sdk/pyproject.toml @@ -6,7 +6,6 @@ dependencies = [ "python-dotenv>=1.0.0", "pycryptodome>=3.21.0", "psutil>=6.1.0", - "llama-parse>=0.4.0", "httpx>=0.27.0", ] diff --git a/megaparse/sdk/utils/type.py b/megaparse/sdk/utils/type.py index d8c70ac..4e583e5 100644 --- a/megaparse/sdk/utils/type.py +++ b/megaparse/sdk/utils/type.py @@ -15,3 +15,89 @@ class StrategyEnum(str, Enum): FAST = "fast" AUTO = "auto" HI_RES = "hi_res" + + +class Language(str, Enum): + BAZA = "abq" + ADYGHE = "ady" + AFRIKAANS = "af" + ANGIKA = "ang" + ARABIC = "ar" + ASSAMESE = "as" + AVAR = "ava" + AZERBAIJANI = "az" + BELARUSIAN = "be" + BULGARIAN = "bg" + BIHARI = "bh" + BHOJPURI = "bho" + BENGALI = "bn" + BOSNIAN = "bs" + SIMPLIFIED_CHINESE = "ch_sim" + TRADITIONAL_CHINESE = "ch_tra" + CHECHEN = "che" + CZECH = "cs" + WELSH = "cy" + DANISH = "da" + DARGWA = "dar" + GERMAN = "de" + ENGLISH = "en" + SPANISH = "es" + ESTONIAN = "et" + PERSIAN_FARSI = "fa" + FRENCH = "fr" + IRISH = "ga" + GOAN_KONKANI = "gom" + HINDI = "hi" + CROATIAN = "hr" + HUNGARIAN = "hu" + INDONESIAN = "id" + INGUSH = "inh" + ICELANDIC = "is" + ITALIAN = "it" + JAPANESE = "ja" + KABARDIAN = "kbd" + KANNADA = "kn" + KOREAN = "ko" + KURDISH = "ku" + LATIN = "la" + LAK = "lbe" + LEZGHIAN = "lez" + LITHUANIAN = "lt" + LATVIAN = "lv" + MAGAHI = "mah" + MAITHILI = "mai" + MAORI = "mi" + MONGOLIAN = "mn" + MARATHI = "mr" + MALAY = "ms" + MALTESE = "mt" + NEPALI = "ne" + NEWARI = "new" + DUTCH = "nl" + NORWEGIAN = "no" + OCCITAN = "oc" + PALI = "pi" + POLISH = "pl" + PORTUGUESE = "pt" + ROMANIAN = "ro" + RUSSIAN = "ru" + SERBIAN_CYRILLIC = "rs_cyrillic" + SERBIAN_LATIN = "rs_latin" + NAGPURI = "sck" + SLOVAK = "sk" + SLOVENIAN = "sl" + ALBANIAN = "sq" + SWEDISH = "sv" + SWAHILI = "sw" + TAMIL = "ta" + TABASSARAN = "tab" + TELUGU = "te" + THAI = "th" + TAJIK = "tjk" + TAGALOG = "tl" + TURKISH = "tr" + UYGHUR = "ug" + UKRAINIAN = "uk" + URDU = "ur" + UZBEK = "uz" + VIETNAMESE = "vi"