Skip to content

Commit

Permalink
add input url and http_proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
hexapode committed Nov 4, 2024
1 parent 89348aa commit bf0158f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions llama_parse/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ class LlamaParse(BasePydanticReader):
azure_openai_key: Optional[str] = Field(
default=None, description="Azure Openai Key"
)
input_url: Optional[str] = Field(
default=None, description="An url to a document that need to be parsed"
)
http_proxy: Optional[str] = Field(
default=None,
description="(optional) If set with input_url will use the specified http proxy to download the file.",
)

@field_validator("api_key", mode="before", check_fields=True)
@classmethod
Expand Down Expand Up @@ -255,6 +262,8 @@ async def _create_job(
fs = fs or get_default_fs()
file_handle = fs.open(file_input, "rb")
files = {"file": (os.path.basename(file_path), file_handle, mime_type)}
elif self.input_url is not None:
files = None
else:
raise ValueError(
"file_input must be either a file path string, file bytes, or buffer object"
Expand Down Expand Up @@ -316,6 +325,13 @@ async def _create_job(
if self.azure_openai_key is not None:
data["azure_openai_key"] = self.azure_openai_key

if self.input_url is not None:
files = None
data["input_url"] = self.input_url

if self.http_proxy is not None:
data["http_proxy"] = self.http_proxy

try:
async with self.client_context() as client:
response = await client.post(
Expand Down

0 comments on commit bf0158f

Please sign in to comment.