You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically my anthropic key is not being accepted when I am trying to use LVM for parsing.
job id: 4fcb9c15-4424-4cce-bf5f-97032018f2ef
This is the code I am using.
def submit_parsing_job_direct_api(pdf_path, api_key, vendor_api_key, instruction_prompt, vendor_model_name):
"""
Submits the document parsing job directly via API using a Llama API key and vendor API key.
Returns the job ID ('id') on success, or the HTTP status code (int)
on specific API errors (401, 429), or None for other errors.
Handles PDF files ONLY.
"""
file_extension = os.path.splitext(pdf_path)[1].lower()
file_name = os.path.basename(pdf_path)
if file_extension != '.pdf':
print(f" > [{file_name}] Error: Unsupported file type '{file_extension}'. Only PDF files are supported. Skipping.")
return None # Indicate failure, not a specific API error code
print(f"Submitting '{file_name}' via Llama Cloud API using {vendor_model_name}...")
upload_url = "https://api.cloud.llamaindex.ai/api/parsing/upload"
headers = {
"Authorization": f"Bearer {api_key}", # Use the Llama API key
"accept": "application/json",
}
# Prepare payload data
multipart_payload_data = {
'parsing_instruction': instruction_prompt,
'invalidate_cache': 'true',
'use_vendor_multimodal_model': 'false',
'vendor_multimodal_model_name': vendor_model_name,
'vendor_api_key': vendor_api_key,
'output_tables_as_html': 'true',
'parse_mode': 'parse_page_with_lvm' # Added directly here
}
try:
with open(pdf_path, 'rb') as f:
files_payload = {
'file': (file_name, f, 'application/pdf') # MIME type is fixed for PDF
}
for key, value in multipart_payload_data.items():
files_payload[key] = (None, value)
response = requests.post(upload_url, headers=headers, files=files_payload)
print(f" > [{file_name}] API Submission Response Status: {response.status_code}")
if response.status_code == 200:
response_json = response.json()
job_id = response_json.get("id")
if job_id:
print(f" > [{file_name}] Successfully submitted job. Job ID: {job_id}")
return job_id # Return job ID string on success
else:
print(f" > [{file_name}] API response OK, but 'id' key not found: {response_json}")
return None # Indicate other failure
elif response.status_code in [401, 429]:
# Return the specific status code for key-related errors
print(f" > [{file_name}] API submission failed: Status {response.status_code}.")
return response.status_code
elif response.status_code == 400:
print(f" > [{file_name}] API submission failed: Bad Request (400). Check file/request details.")
print(f" > Response: {response.text}")
return None # Indicate other failure
else:
print(f" > [{file_name}] API submission failed. Status: {response.status_code}, Response: {response.text}")
return None # Indicate other failure
except requests.exceptions.RequestException as e:
print(f" > [{file_name}] Error submitting job via API: {e}")
return None # Indicate other failure
except FileNotFoundError:
print(f" > [{file_name}] Error: File not found at {pdf_path}")
return None # Indicate other failure
except Exception as e:
print(f" > [{file_name}] An unexpected error occurred during submission: {e}")
traceback.print_exc()
return None # Indicate other failure
LVM with anthropic key and somehow it isn't right for llama parse when I try it on Ui, says connection invalid
The text was updated successfully, but these errors were encountered:
Basically my anthropic key is not being accepted when I am trying to use LVM for parsing.
job id: 4fcb9c15-4424-4cce-bf5f-97032018f2ef
This is the code I am using.
def submit_parsing_job_direct_api(pdf_path, api_key, vendor_api_key, instruction_prompt, vendor_model_name):
"""
Submits the document parsing job directly via API using a Llama API key and vendor API key.
Returns the job ID ('id') on success, or the HTTP status code (int)
on specific API errors (401, 429), or None for other errors.
Handles PDF files ONLY.
"""
file_extension = os.path.splitext(pdf_path)[1].lower()
file_name = os.path.basename(pdf_path)
}
LVM with anthropic key and somehow it isn't right for llama parse when I try it on Ui, says connection invalid
The text was updated successfully, but these errors were encountered: