sunholo 0.136.1__tar.gz → 0.136.3__tar.gz
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.
- {sunholo-0.136.1/src/sunholo.egg-info → sunholo-0.136.3}/PKG-INFO +1 -1
- {sunholo-0.136.1 → sunholo-0.136.3}/pyproject.toml +1 -1
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/discovery_engine/discovery_engine_client.py +88 -102
- {sunholo-0.136.1 → sunholo-0.136.3/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.136.1 → sunholo-0.136.3}/LICENSE.txt +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/MANIFEST.in +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/README.md +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/setup.cfg +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/auth/refresh.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/database.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/discovery_engine/cli.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/embedder/embed_metadata.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/file_handling.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/ollama/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/ollama/ollama_images.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/tests/test_async.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/tests/test_async_genai2.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/tests/test_chat_history.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/tests/test_config.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/tests/test_genai2.py +0 -0
- {sunholo-0.136.1 → sunholo-0.136.3}/tests/test_unstructured.py +0 -0
@@ -486,35 +486,53 @@ class DiscoveryEngineClient:
|
|
486
486
|
"""Process a search response containing documents into a formatted string."""
|
487
487
|
all_documents = []
|
488
488
|
result_count = 0
|
489
|
+
|
489
490
|
# Check if the response contains results
|
490
491
|
if not response or not hasattr(response, 'results') or not response.results:
|
491
492
|
log.info(f'No results found in response: {response=}')
|
492
493
|
return []
|
493
494
|
|
494
|
-
|
495
|
-
#
|
496
|
-
for
|
497
|
-
if
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
495
|
+
# Simpler approach: Just process the direct results from the response
|
496
|
+
# This handles the case where it's just a simple SearchResponse
|
497
|
+
for result in response.results:
|
498
|
+
if hasattr(result, 'document'):
|
499
|
+
document = result.document
|
500
|
+
all_documents.append(self.document_format(document))
|
501
|
+
result_count += 1
|
502
|
+
|
503
|
+
# Check if we've reached max_limit
|
504
|
+
if max_limit is not None and result_count >= max_limit:
|
505
|
+
log.info(f"Reached max_limit of {max_limit} results, stopping processing")
|
506
|
+
break
|
507
|
+
else:
|
508
|
+
log.warning("No document found in result")
|
509
|
+
|
510
|
+
# If there are pages, check gently without assuming too much about the structure
|
511
|
+
# Only process if we haven't already hit the max_limit
|
512
|
+
if (max_limit is None or result_count < max_limit) and hasattr(response, 'pages'):
|
513
|
+
try:
|
514
|
+
# For each page (after the first which we've already processed)
|
515
|
+
for page in list(response.pages)[1:]: # Skip first page as we already processed it
|
516
|
+
if hasattr(page, 'results'):
|
517
|
+
for result in page.results:
|
518
|
+
if hasattr(result, 'document'):
|
519
|
+
document = result.document
|
520
|
+
all_documents.append(self.document_format(document))
|
521
|
+
result_count += 1
|
522
|
+
|
523
|
+
# Check if we've reached max_limit
|
524
|
+
if max_limit is not None and result_count >= max_limit:
|
525
|
+
log.info(f"Reached max_limit of {max_limit} results while processing pages")
|
526
|
+
break
|
527
|
+
else:
|
528
|
+
log.warning("No document found in result during page processing")
|
529
|
+
|
530
|
+
# Break out of the page loop if we've reached max_limit
|
531
|
+
if max_limit is not None and result_count >= max_limit:
|
532
|
+
break
|
533
|
+
except Exception as e:
|
534
|
+
# Don't let page iteration issues break the whole function
|
535
|
+
log.warning(f"Error during page iteration, proceeding with results already collected: {e}")
|
518
536
|
|
519
537
|
# Combine all documents into one long string
|
520
538
|
result_string = "\n\n".join(all_documents)
|
@@ -531,30 +549,52 @@ class DiscoveryEngineClient:
|
|
531
549
|
log.info(f'No results found in response: {response=}')
|
532
550
|
return []
|
533
551
|
|
534
|
-
|
535
|
-
#
|
536
|
-
|
537
|
-
if
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
552
|
+
# Simpler approach: Just process the direct results from the response
|
553
|
+
# This handles the case where it's just a simple SearchResponse
|
554
|
+
for result in response.results:
|
555
|
+
if hasattr(result, 'document'):
|
556
|
+
document = result.document
|
557
|
+
all_documents.append(self.document_format(document))
|
558
|
+
result_count += 1
|
559
|
+
|
560
|
+
# Check if we've reached max_limit
|
561
|
+
if max_limit is not None and result_count >= max_limit:
|
562
|
+
log.info(f"Reached max_limit of {max_limit} results, stopping processing")
|
563
|
+
break
|
564
|
+
else:
|
565
|
+
log.warning("No document found in result")
|
566
|
+
|
567
|
+
# If there are pages, check gently without assuming too much about the structure
|
568
|
+
# Only process if we haven't already hit the max_limit
|
569
|
+
if (max_limit is None or result_count < max_limit) and hasattr(response, 'pages'):
|
570
|
+
try:
|
571
|
+
# Since pages is an async iterator, we need special handling
|
572
|
+
first_page = True # Flag to skip first page (already processed above)
|
573
|
+
async for page in response.pages:
|
574
|
+
if first_page:
|
575
|
+
first_page = False
|
576
|
+
continue # Skip first page as we already processed it
|
577
|
+
|
578
|
+
if hasattr(page, 'results'):
|
579
|
+
for result in page.results:
|
580
|
+
if hasattr(result, 'document'):
|
581
|
+
document = result.document
|
582
|
+
all_documents.append(self.document_format(document))
|
583
|
+
result_count += 1
|
584
|
+
|
585
|
+
# Check if we've reached max_limit
|
586
|
+
if max_limit is not None and result_count >= max_limit:
|
587
|
+
log.info(f"Reached max_limit of {max_limit} results while processing pages")
|
588
|
+
break
|
589
|
+
else:
|
590
|
+
log.warning("No document found in result during page processing")
|
591
|
+
|
592
|
+
# Break out of the page loop if we've reached max_limit
|
593
|
+
if max_limit is not None and result_count >= max_limit:
|
594
|
+
break
|
595
|
+
except Exception as e:
|
596
|
+
# Don't let page iteration issues break the whole function
|
597
|
+
log.warning(f"Error during async page iteration, proceeding with results already collected: {e}")
|
558
598
|
|
559
599
|
# Combine all documents into one long string
|
560
600
|
result_string = "\n\n".join(all_documents)
|
@@ -884,33 +924,6 @@ class DiscoveryEngineClient:
|
|
884
924
|
except Exception as e:
|
885
925
|
log.info(f"No results {search_request.data_store_specs=}: {str(e)}")
|
886
926
|
return None
|
887
|
-
|
888
|
-
# Apply max_limit if needed
|
889
|
-
if content_search_spec_type=="documents" and max_limit is not None:
|
890
|
-
# For raw response objects (when parse_chunks_to_string=False)
|
891
|
-
if not parse_chunks_to_string:
|
892
|
-
# We need to limit the pager results before returning
|
893
|
-
limited_response = search_response
|
894
|
-
# Store the original pages iterator method
|
895
|
-
original_pages = limited_response.pages
|
896
|
-
|
897
|
-
# Override the pages property with a custom iterator that respects max_limit
|
898
|
-
def limited_pages_iterator():
|
899
|
-
results_count = 0
|
900
|
-
for page in original_pages:
|
901
|
-
yield page
|
902
|
-
|
903
|
-
# Count results in this page
|
904
|
-
if hasattr(page, 'results'):
|
905
|
-
results_count += len(page.results)
|
906
|
-
|
907
|
-
# Stop if we've reached max_limit
|
908
|
-
if results_count >= max_limit:
|
909
|
-
break
|
910
|
-
|
911
|
-
# Replace the pages property with our custom iterator
|
912
|
-
limited_response.pages = limited_pages_iterator()
|
913
|
-
return limited_response
|
914
927
|
|
915
928
|
if parse_chunks_to_string:
|
916
929
|
if content_search_spec_type=="chunks":
|
@@ -995,33 +1008,6 @@ class DiscoveryEngineClient:
|
|
995
1008
|
except Exception as e:
|
996
1009
|
log.info(f"No results {search_request.data_store_specs=}: {str(e)}")
|
997
1010
|
return None
|
998
|
-
|
999
|
-
# Apply max_limit if needed
|
1000
|
-
if content_search_spec_type=="documents" and max_limit is not None:
|
1001
|
-
# For raw response objects (when parse_chunks_to_string=False)
|
1002
|
-
if not parse_chunks_to_string:
|
1003
|
-
# We need to limit the pager results before returning
|
1004
|
-
limited_response = search_response
|
1005
|
-
# Store the original pages iterator method
|
1006
|
-
original_pages = limited_response.pages
|
1007
|
-
|
1008
|
-
# Override the pages property with a custom iterator that respects max_limit
|
1009
|
-
async def limited_pages_iterator():
|
1010
|
-
results_count = 0
|
1011
|
-
async for page in original_pages:
|
1012
|
-
yield page
|
1013
|
-
|
1014
|
-
# Count results in this page
|
1015
|
-
if hasattr(page, 'results'):
|
1016
|
-
results_count += len(page.results)
|
1017
|
-
|
1018
|
-
# Stop if we've reached max_limit
|
1019
|
-
if results_count >= max_limit:
|
1020
|
-
break
|
1021
|
-
|
1022
|
-
# Replace the pages property with our custom iterator
|
1023
|
-
limited_response.pages = limited_pages_iterator()
|
1024
|
-
return limited_response
|
1025
1011
|
|
1026
1012
|
if parse_chunks_to_string:
|
1027
1013
|
if content_search_spec_type=="chunks":
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|