sunholo 0.120.0__tar.gz → 0.120.1__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.120.0/src/sunholo.egg-info → sunholo-0.120.1}/PKG-INFO +1 -1
- {sunholo-0.120.0 → sunholo-0.120.1}/pyproject.toml +1 -1
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/file_handling.py +52 -19
- {sunholo-0.120.0 → sunholo-0.120.1/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.120.0 → sunholo-0.120.1}/LICENSE.txt +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/MANIFEST.in +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/README.md +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/setup.cfg +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/auth/refresh.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/database.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/discovery_engine/cli.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/embedder/embed_metadata.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/tests/test_async.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/tests/test_async_genai2.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/tests/test_chat_history.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/tests/test_config.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/tests/test_genai2.py +0 -0
- {sunholo-0.120.0 → sunholo-0.120.1}/tests/test_unstructured.py +0 -0
@@ -79,24 +79,40 @@ ALLOWED_MIME_TYPES = set(AUDIO_MIMES + VIDEO_MIMES + IMAGE_MIMES + DOCUMENT_MIME
|
|
79
79
|
# ]
|
80
80
|
|
81
81
|
def sanitize_file(filename):
|
82
|
+
"""
|
83
|
+
Sanitize filename to conform to Gemini API requirements:
|
84
|
+
- Only lowercase alphanumeric characters and dashes
|
85
|
+
- Cannot begin or end with a dash
|
86
|
+
"""
|
82
87
|
# Split the filename into name and extension
|
83
88
|
name, extension = os.path.splitext(filename)
|
84
89
|
|
85
|
-
#
|
86
|
-
|
87
|
-
|
90
|
+
# Convert to lowercase
|
91
|
+
name = name.lower()
|
92
|
+
|
93
|
+
# Replace any non-alphanumeric characters (including underscores) with dashes
|
94
|
+
sanitized_name = re.sub(r'[^a-z0-9]', '-', name)
|
95
|
+
|
96
|
+
# Remove consecutive dashes
|
97
|
+
sanitized_name = re.sub(r'-+', '-', sanitized_name)
|
98
|
+
|
99
|
+
# Remove leading or trailing dashes
|
100
|
+
sanitized_name = sanitized_name.strip('-')
|
101
|
+
|
102
|
+
# If the name is empty after sanitization, use a default
|
103
|
+
if not sanitized_name:
|
104
|
+
sanitized_name = 'file'
|
88
105
|
|
89
|
-
#
|
106
|
+
# Limit the length
|
90
107
|
return sanitized_name[:40]
|
91
108
|
|
92
|
-
async def construct_file_content(gs_list, bucket:str, genai_lib=False):
|
109
|
+
async def construct_file_content(gs_list, bucket:str, genai_lib=False, timeout=60):
|
93
110
|
"""
|
94
|
-
Thread-safe implementation for processing multiple files concurrently.
|
95
|
-
|
96
111
|
Args:
|
97
112
|
- gs_list: a list of dicts representing files in a bucket
|
98
113
|
- bucket: The bucket the files are in
|
99
114
|
- genai_lib: whether its using the genai SDK
|
115
|
+
- timeout: timeout in seconds for the gather operation
|
100
116
|
"""
|
101
117
|
|
102
118
|
file_list = []
|
@@ -112,7 +128,7 @@ async def construct_file_content(gs_list, bucket:str, genai_lib=False):
|
|
112
128
|
log.warning(f'{the_mime_type} is not in allowed MIME types for {element.get("name")}')
|
113
129
|
|
114
130
|
if not file_list:
|
115
|
-
return {"role": "user", "parts": [{"text": "No eligible contentTypes were found"}]}
|
131
|
+
return [{"role": "user", "parts": [{"text": "No eligible contentTypes were found"}]}]
|
116
132
|
|
117
133
|
content = []
|
118
134
|
|
@@ -122,9 +138,12 @@ async def construct_file_content(gs_list, bucket:str, genai_lib=False):
|
|
122
138
|
img_url = f"gs://{bucket}/{file_info['storagePath']}"
|
123
139
|
display_url = file_info.get('url')
|
124
140
|
mime_type = file_info['contentType']
|
125
|
-
# Generate a unique name for each file
|
141
|
+
# Generate a unique name for each file
|
142
|
+
import uuid
|
126
143
|
original_name = sanitize_file(file_info['name'])
|
127
|
-
|
144
|
+
unique_id = str(uuid.uuid4())[:8]
|
145
|
+
unique_name = sanitize_file(f"{original_name}-{unique_id}")
|
146
|
+
|
128
147
|
display_name = file_info['name']
|
129
148
|
log.info(f"Processing {unique_name=} {display_name=}")
|
130
149
|
|
@@ -148,16 +167,30 @@ async def construct_file_content(gs_list, bucket:str, genai_lib=False):
|
|
148
167
|
genai_lib=genai_lib)
|
149
168
|
)
|
150
169
|
|
151
|
-
# Process files
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
170
|
+
# Process files with timeout
|
171
|
+
if tasks:
|
172
|
+
try:
|
173
|
+
# Add timeout to prevent hanging
|
174
|
+
task_results = await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), timeout=timeout)
|
175
|
+
|
176
|
+
# Process results, handle any exceptions
|
177
|
+
for result in task_results:
|
178
|
+
if isinstance(result, Exception):
|
179
|
+
log.error(f"Task failed with error: {str(result)}")
|
180
|
+
# Add error message to content
|
181
|
+
content.append({"role": "user", "parts": [{"text": f"Error processing file: {str(result)}"}]})
|
182
|
+
else:
|
183
|
+
# Normalize the result structure based on genai_lib
|
184
|
+
if genai_lib and isinstance(result, list):
|
185
|
+
content.append(result[0]) # The file object
|
186
|
+
content.append({"role": "user", "parts": [{"text": result[1]}]}) # The message
|
187
|
+
else:
|
188
|
+
content.append(result)
|
189
|
+
except asyncio.TimeoutError:
|
190
|
+
log.error(f"Timeout occurred after {timeout} seconds while processing files")
|
191
|
+
content.append({"role": "user", "parts": [{"text": f"Some files could not be processed within the time limit ({timeout} seconds)"}]})
|
159
192
|
|
160
|
-
|
193
|
+
log.info(f"construct_file_content completed with {len(content)} items")
|
161
194
|
return content
|
162
195
|
|
163
196
|
# Helper function to handle each file download with error handling
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|