Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .docsrc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import os
import sys
sys.path.insert(0, os.path.abspath('../'))

project = 'edenai-apis'
copyright = '2022, Eden AI'
author = 'Eden AI'
sys.path.insert(0, os.path.abspath("../"))

project = "edenai-apis"
copyright = "2022, Eden AI"
author = "Eden AI"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.napoleon']
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.napoleon"]
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

autosummary_generate = True
autodoc_default_options = {
'members': True,
"members": True,
}
napoleon_google_docstring = True
napoleon_include_private_with_doc = True

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
html_theme = "furo"
html_static_path = ["_static"]
3 changes: 2 additions & 1 deletion edenai_apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
To see all available providers and features,
check the Full documentation at <https://edenai.github.io/edenai_apis>.
"""

from . import apis
from . import features
from . import interface
from . import loaders
from . import settings
from . import utils
from .interface_v2 import Text, Ocr, Video, Audio, Image, Translation, Multimodal
from .interface_v2 import Text, Ocr, Video, Audio, Image, Translation, Multimodal, LLM
37 changes: 20 additions & 17 deletions edenai_apis/apis/affinda/document.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#TODO: Add tests for this file
# TODO: Add tests for this file
from enum import Enum
from typing import Any, Dict, Optional, Literal

Expand All @@ -15,6 +15,7 @@ class DocumentState(Enum):
ARCHIVED: Document has been archived
REJECTED: Document has been rejected
"""

UPLOADED = "uploaded"
REVIEW = "review"
VALIDATED = "validated"
Expand All @@ -35,6 +36,7 @@ class QueryBuilder:
add_collection: Add the collection parameter to the query
build: Build the query parameters
"""

__query: Dict[str, Any]

def __init__(self) -> None:
Expand All @@ -54,7 +56,7 @@ def add_state(self, state: Optional[DocumentState], required: bool = False):
required (bool): Whether the state parameter is required
"""
if required is True or state is not None:
self.__query['state'] = state.value if state else None
self.__query["state"] = state.value if state else None
return self

def add_workspace(self, workspace: Optional[Workspace], required: bool = False):
Expand All @@ -66,7 +68,7 @@ def add_workspace(self, workspace: Optional[Workspace], required: bool = False):
required (bool): Whether the workspace parameter is required
"""
if required is True or workspace is not None:
self.__query['workspace'] = workspace.identifier if workspace else None
self.__query["workspace"] = workspace.identifier if workspace else None
return self

def add_collection(self, collection: Optional[Collection], required: bool = False):
Expand All @@ -78,7 +80,7 @@ def add_collection(self, collection: Optional[Collection], required: bool = Fals
required (bool): Whether the collection parameter is required
"""
if required is True or collection is not None:
self.__query['collection'] = collection.identifier if collection else None
self.__query["collection"] = collection.identifier if collection else None
return self

def build(self) -> Dict[str, Any]:
Expand All @@ -97,16 +99,17 @@ class FileParameter:
file (str): Path to the file to upload
type (str): Type of the file, either 'file' or 'url'
"""

__file: str
__type: Literal['file', 'url']
__type: Literal["file", "url"]

def __init__(self, file: Optional[str], url: Optional[str]) -> None:
if url:
self.__file = url
self.__type = 'url'
self.__type = "url"
elif file:
self.__file = file
self.__type = 'file'
self.__type = "file"
else:
raise ValueError("File or URL must be provided")

Expand All @@ -116,7 +119,7 @@ def file(self) -> str:
return self.__file

@property
def type(self) -> Literal['file', 'url']:
def type(self) -> Literal["file", "url"]:
"""Type of the file, either 'file' or 'url'"""
return self.__type

Expand All @@ -135,6 +138,7 @@ class UploadDocumentParams:
Methods:
to_form_data: Convert the parameters to a dictionary to be passed to the request
"""

__wait: bool
__identifier: Optional[str]
__filename: Optional[str]
Expand All @@ -149,7 +153,7 @@ def __init__(
filename: Optional[str] = None,
expiry_time: Optional[str] = None,
language: Optional[str] = None,
reject_duplicates: Optional[bool] = None
reject_duplicates: Optional[bool] = None,
) -> None:
self.__wait = wait
self.__identifier = identifier
Expand All @@ -161,42 +165,42 @@ def __init__(
@property
def wait(self) -> dict:
"""Wait for the document to be processed before returning"""
return { 'wait': self.__wait }
return {"wait": self.__wait}

@property
def identifier(self) -> dict:
"""Custom Identifier of the document"""
if self.__identifier is None:
return {}
return { 'identifier': self.__identifier }
return {"identifier": self.__identifier}

@property
def filename(self) -> dict:
"""Filename of the document"""
if self.__filename is None:
return {}
return { 'filename': self.__filename }
return {"filename": self.__filename}

@property
def expiry_time(self) -> dict:
"""Expiry time of the document"""
if self.__expiry_time is None:
return {}
return { 'expiryTime': self.__expiry_time }
return {"expiryTime": self.__expiry_time}

@property
def language(self) -> dict:
"""Language of the document"""
if self.__language is None:
return {}
return { 'language': self.__language }
return {"language": self.__language}

@property
def reject_duplicates(self) -> dict:
"""Reject duplicates of the document"""
if self.__reject_duplicates is None:
return {}
return { 'rejectDuplicates': self.__reject_duplicates }
return {"rejectDuplicates": self.__reject_duplicates}

def to_form_data(self) -> Dict[str, Any]:
"""Convert the parameters to a dictionary to be passed to the request"""
Expand All @@ -206,6 +210,5 @@ def to_form_data(self) -> Dict[str, Any]:
**self.filename,
**self.expiry_time,
**self.language,
**self.reject_duplicates
**self.reject_duplicates,
}

1 change: 1 addition & 0 deletions edenai_apis/apis/affinda/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTE: Please note that these models do not represent the complete API responses, only what can be used.
If any fields are missing, don't hesitate to add them.
"""

from typing import Any, Dict, Literal, Optional, Sequence

from pydantic import BaseModel, Field
Expand Down
75 changes: 52 additions & 23 deletions edenai_apis/apis/affinda/standardization.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,61 @@
from typing import Any, Dict, List, Optional, Sequence, Tuple

from edenai_apis.features.ocr.financial_parser import (
FinancialBankInformation, FinancialBarcode, FinancialCustomerInformation,
FinancialDocumentInformation, FinancialDocumentMetadata, FinancialLineItem,
FinancialLocalInformation, FinancialMerchantInformation,
FinancialParserDataClass, FinancialParserObjectDataClass,
FinancialPaymentInformation)
FinancialBankInformation,
FinancialBarcode,
FinancialCustomerInformation,
FinancialDocumentInformation,
FinancialDocumentMetadata,
FinancialLineItem,
FinancialLocalInformation,
FinancialMerchantInformation,
FinancialParserDataClass,
FinancialParserObjectDataClass,
FinancialPaymentInformation,
)
from edenai_apis.features.ocr.identity_parser import (
IdentityParserDataClass, InfoCountry, InfosIdentityParserDataClass,
ItemIdentityParserDataClass, format_date, get_info_country)
IdentityParserDataClass,
InfoCountry,
InfosIdentityParserDataClass,
ItemIdentityParserDataClass,
format_date,
get_info_country,
)
from edenai_apis.features.ocr.invoice_parser import (
BankInvoice, CustomerInformationInvoice, InfosInvoiceParserDataClass,
InvoiceParserDataClass, ItemLinesInvoice, MerchantInformationInvoice,
TaxesInvoice)
BankInvoice,
CustomerInformationInvoice,
InfosInvoiceParserDataClass,
InvoiceParserDataClass,
ItemLinesInvoice,
MerchantInformationInvoice,
TaxesInvoice,
)
from edenai_apis.features.ocr.receipt_parser import (
InfosReceiptParserDataClass, ItemLines, Locale, MerchantInformation,
PaymentInformation, ReceiptParserDataClass, Taxes)
from edenai_apis.features.ocr.resume_parser import (ResumeEducation,
ResumeEducationEntry,
ResumeExtractedData,
ResumeLang, ResumeLocation,
ResumeParserDataClass,
ResumePersonalInfo,
ResumePersonalName,
ResumeSkill, ResumeWorkExp,
ResumeWorkExpEntry)
from edenai_apis.utils.conversion import (combine_date_with_time,
convert_string_to_number)
InfosReceiptParserDataClass,
ItemLines,
Locale,
MerchantInformation,
PaymentInformation,
ReceiptParserDataClass,
Taxes,
)
from edenai_apis.features.ocr.resume_parser import (
ResumeEducation,
ResumeEducationEntry,
ResumeExtractedData,
ResumeLang,
ResumeLocation,
ResumeParserDataClass,
ResumePersonalInfo,
ResumePersonalName,
ResumeSkill,
ResumeWorkExp,
ResumeWorkExpEntry,
)
from edenai_apis.utils.conversion import (
combine_date_with_time,
convert_string_to_number,
)
from edenai_apis.utils.parsing import extract

from .models import Document, DocumentError, DocumentMeta
Expand Down
Loading