sunholo 0.136.2__tar.gz → 0.137.0__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.2/src/sunholo.egg-info → sunholo-0.137.0}/PKG-INFO +1 -1
- {sunholo-0.136.2 → sunholo-0.137.0}/pyproject.toml +1 -1
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/discovery_engine/discovery_engine_client.py +88 -48
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/invoke/async_class.py +7 -5
- {sunholo-0.136.2 → sunholo-0.137.0/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.136.2 → sunholo-0.137.0}/LICENSE.txt +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/MANIFEST.in +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/README.md +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/setup.cfg +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/auth/refresh.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/database.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/discovery_engine/cli.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/embedder/embed_metadata.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/file_handling.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/ollama/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/ollama/ollama_images.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/tests/test_async.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/tests/test_async_genai2.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/tests/test_chat_history.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/tests/test_config.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/tests/test_genai2.py +0 -0
- {sunholo-0.136.2 → sunholo-0.137.0}/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)
|
@@ -8,11 +8,12 @@ from tenacity import AsyncRetrying, retry_if_exception_type, wait_random_exponen
|
|
8
8
|
log = setup_logging("sunholo_AsyncTaskRunner")
|
9
9
|
|
10
10
|
class AsyncTaskRunner:
|
11
|
-
def __init__(self, retry_enabled=False, retry_kwargs=None, timeout=120):
|
11
|
+
def __init__(self, retry_enabled:bool=False, retry_kwargs:dict=None, timeout:int=120, max_concurrency:int=20):
|
12
12
|
self.tasks = []
|
13
13
|
self.retry_enabled = retry_enabled
|
14
14
|
self.retry_kwargs = retry_kwargs or {}
|
15
15
|
self.timeout = timeout
|
16
|
+
self.semaphore = asyncio.Semaphore(max_concurrency)
|
16
17
|
|
17
18
|
def add_task(self, func: Callable[..., Any], *args: Any, **kwargs: Any):
|
18
19
|
"""
|
@@ -136,10 +137,11 @@ class AsyncTaskRunner:
|
|
136
137
|
Returns:
|
137
138
|
Any: The result of the task.
|
138
139
|
"""
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
async with self.semaphore: # Use semaphore to limit concurrent executions
|
141
|
+
if asyncio.iscoroutinefunction(func):
|
142
|
+
return await func(*args, **kwargs)
|
143
|
+
else:
|
144
|
+
return await asyncio.to_thread(func, *args, **kwargs)
|
143
145
|
|
144
146
|
async def _send_heartbeat(self, func_name: str, completion_event: asyncio.Event, queue: asyncio.Queue, interval: int = 2):
|
145
147
|
"""
|
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
|