sunholo 0.136.0__py3-none-any.whl → 0.136.2__py3-none-any.whl

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.
@@ -487,23 +487,34 @@ class DiscoveryEngineClient:
487
487
  all_documents = []
488
488
  result_count = 0
489
489
  # Check if the response contains results
490
- if not hasattr(response, 'results') or not response.results:
490
+ if not response or not hasattr(response, 'results') or not response.results:
491
491
  log.info(f'No results found in response: {response=}')
492
492
  return []
493
493
 
494
- # Iterate through each result in the page
495
- for result in response.results:
496
- if hasattr(result, 'document'):
497
- document = result.document
498
- all_documents.append(self.document_format(document))
499
- result_count += 1
500
-
501
- # Check if we've reached max_limit
502
- if max_limit is not None and result_count >= max_limit:
503
- log.info(f"Reached max_limit of {max_limit} results, stopping processing")
504
- break
505
- else:
506
- log.warning("No document found in result")
494
+ should_break=False
495
+ # Process the pager properly
496
+ for page in response.pages:
497
+ if should_break:
498
+ break
499
+ if hasattr(page, 'results') and page.results:
500
+ for result in page.results:
501
+ if result_count >= max_limit:
502
+ log.info("Breaking results loop as max limit reached")
503
+ should_break = True # Set flag to break outer loop
504
+ break
505
+
506
+ if hasattr(result, 'document'):
507
+ document = result.document
508
+ all_documents.append(self.document_format(document))
509
+ result_count += 1
510
+
511
+ # Check if we've reached max_limit
512
+ if max_limit is not None and result_count >= max_limit:
513
+ log.info(f"Reached max_limit of {max_limit} results, stopping processing")
514
+ should_break = True
515
+ break
516
+ else:
517
+ log.warning("No document found in result")
507
518
 
508
519
  # Combine all documents into one long string
509
520
  result_string = "\n\n".join(all_documents)
@@ -516,23 +527,34 @@ class DiscoveryEngineClient:
516
527
  result_count = 0
517
528
 
518
529
  # Check if the response contains results
519
- if not hasattr(response, 'results') or not response.results:
530
+ if not response or not hasattr(response, 'results') or not response.results:
520
531
  log.info(f'No results found in response: {response=}')
521
532
  return []
522
-
523
- # Iterate through each result in the page
524
- for result in response.results:
525
- if hasattr(result, 'document'):
526
- document = result.document
527
- all_documents.append(self.document_format(document))
528
- result_count += 1
529
-
530
- # Check if we've reached max_limit
531
- if max_limit is not None and result_count >= max_limit:
532
- log.info(f"Reached max_limit of {max_limit} results, stopping processing")
533
- break
534
- else:
535
- log.warning("No document found in result")
533
+
534
+ should_break=False
535
+ # Process the pager properly
536
+ async for page in response.pages:
537
+ if should_break:
538
+ break
539
+ if hasattr(page, 'results') and page.results:
540
+ for result in page.results:
541
+ if result_count >= max_limit:
542
+ log.info("Breaking results loop as max limit reached")
543
+ should_break = True # Set flag to break outer loop
544
+ break
545
+
546
+ if hasattr(result, 'document'):
547
+ document = result.document
548
+ all_documents.append(self.document_format(document))
549
+ result_count += 1
550
+
551
+ # Check if we've reached max_limit
552
+ if max_limit is not None and result_count >= max_limit:
553
+ log.info(f"Reached max_limit of {max_limit} results, stopping processing")
554
+ should_break = True
555
+ break
556
+ else:
557
+ log.warning("No document found in result")
536
558
 
537
559
  # Combine all documents into one long string
538
560
  result_string = "\n\n".join(all_documents)
@@ -862,33 +884,6 @@ class DiscoveryEngineClient:
862
884
  except Exception as e:
863
885
  log.info(f"No results {search_request.data_store_specs=}: {str(e)}")
864
886
  return None
865
-
866
- # Apply max_limit if needed
867
- if content_search_spec_type=="documents" and max_limit is not None:
868
- # For raw response objects (when parse_chunks_to_string=False)
869
- if not parse_chunks_to_string:
870
- # We need to limit the pager results before returning
871
- limited_response = search_response
872
- # Store the original pages iterator method
873
- original_pages = limited_response.pages
874
-
875
- # Override the pages property with a custom iterator that respects max_limit
876
- def limited_pages_iterator():
877
- results_count = 0
878
- for page in original_pages:
879
- yield page
880
-
881
- # Count results in this page
882
- if hasattr(page, 'results'):
883
- results_count += len(page.results)
884
-
885
- # Stop if we've reached max_limit
886
- if results_count >= max_limit:
887
- break
888
-
889
- # Replace the pages property with our custom iterator
890
- limited_response.pages = limited_pages_iterator()
891
- return limited_response
892
887
 
893
888
  if parse_chunks_to_string:
894
889
  if content_search_spec_type=="chunks":
@@ -973,33 +968,6 @@ class DiscoveryEngineClient:
973
968
  except Exception as e:
974
969
  log.info(f"No results {search_request.data_store_specs=}: {str(e)}")
975
970
  return None
976
-
977
- # Apply max_limit if needed
978
- if content_search_spec_type=="documents" and max_limit is not None:
979
- # For raw response objects (when parse_chunks_to_string=False)
980
- if not parse_chunks_to_string:
981
- # We need to limit the pager results before returning
982
- limited_response = search_response
983
- # Store the original pages iterator method
984
- original_pages = limited_response.pages
985
-
986
- # Override the pages property with a custom iterator that respects max_limit
987
- async def limited_pages_iterator():
988
- results_count = 0
989
- async for page in original_pages:
990
- yield page
991
-
992
- # Count results in this page
993
- if hasattr(page, 'results'):
994
- results_count += len(page.results)
995
-
996
- # Stop if we've reached max_limit
997
- if results_count >= max_limit:
998
- break
999
-
1000
- # Replace the pages property with our custom iterator
1001
- limited_response.pages = limited_pages_iterator()
1002
- return limited_response
1003
971
 
1004
972
  if parse_chunks_to_string:
1005
973
  if content_search_spec_type=="chunks":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.136.0
3
+ Version: 0.136.2
4
4
  Summary: AI DevOps - a package to help deploy GenAI to the Cloud.
5
5
  Author-email: Holosun ApS <multivac@sunholo.com>
6
6
  License: Apache License, Version 2.0
@@ -75,7 +75,7 @@ sunholo/discovery_engine/__init__.py,sha256=hLgqRDJ22Aov9o2QjAEfsVgnL3kMdM-g5p8R
75
75
  sunholo/discovery_engine/chunker_handler.py,sha256=wkvXl4rFtYfN6AZUKdW9_QD49Whf77BukDbO82UwlAg,7480
76
76
  sunholo/discovery_engine/cli.py,sha256=tsKqNSDCEsDTz5-wuNwjttb3Xt35D97-KyyEiaqolMQ,35628
77
77
  sunholo/discovery_engine/create_new.py,sha256=WUi4_xh_dFaGX3xA9jkNKZhaR6LCELjMPeRb0hyj4FU,1226
78
- sunholo/discovery_engine/discovery_engine_client.py,sha256=xOcOj7D49bh7aKvDM1KujrFxu8dhgbFugSJv-fUPjt0,62444
78
+ sunholo/discovery_engine/discovery_engine_client.py,sha256=f-KjBzS5ILMDWLBF-ozRynKCjxGi7Mm3rRNnynlhWtY,60822
79
79
  sunholo/discovery_engine/get_ai_search_chunks.py,sha256=I6Dt1CznqEvE7XIZ2PkLqopmjpO96iVEWJJqL5cJjOU,5554
80
80
  sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
81
81
  sunholo/embedder/embed_chunk.py,sha256=did2pKkWM2o0KkRcb0H9l2x_WjCq6OyuHDxGbITFKPM,6530
@@ -168,9 +168,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
168
168
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
169
169
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
170
170
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
171
- sunholo-0.136.0.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
- sunholo-0.136.0.dist-info/METADATA,sha256=VeoffpbDPqtye_pewu_LASUZo-79qT6Rpb4UjrG1TQ8,10067
173
- sunholo-0.136.0.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
174
- sunholo-0.136.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
- sunholo-0.136.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
- sunholo-0.136.0.dist-info/RECORD,,
171
+ sunholo-0.136.2.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
+ sunholo-0.136.2.dist-info/METADATA,sha256=3RZ3YKpfmyWWwg2yUp8ayE4a2ECu47f9Kp35IV1MjyM,10067
173
+ sunholo-0.136.2.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
174
+ sunholo-0.136.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
+ sunholo-0.136.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
+ sunholo-0.136.2.dist-info/RECORD,,