File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,19 @@ def prepare_url_data(self, url) -> URLData:
24
24
"""Prepare single URL data for API"""
25
25
return {
26
26
"url_id" : url .id ,
27
- "text" : url .scraped_text ,
28
- "metadata" : {"title" : url .scraped_title , "url" : url .url },
27
+ "text" : url .scraped_text or "" , # Handle None values safely
28
+ "metadata" : {"title" : url .scraped_title or "" , "url" : url .url },
29
29
}
30
30
31
31
def get_text_length (self , url_data : URLData ) -> int :
32
32
"""Get the length of text content for a URL"""
33
- return len (url_data ["text" ])
33
+ text = url_data ["text" ]
34
+ return len (text ) if text is not None else 0
34
35
35
36
def truncate_oversized_url (self , url_data : URLData ) -> URLData :
36
37
"""Handle a URL that exceeds the maximum batch length"""
37
- return {** url_data , "text" : url_data ["text" ][: self .max_batch_text_length ]}
38
+ text = url_data ["text" ] or ""
39
+ return {** url_data , "text" : text [: self .max_batch_text_length ]}
38
40
39
41
def would_exceed_batch_limit (self , current_length : int , new_length : int ) -> bool :
40
42
"""Check if adding new text would exceed batch limit"""
You can’t perform that action at this time.
0 commit comments