sunholo 0.118.2__tar.gz → 0.118.5__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.118.2/src/sunholo.egg-info → sunholo-0.118.5}/PKG-INFO +1 -1
- {sunholo-0.118.2 → sunholo-0.118.5}/pyproject.toml +1 -1
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/file_handling.py +30 -12
- {sunholo-0.118.2 → sunholo-0.118.5/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.118.2 → sunholo-0.118.5}/LICENSE.txt +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/MANIFEST.in +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/README.md +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/setup.cfg +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/auth/refresh.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/database.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/tests/test_async.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/tests/test_async_genai2.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/tests/test_chat_history.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/tests/test_config.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/tests/test_genai2.py +0 -0
- {sunholo-0.118.2 → sunholo-0.118.5}/tests/test_unstructured.py +0 -0
|
@@ -10,8 +10,10 @@ import os
|
|
|
10
10
|
import traceback
|
|
11
11
|
try:
|
|
12
12
|
import google.generativeai as genai
|
|
13
|
+
from google import genai as genaiv2
|
|
13
14
|
except ImportError:
|
|
14
15
|
genai = None
|
|
16
|
+
genaiv2 = None
|
|
15
17
|
|
|
16
18
|
DOCUMENT_MIMES = [
|
|
17
19
|
'application/pdf',
|
|
@@ -85,7 +87,7 @@ def sanitize_file(filename):
|
|
|
85
87
|
# Reattach the original extension
|
|
86
88
|
return sanitized_name[:40]
|
|
87
89
|
|
|
88
|
-
async def construct_file_content(gs_list, bucket:str):
|
|
90
|
+
async def construct_file_content(gs_list, bucket:str, genai_lib=False):
|
|
89
91
|
"""
|
|
90
92
|
Args:
|
|
91
93
|
- gs_list: a list of dicts representing files in a bucket
|
|
@@ -93,6 +95,7 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
93
95
|
- storagePath: The path in the bucket
|
|
94
96
|
- name: The name of the file
|
|
95
97
|
- bucket: The bucket the files are in
|
|
98
|
+
- genai: whether its using the genai SDK
|
|
96
99
|
|
|
97
100
|
"""
|
|
98
101
|
|
|
@@ -124,7 +127,12 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
124
127
|
display_name = file_info['name']
|
|
125
128
|
log.info(f"Processing {name=} {display_name=}")
|
|
126
129
|
try:
|
|
127
|
-
|
|
130
|
+
if not genai_lib:
|
|
131
|
+
myfile = genai.get_file(name)
|
|
132
|
+
else:
|
|
133
|
+
client = genaiv2.Client()
|
|
134
|
+
myfile = client.files.get(name)
|
|
135
|
+
|
|
128
136
|
content.append(
|
|
129
137
|
{"role": "user", "parts": [
|
|
130
138
|
{"file_data": myfile},
|
|
@@ -132,7 +140,6 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
132
140
|
]
|
|
133
141
|
})
|
|
134
142
|
log.info(f"Found existing genai.get_file {name=}")
|
|
135
|
-
|
|
136
143
|
except Exception as e:
|
|
137
144
|
log.info(f"Not found checking genai.get_file: '{name}' {str(e)}")
|
|
138
145
|
tasks.append(
|
|
@@ -140,7 +147,8 @@ async def construct_file_content(gs_list, bucket:str):
|
|
|
140
147
|
mime_type=mime_type,
|
|
141
148
|
name=name,
|
|
142
149
|
display_url=display_url,
|
|
143
|
-
display_name=display_name
|
|
150
|
+
display_name=display_name,
|
|
151
|
+
genai_lib=genai_lib)
|
|
144
152
|
)
|
|
145
153
|
|
|
146
154
|
# Run all tasks in parallel
|
|
@@ -164,7 +172,7 @@ async def download_gcs_upload_genai(img_url,
|
|
|
164
172
|
name=None,
|
|
165
173
|
display_url=None,
|
|
166
174
|
display_name=None,
|
|
167
|
-
retries=3, delay=2):
|
|
175
|
+
retries=3, delay=2, genai_lib=False):
|
|
168
176
|
import aiofiles
|
|
169
177
|
from google.generativeai.types import file_types
|
|
170
178
|
"""
|
|
@@ -213,13 +221,23 @@ async def download_gcs_upload_genai(img_url,
|
|
|
213
221
|
|
|
214
222
|
# Upload the file and get its content reference
|
|
215
223
|
try:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
if not genai_lib:
|
|
225
|
+
downloaded_content: file_types.File = await asyncio.to_thread(
|
|
226
|
+
partial(genai.upload_file, name=name, mime_type=mime_type, display_name=display_name),
|
|
227
|
+
sanitized_file
|
|
228
|
+
)
|
|
229
|
+
return {"role": "user", "parts": [{"file_data": downloaded_content},
|
|
230
|
+
{"text": f"You have been given the ability to read and work with filename '{display_name=}' with {mime_type=} {display_url=}"}
|
|
231
|
+
]}
|
|
232
|
+
else:
|
|
233
|
+
client = genaiv2.Client()
|
|
234
|
+
downloaded_content = await asyncio.to_thread(
|
|
235
|
+
partial(client.files.upload, config=dict(mime_type=mime_type, display_name=display_name)),
|
|
236
|
+
sanitized_file
|
|
237
|
+
)
|
|
238
|
+
return {"role": "user", "parts": [{"file_data": downloaded_content},
|
|
239
|
+
{"text": f"You have been given the ability to read and work with filename '{display_name=}' with {mime_type=} {display_url=}"}
|
|
240
|
+
]}
|
|
223
241
|
except Exception as err:
|
|
224
242
|
msg = f"Could not upload {sanitized_file} to genai.upload_file: {str(err)} {traceback.format_exc()} {display_url=}"
|
|
225
243
|
log.error(msg)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|