sunholo 0.120.4__tar.gz → 0.120.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.120.4/src/sunholo.egg-info → sunholo-0.120.5}/PKG-INFO +1 -1
- {sunholo-0.120.4 → sunholo-0.120.5}/pyproject.toml +1 -1
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/auth/refresh.py +1 -3
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/file_handling.py +36 -6
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/streaming/streaming.py +21 -6
- {sunholo-0.120.4 → sunholo-0.120.5/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.120.4 → sunholo-0.120.5}/LICENSE.txt +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/MANIFEST.in +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/README.md +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/setup.cfg +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/database.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/discovery_engine/cli.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/embedder/embed_metadata.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/tests/test_async.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/tests/test_async_genai2.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/tests/test_chat_history.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/tests/test_config.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/tests/test_genai2.py +0 -0
- {sunholo-0.120.4 → sunholo-0.120.5}/tests/test_unstructured.py +0 -0
@@ -9,9 +9,7 @@ from ..custom_logging import log
|
|
9
9
|
def get_default_email():
|
10
10
|
|
11
11
|
# https://stackoverflow.com/questions/64234214/how-to-generate-a-blob-signed-url-in-google-cloud-run
|
12
|
-
gcs_credentials, project_id =
|
13
|
-
if gcs_credentials is None:
|
14
|
-
gcs_credentials, project_id = refresh_credentials()
|
12
|
+
gcs_credentials, project_id = refresh_credentials()
|
15
13
|
|
16
14
|
if gcs_credentials is None:
|
17
15
|
log.error("Could not refresh the credentials properly.")
|
@@ -12,6 +12,7 @@ import traceback
|
|
12
12
|
try:
|
13
13
|
import google.generativeai as genai
|
14
14
|
from google import genai as genaiv2
|
15
|
+
from google.genai import types
|
15
16
|
|
16
17
|
except ImportError:
|
17
18
|
genai = None
|
@@ -106,13 +107,18 @@ def sanitize_file(filename):
|
|
106
107
|
# Limit the length
|
107
108
|
return sanitized_name[:40]
|
108
109
|
|
109
|
-
async def construct_file_content(gs_list,
|
110
|
+
async def construct_file_content(gs_list,
|
111
|
+
bucket:str,
|
112
|
+
genai_lib=False,
|
113
|
+
timeout=60,
|
114
|
+
genai_lib_vertex=False):
|
110
115
|
"""
|
111
116
|
Args:
|
112
117
|
- gs_list: a list of dicts representing files in a bucket
|
113
118
|
- bucket: The bucket the files are in
|
114
119
|
- genai_lib: whether its using the genai SDK
|
115
120
|
- timeout: timeout in seconds for the gather operation
|
121
|
+
- genai_lib_vertex: bool whether to use the vertex version of the genai library, using default credentials
|
116
122
|
"""
|
117
123
|
|
118
124
|
file_list = []
|
@@ -130,7 +136,28 @@ async def construct_file_content(gs_list, bucket:str, genai_lib=False, timeout=6
|
|
130
136
|
if not file_list:
|
131
137
|
return [{"role": "user", "parts": [{"text": "No eligible contentTypes were found"}]}]
|
132
138
|
|
139
|
+
# export GOOGLE_GENAI_USE_VERTEXAI=true
|
140
|
+
# export GOOGLE_CLOUD_PROJECT='your-project-id'
|
141
|
+
# export GOOGLE_CLOUD_LOCATION='us-central1'
|
133
142
|
content = []
|
143
|
+
if genai_lib_vertex or os.getenv("GOOGLE_GENAI_USE_VERTEXAI"):
|
144
|
+
client = genaiv2.Client(vertexai=True)
|
145
|
+
# we can just use the gs:// uri directly
|
146
|
+
for file_info in file_list:
|
147
|
+
img_url = f"gs://{bucket}/{file_info['storagePath']}"
|
148
|
+
mime_type = file_info['contentType']
|
149
|
+
display_name = file_info['name']
|
150
|
+
display_url = img_url
|
151
|
+
file_content = types.Part.from_uri(
|
152
|
+
file_uri=img_url,
|
153
|
+
mime_type=mime_type,
|
154
|
+
)
|
155
|
+
file_content_list = [file_content,
|
156
|
+
f"You have been given the ability to read and work with filename '{display_name}' with {mime_type=} {display_url=}"]
|
157
|
+
content.extend(file_content_list)
|
158
|
+
|
159
|
+
return content
|
160
|
+
|
134
161
|
|
135
162
|
# Loop through the valid files and process them
|
136
163
|
tasks = []
|
@@ -139,8 +166,7 @@ async def construct_file_content(gs_list, bucket:str, genai_lib=False, timeout=6
|
|
139
166
|
display_url = file_info.get('url')
|
140
167
|
mime_type = file_info['contentType']
|
141
168
|
# Generate a unique name for each file
|
142
|
-
|
143
|
-
unique_name = sanitize_file(f"{original_name}")
|
169
|
+
unique_name= sanitize_file(file_info['name'])
|
144
170
|
|
145
171
|
display_name = file_info['name']
|
146
172
|
log.info(f"Processing {unique_name=} {display_name=}")
|
@@ -205,7 +231,8 @@ async def download_gcs_upload_genai(img_url,
|
|
205
231
|
name=None,
|
206
232
|
display_url=None,
|
207
233
|
display_name=None,
|
208
|
-
retries=3, delay=2,
|
234
|
+
retries=3, delay=2,
|
235
|
+
genai_lib=False):
|
209
236
|
"""
|
210
237
|
Downloads and uploads a file with retries in case of failure.
|
211
238
|
Thread-safe implementation using unique file paths.
|
@@ -216,6 +243,8 @@ async def download_gcs_upload_genai(img_url,
|
|
216
243
|
- name: str Optional name, else a random one will be created
|
217
244
|
- retries: int Number of retry attempts before failing.
|
218
245
|
- delay: int Initial delay between retries, exponentially increasing.
|
246
|
+
- genai_lin: bool whether to use newer genai library to upload files
|
247
|
+
|
219
248
|
|
220
249
|
Returns:
|
221
250
|
- downloaded_content: The result of the file upload if successful.
|
@@ -242,7 +271,6 @@ async def download_gcs_upload_genai(img_url,
|
|
242
271
|
|
243
272
|
extension = mimetypes.guess_extension(mime_type)
|
244
273
|
|
245
|
-
# Create a unique directory for this upload task
|
246
274
|
# Create a unique directory for this upload task
|
247
275
|
unique_id = str(uuid.uuid4())
|
248
276
|
temp_dir = os.path.join(tempfile.gettempdir(), f"upload_{unique_id}")
|
@@ -275,14 +303,16 @@ async def download_gcs_upload_genai(img_url,
|
|
275
303
|
return {"role": "user", "parts": [{"file_data": downloaded_content},
|
276
304
|
{"text": f"You have been given the ability to read and work with filename '{display_name}' with {mime_type=} {display_url=}"}
|
277
305
|
]}
|
306
|
+
|
278
307
|
else:
|
308
|
+
|
279
309
|
client = genaiv2.Client()
|
280
310
|
|
281
311
|
# Use semaphore to limit concurrent uploads
|
282
312
|
async with upload_semaphore:
|
283
313
|
downloaded_content = await asyncio.to_thread(
|
284
314
|
client.files.upload,
|
285
|
-
|
315
|
+
path=file_path, # Use the unsanitized path for filesystem access
|
286
316
|
config=dict(mime_type=mime_type, display_name=display_name, name=api_name)
|
287
317
|
)
|
288
318
|
|
@@ -209,12 +209,27 @@ async def start_streaming_chat_async(question, vector_name, qna_func_async, chat
|
|
209
209
|
stop_event.set()
|
210
210
|
await chat_task # Ensure the async task is awaited
|
211
211
|
|
212
|
-
# Handle final
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
212
|
+
# Handle final flush of any remaining content
|
213
|
+
content_to_send = await content_buffer.async_read()
|
214
|
+
if content_to_send:
|
215
|
+
log.info(f"==Flush Async==\n{content_to_send}")
|
216
|
+
yield content_to_send
|
217
|
+
await content_buffer.async_clear()
|
218
|
+
|
219
|
+
# Handle final result to match non-async behavior
|
220
|
+
if kwargs.get("stream_only"):
|
221
|
+
log.info("stream_only so finishing now")
|
222
|
+
final_yield = ""
|
223
|
+
else:
|
224
|
+
log.info("Sending final full message plus sources...")
|
225
|
+
if not result_queue.empty():
|
226
|
+
final_result = result_queue.get()
|
227
|
+
final_yield = parse_output(final_result)
|
228
|
+
else:
|
229
|
+
final_yield = ""
|
230
|
+
|
231
|
+
# Match the non-async behavior - yield the parsed output directly, not as JSON
|
232
|
+
yield final_yield
|
218
233
|
|
219
234
|
|
220
235
|
def generate_proxy_stream(stream_to_f, user_input, vector_name, chat_history, generate_f_output, **kwargs):
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|