Skip to content

Commit

Permalink
update to use v0.11.0 of core
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-markewich committed Aug 23, 2024
1 parent 6c700d9 commit 6a29b1a
Show file tree
Hide file tree
Showing 3 changed files with 543 additions and 615 deletions.
14 changes: 10 additions & 4 deletions llama_parse/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from io import BufferedIOBase

from llama_index.core.async_utils import run_jobs
from llama_index.core.bridge.pydantic import Field, validator
from llama_index.core.bridge.pydantic import Field, field_validator
from llama_index.core.constants import DEFAULT_BASE_URL
from llama_index.core.readers.base import BasePydanticReader
from llama_index.core.schema import Document
Expand All @@ -31,7 +31,11 @@
class LlamaParse(BasePydanticReader):
"""A smart-parser for files."""

api_key: str = Field(default="", description="The API key for the LlamaParse API.")
api_key: str = Field(
default="",
description="The API key for the LlamaParse API.",
validate_default=True,
)
base_url: str = Field(
default=DEFAULT_BASE_URL,
description="The base URL of the Llama Parsing API.",
Expand Down Expand Up @@ -134,7 +138,8 @@ class LlamaParse(BasePydanticReader):
description="The model name for the vendor multimodal API.",
)

@validator("api_key", pre=True, always=True)
@field_validator("api_key", mode="before", check_fields=True)
@classmethod
def validate_api_key(cls, v: str) -> str:
"""Validate the API key."""
if not v:
Expand All @@ -147,7 +152,8 @@ def validate_api_key(cls, v: str) -> str:

return v

@validator("base_url", pre=True, always=True)
@field_validator("base_url", mode="before", check_fields=True)
@classmethod
def validate_base_url(cls, v: str) -> str:
"""Validate the base URL."""
url = os.getenv("LLAMA_CLOUD_BASE_URL", None)
Expand Down
Loading

0 comments on commit 6a29b1a

Please sign in to comment.