Skip to content

Commit

Permalink
fix: unnecessary dep and readme (#107)
Browse files Browse the repository at this point in the history
* fix: unnecessary dep and readme

* fix: rename src to megaparse_sdk

* fix: rename src to megaparse_sdk
  • Loading branch information
chloedia authored Nov 7, 2024
1 parent 99b6014 commit b80aaa3
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 8 deletions.
84 changes: 82 additions & 2 deletions megaparse/sdk/README.md
Original file line number Diff line number Diff line change
@@ -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* !
2 changes: 1 addition & 1 deletion megaparse/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from megaparse.sdk.src import MegaParseSDK
from megaparse.sdk.megaparse_sdk import MegaParseSDK

__all__ = ["MegaParseSDK"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from megaparse.sdk.src.client import MegaParseClient
from megaparse.sdk.megaparse_sdk.client import MegaParseClient


class URLUpload:
Expand Down
1 change: 0 additions & 1 deletion megaparse/sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",

]
Expand Down
86 changes: 86 additions & 0 deletions megaparse/sdk/utils/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit b80aaa3

Please sign in to comment.