llamaparserb 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +102 -9
- data/lib/llamaparserb/version.rb +1 -1
- data/lib/llamaparserb.rb +41 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba81bbf8d24dc79b57a29c8c40764c42d700012e6608d1a494075dd63900d06f
|
4
|
+
data.tar.gz: 1ce8846e182bf7025d90e8722148554fe2e65d47d82e1671e19f7e6386d30ce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c86e77644210049df9a1095049e2a276f70e40208637e80fd14283fded8eee45ec034cc9bd7c205b802ef24be252989bbd5be671ac50981c0acb998876131b
|
7
|
+
data.tar.gz: 91ea52459cc1fc38f15dd5b050a2c25449147f8905d24af34c76986f48c84f54d0187bad3c0d3b4da81061e8d593982252229611592948deffdc7a6d6d6c066f
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.2.3] - 2024-11-28
|
10
|
+
### Added
|
11
|
+
- Add support for all supported optional llamaparsse parameters to `parse_file`
|
12
|
+
|
13
|
+
## [0.2.2] - 2024-11-28
|
14
|
+
### Fixed
|
15
|
+
- Fix issue with handling file path
|
16
|
+
|
9
17
|
## [0.2.1] - 2024-11-28
|
10
18
|
### Fixed
|
11
19
|
- Fix parse_file to handle files that are not on the local filesystem
|
data/README.md
CHANGED
@@ -75,19 +75,112 @@ client.parse_file(temp_file, 'pdf')
|
|
75
75
|
client = Llamaparserb::Client.new(
|
76
76
|
ENV['LLAMA_CLOUD_API_KEY'],
|
77
77
|
{
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
# Basic Configuration
|
79
|
+
result_type: "markdown", # Output format: "text" or "markdown"
|
80
|
+
num_workers: 4, # Number of workers for concurrent processing
|
81
|
+
check_interval: 1, # How often to check job status (seconds)
|
82
|
+
max_timeout: 2000, # Maximum time to wait for parsing (seconds)
|
83
|
+
verbose: true, # Enable detailed logging
|
84
|
+
show_progress: true, # Show progress during parsing
|
85
|
+
ignore_errors: true, # Return nil instead of raising errors
|
86
|
+
|
87
|
+
# Language and Parsing Options
|
88
|
+
language: :en, # Target language for parsing
|
89
|
+
parsing_instruction: "", # Custom parsing instructions
|
90
|
+
skip_diagonal_text: false, # Skip diagonal text in documents
|
91
|
+
invalidate_cache: false, # Force reprocessing of cached documents
|
92
|
+
do_not_cache: false, # Disable caching of results
|
93
|
+
|
94
|
+
# Processing Modes
|
95
|
+
fast_mode: false, # Enable faster processing (may reduce quality)
|
96
|
+
premium_mode: false, # Enable premium parsing features
|
97
|
+
continuous_mode: false, # Process document as continuous text
|
98
|
+
do_not_unroll_columns: false, # Keep columnar text structure
|
99
|
+
|
100
|
+
# Page Handling
|
101
|
+
split_by_page: true, # Split result by pages
|
102
|
+
page_separator: "\n\n", # Custom page separator
|
103
|
+
page_prefix: "Page ", # Text to prepend to each page
|
104
|
+
page_suffix: "\n", # Text to append to each page
|
105
|
+
target_pages: [1,2,3], # Array of specific pages to process
|
106
|
+
bounding_box: { # Specify area to parse (coordinates in pixels)
|
107
|
+
x1: 0, y1: 0, # Top-left corner
|
108
|
+
x2: 612, y2: 792 # Bottom-right corner
|
109
|
+
},
|
110
|
+
|
111
|
+
# OCR and Image Processing
|
112
|
+
disable_ocr: false, # Disable Optical Character Recognition
|
113
|
+
take_screenshot: false, # Capture screenshot of document
|
114
|
+
|
115
|
+
# Advanced Processing Features
|
116
|
+
gpt4o_mode: false, # Enable GPT-4 Optimization mode
|
117
|
+
gpt4o_api_key: "key", # API key for GPT-4 Optimization
|
118
|
+
guess_xlsx_sheet_names: false, # Attempt to guess Excel sheet names
|
119
|
+
is_formatting_instruction: false, # Use formatting instructions
|
120
|
+
annotate_links: false, # Include link annotations in output
|
121
|
+
|
122
|
+
# Multimodal Processing
|
123
|
+
vendor_multimodal_api_key: "key", # API key for multimodal processing
|
124
|
+
use_vendor_multimodal_model: false, # Enable multimodal model
|
125
|
+
vendor_multimodal_model_name: "model", # Specify multimodal model
|
126
|
+
|
127
|
+
# Integration Options
|
128
|
+
webhook_url: "https://...", # URL for webhook notifications
|
129
|
+
http_proxy: "http://...", # HTTP proxy configuration
|
130
|
+
|
131
|
+
# Azure OpenAI Configuration
|
132
|
+
azure_openai_deployment_name: "deployment", # Azure OpenAI deployment name
|
133
|
+
azure_openai_endpoint: "endpoint", # Azure OpenAI endpoint
|
134
|
+
azure_openai_api_version: "2023-05-15", # Azure OpenAI API version
|
135
|
+
azure_openai_key: "key" # Azure OpenAI API key
|
87
136
|
}
|
88
137
|
)
|
89
138
|
```
|
90
139
|
|
140
|
+
### Feature-Specific Options
|
141
|
+
|
142
|
+
#### Page Processing
|
143
|
+
- `split_by_page`: Split the document into separate pages
|
144
|
+
- `page_separator`: Custom text to insert between pages
|
145
|
+
- `page_prefix`/`page_suffix`: Add custom text before/after each page
|
146
|
+
- `target_pages`: Process only specific pages
|
147
|
+
- `bounding_box`: Parse only a specific area of the document
|
148
|
+
|
149
|
+
#### OCR and Image Processing
|
150
|
+
- `disable_ocr`: Turn off Optical Character Recognition
|
151
|
+
- `take_screenshot`: Generate document screenshots
|
152
|
+
- `skip_diagonal_text`: Ignore text at diagonal angles
|
153
|
+
|
154
|
+
#### Advanced Processing
|
155
|
+
- `continuous_mode`: Process text as a continuous stream
|
156
|
+
- `do_not_unroll_columns`: Preserve column structure
|
157
|
+
- `guess_xlsx_sheet_names`: Auto-detect Excel sheet names
|
158
|
+
- `annotate_links`: Include document hyperlinks in output
|
159
|
+
- `is_formatting_instruction`: Use special formatting instructions
|
160
|
+
|
161
|
+
#### Performance Options
|
162
|
+
- `fast_mode`: Faster processing with potential quality trade-offs
|
163
|
+
- `premium_mode`: Access to premium features
|
164
|
+
- `invalidate_cache`/`do_not_cache`: Control result caching
|
165
|
+
- `num_workers`: Configure concurrent processing
|
166
|
+
|
167
|
+
#### Integration Features
|
168
|
+
- `webhook_url`: Receive processing notifications
|
169
|
+
- `http_proxy`: Configure proxy settings
|
170
|
+
|
171
|
+
#### Azure OpenAI Integration
|
172
|
+
Configure Azure OpenAI services with:
|
173
|
+
- `azure_openai_deployment_name`
|
174
|
+
- `azure_openai_endpoint`
|
175
|
+
- `azure_openai_api_version`
|
176
|
+
- `azure_openai_key`
|
177
|
+
|
178
|
+
#### Multimodal Processing
|
179
|
+
Enable advanced multimodal processing with:
|
180
|
+
- `vendor_multimodal_api_key`
|
181
|
+
- `use_vendor_multimodal_model`
|
182
|
+
- `vendor_multimodal_model_name`
|
183
|
+
|
91
184
|
### Supported File Types
|
92
185
|
|
93
186
|
The client supports a wide range of file formats including:
|
data/lib/llamaparserb/version.rb
CHANGED
data/lib/llamaparserb.rb
CHANGED
@@ -100,7 +100,20 @@ module Llamaparserb
|
|
100
100
|
bounding_box: nil,
|
101
101
|
target_pages: nil,
|
102
102
|
ignore_errors: true,
|
103
|
-
split_by_page: true
|
103
|
+
split_by_page: true,
|
104
|
+
vendor_multimodal_api_key: nil,
|
105
|
+
use_vendor_multimodal_model: false,
|
106
|
+
vendor_multimodal_model_name: nil,
|
107
|
+
take_screenshot: false,
|
108
|
+
disable_ocr: false,
|
109
|
+
is_formatting_instruction: false,
|
110
|
+
annotate_links: false,
|
111
|
+
webhook_url: nil,
|
112
|
+
azure_openai_deployment_name: nil,
|
113
|
+
azure_openai_endpoint: nil,
|
114
|
+
azure_openai_api_version: nil,
|
115
|
+
azure_openai_key: nil,
|
116
|
+
http_proxy: nil
|
104
117
|
}
|
105
118
|
end
|
106
119
|
|
@@ -168,10 +181,10 @@ module Llamaparserb
|
|
168
181
|
|
169
182
|
def handle_error(error, file_input)
|
170
183
|
if @options[:ignore_errors]
|
171
|
-
safe_message = if file_input.is_a?(String) &&
|
172
|
-
"
|
184
|
+
safe_message = if file_input.is_a?(String) && file_input.start_with?("/")
|
185
|
+
"file path: #{file_input}"
|
173
186
|
else
|
174
|
-
|
187
|
+
"binary data"
|
175
188
|
end
|
176
189
|
|
177
190
|
log "Error while parsing file (#{safe_message}): #{error.message}", :error
|
@@ -237,7 +250,7 @@ module Llamaparserb
|
|
237
250
|
end
|
238
251
|
|
239
252
|
def upload_params(file)
|
240
|
-
{
|
253
|
+
params = {
|
241
254
|
file: file,
|
242
255
|
language: @options[:language].to_s,
|
243
256
|
parsing_instruction: @options[:parsing_instruction],
|
@@ -250,8 +263,30 @@ module Llamaparserb
|
|
250
263
|
do_not_unroll_columns: @options[:do_not_unroll_columns],
|
251
264
|
gpt4o_mode: @options[:gpt4o_mode],
|
252
265
|
gpt4o_api_key: @options[:gpt4o_api_key],
|
266
|
+
vendor_multimodal_api_key: @options[:vendor_multimodal_api_key],
|
267
|
+
use_vendor_multimodal_model: @options[:use_vendor_multimodal_model],
|
268
|
+
vendor_multimodal_model_name: @options[:vendor_multimodal_model_name],
|
269
|
+
take_screenshot: @options[:take_screenshot],
|
270
|
+
disable_ocr: @options[:disable_ocr],
|
271
|
+
guess_xlsx_sheet_names: @options[:guess_xlsx_sheet_names],
|
272
|
+
is_formatting_instruction: @options[:is_formatting_instruction],
|
273
|
+
annotate_links: @options[:annotate_links],
|
253
274
|
from_ruby_package: true
|
254
|
-
}
|
275
|
+
}
|
276
|
+
|
277
|
+
params[:page_separator] = @options[:page_separator] if @options[:page_separator]
|
278
|
+
params[:page_prefix] = @options[:page_prefix] if @options[:page_prefix]
|
279
|
+
params[:page_suffix] = @options[:page_suffix] if @options[:page_suffix]
|
280
|
+
params[:bounding_box] = @options[:bounding_box] if @options[:bounding_box]
|
281
|
+
params[:target_pages] = @options[:target_pages] if @options[:target_pages]
|
282
|
+
params[:webhook_url] = @options[:webhook_url] if @options[:webhook_url]
|
283
|
+
params[:azure_openai_deployment_name] = @options[:azure_openai_deployment_name] if @options[:azure_openai_deployment_name]
|
284
|
+
params[:azure_openai_endpoint] = @options[:azure_openai_endpoint] if @options[:azure_openai_endpoint]
|
285
|
+
params[:azure_openai_api_version] = @options[:azure_openai_api_version] if @options[:azure_openai_api_version]
|
286
|
+
params[:azure_openai_key] = @options[:azure_openai_key] if @options[:azure_openai_key]
|
287
|
+
params[:http_proxy] = @options[:http_proxy] if @options[:http_proxy]
|
288
|
+
|
289
|
+
params.compact
|
255
290
|
end
|
256
291
|
|
257
292
|
def get_job_status(job_id)
|