sunholo 0.76.2__tar.gz → 0.76.4__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.76.2 → sunholo-0.76.4}/PKG-INFO +2 -2
- {sunholo-0.76.2 → sunholo-0.76.4}/setup.py +1 -1
- sunholo-0.76.4/sunholo/auth/__init__.py +2 -0
- sunholo-0.76.4/sunholo/auth/refresh.py +55 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/auth/run.py +7 -2
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/vertex.py +2 -2
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/gcs/download_url.py +4 -30
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/vertex/extensions_class.py +24 -6
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/vertex/init.py +7 -2
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo.egg-info/PKG-INFO +2 -2
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo.egg-info/SOURCES.txt +1 -0
- sunholo-0.76.2/sunholo/auth/__init__.py +0 -2
- {sunholo-0.76.2 → sunholo-0.76.4}/LICENSE.txt +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/MANIFEST.in +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/README.md +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/setup.cfg +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/langserve.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/route.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/agents/swagger.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/archive/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/archive/archive.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/azure/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/bots/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/bots/discord.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/bots/webapp.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/azure.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/images.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/publish.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/cli.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/configs.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/deploy.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/embedder.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/cli/swagger.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/components/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/components/llm.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/components/retriever.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/alloydb.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/database.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/lancedb.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/database/uuid.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/llamaindex/generate.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/logging.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/patches/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/patches/langchain/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/patches/langchain/lancedb.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/patches/langchain/vertexai.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/qna/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/qna/parsers.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/qna/retry.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/tools/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/api_key.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/big_context.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/config.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/config_class.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/gcp.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/parsers.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/utils/version.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo/vertex/safety.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/tests/test_chat_history.py +0 -0
- {sunholo-0.76.2 → sunholo-0.76.4}/tests/test_config.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.76.
|
|
3
|
+
Version: 0.76.4
|
|
4
4
|
Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
|
|
5
5
|
Home-page: https://github.com/sunholo-data/sunholo-py
|
|
6
|
-
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.76.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.76.4.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# needs to be in minimal to check gcp
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import google.auth
|
|
5
|
+
from google.auth.transport import requests
|
|
6
|
+
from ..utils.gcp import is_running_on_gcp
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from ..logging import log
|
|
10
|
+
|
|
11
|
+
def get_default_email():
|
|
12
|
+
if not refresh_credentials():
|
|
13
|
+
log.error("Could not refresh the credentials properly.")
|
|
14
|
+
return None
|
|
15
|
+
# https://stackoverflow.com/questions/64234214/how-to-generate-a-blob-signed-url-in-google-cloud-run
|
|
16
|
+
|
|
17
|
+
gcs_credentials, project_id = get_default_creds()
|
|
18
|
+
|
|
19
|
+
service_account_email = getattr(gcs_credentials, 'service_account_email', None)
|
|
20
|
+
# If you use a service account credential, you can use the embedded email
|
|
21
|
+
if not service_account_email:
|
|
22
|
+
service_account_email = os.getenv('GCS_MAIL_USER')
|
|
23
|
+
if not service_account_email:
|
|
24
|
+
log.error("Could not create the credentials for signed requests - no credentials.service_account_email or GCS_MAIL_USER with roles/iam.serviceAccountTokenCreator")
|
|
25
|
+
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
log.info(f"Found default email: {service_account_email=} for {project_id=}")
|
|
29
|
+
return service_account_email
|
|
30
|
+
|
|
31
|
+
def get_default_creds():
|
|
32
|
+
gcs_credentials = None
|
|
33
|
+
project_id = None
|
|
34
|
+
gcs_credentials, project_id = google.auth.default()
|
|
35
|
+
|
|
36
|
+
return gcs_credentials, project_id
|
|
37
|
+
|
|
38
|
+
def refresh_credentials():
|
|
39
|
+
if not is_running_on_gcp():
|
|
40
|
+
log.debug("Not running on Google Cloud so no credentials available for GCS.")
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
gcs_credentials, project_id = get_default_creds()
|
|
44
|
+
|
|
45
|
+
if not gcs_credentials.token or gcs_credentials.expired or not gcs_credentials.valid:
|
|
46
|
+
try:
|
|
47
|
+
gcs_credentials.refresh(requests.Request())
|
|
48
|
+
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
except Exception as e:
|
|
52
|
+
log.error(f"Failed to refresh gcs credentials: {e}")
|
|
53
|
+
|
|
54
|
+
return False
|
|
55
|
+
|
|
@@ -39,8 +39,7 @@ def get_id_token(url: str) -> str:
|
|
|
39
39
|
|
|
40
40
|
return get_local_gcloud_token()
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
def get_header(vector_name) -> Optional[dict]:
|
|
42
|
+
def get_cloud_run_token(vector_name):
|
|
44
43
|
if has_multivac_api_key():
|
|
45
44
|
|
|
46
45
|
return {"x-api-key": get_multivac_api_key()}
|
|
@@ -67,6 +66,12 @@ def get_header(vector_name) -> Optional[dict]:
|
|
|
67
66
|
}
|
|
68
67
|
log.info(f"Authenticating for run_url {run_url} from {caller_frame.f_code.co_name}")
|
|
69
68
|
id_token = get_id_token(run_url)
|
|
69
|
+
|
|
70
|
+
return id_token
|
|
71
|
+
|
|
72
|
+
def get_header(vector_name) -> Optional[dict]:
|
|
73
|
+
id_token = get_cloud_run_token(vector_name)
|
|
74
|
+
|
|
70
75
|
headers = {"Authorization": f"Bearer {id_token}"}
|
|
71
76
|
#log.info(f"id_token {id_token}")
|
|
72
77
|
return headers
|
|
@@ -3,8 +3,8 @@ from ..vertex import VertexAIExtensions
|
|
|
3
3
|
from .sun_rich import console
|
|
4
4
|
|
|
5
5
|
def deploy_extension(args):
|
|
6
|
-
vex = VertexAIExtensions()
|
|
7
|
-
console.rule(f"Creating Vertex extension '{args.display_name}'")
|
|
6
|
+
vex = VertexAIExtensions(args.project)
|
|
7
|
+
console.rule(f"Creating Vertex extension '{args.display_name}' within '{args.project}'")
|
|
8
8
|
|
|
9
9
|
vex.create_extension(
|
|
10
10
|
args.display_name,
|
|
@@ -3,8 +3,6 @@ from urllib.parse import quote
|
|
|
3
3
|
from datetime import datetime, timedelta
|
|
4
4
|
|
|
5
5
|
# needs to be in minimal to check gcp
|
|
6
|
-
import google.auth
|
|
7
|
-
from google.auth.transport import requests
|
|
8
6
|
from google.auth.exceptions import RefreshError
|
|
9
7
|
|
|
10
8
|
try:
|
|
@@ -14,6 +12,7 @@ except ImportError:
|
|
|
14
12
|
|
|
15
13
|
from ..logging import log
|
|
16
14
|
from ..utils.gcp import is_running_on_gcp
|
|
15
|
+
from ..auth.refresh import refresh_credentials, get_default_creds, get_default_email
|
|
17
16
|
from io import BytesIO
|
|
18
17
|
try:
|
|
19
18
|
from PIL import Image
|
|
@@ -77,47 +76,22 @@ def get_bytes_from_gcs(gs_uri):
|
|
|
77
76
|
|
|
78
77
|
if is_running_on_gcp():
|
|
79
78
|
# Perform a refresh request to get the access token of the current credentials (Else, it's None)
|
|
80
|
-
gcs_credentials, project_id =
|
|
79
|
+
gcs_credentials, project_id = get_default_creds()
|
|
81
80
|
# Prepare global variables for client reuse
|
|
82
81
|
if storage:
|
|
83
82
|
gcs_client = storage.Client()
|
|
84
83
|
|
|
85
|
-
def refresh_credentials():
|
|
86
|
-
if not is_running_on_gcp():
|
|
87
|
-
log.debug("Not running on Google Cloud so no credentials available for GCS.")
|
|
88
|
-
return False
|
|
89
|
-
if not gcs_credentials.token or gcs_credentials.expired or not gcs_credentials.valid:
|
|
90
|
-
try:
|
|
91
|
-
gcs_credentials.refresh(requests.Request())
|
|
92
|
-
except Exception as e:
|
|
93
|
-
log.error(f"Failed to refresh gcs credentials: {e}")
|
|
94
|
-
return False
|
|
95
|
-
return True
|
|
96
|
-
|
|
97
|
-
refresh_credentials()
|
|
98
|
-
|
|
99
84
|
def get_bucket(bucket_name):
|
|
100
85
|
if bucket_name not in gcs_bucket_cache:
|
|
101
86
|
gcs_bucket_cache[bucket_name] = gcs_client.get_bucket(bucket_name)
|
|
102
87
|
return gcs_bucket_cache[bucket_name]
|
|
103
88
|
|
|
104
89
|
def sign_gcs_url(bucket_name:str, object_name:str, expiry_secs = 86400):
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return None
|
|
108
|
-
# https://stackoverflow.com/questions/64234214/how-to-generate-a-blob-signed-url-in-google-cloud-run
|
|
90
|
+
|
|
91
|
+
service_account_email = get_default_email()
|
|
109
92
|
|
|
110
93
|
expires = datetime.now() + timedelta(seconds=expiry_secs)
|
|
111
94
|
|
|
112
|
-
service_account_email = getattr(gcs_credentials, 'service_account_email', None)
|
|
113
|
-
# If you use a service account credential, you can use the embedded email
|
|
114
|
-
if not service_account_email:
|
|
115
|
-
service_account_email = os.getenv('GCS_MAIL_USER')
|
|
116
|
-
if service_account_email is None:
|
|
117
|
-
log.error("For local testing must set a GCS_MAIL_USER to sign GCS URLs")
|
|
118
|
-
log.error("Could not create the credentials for signed requests - no credentials.service_account_email or GCS_MAIL_USER with roles/iam.serviceAccountTokenCreator")
|
|
119
|
-
return None
|
|
120
|
-
|
|
121
95
|
try:
|
|
122
96
|
bucket = get_bucket(bucket_name)
|
|
123
97
|
blob = bucket.blob(object_name)
|
|
@@ -7,6 +7,7 @@ from .init import init_vertex
|
|
|
7
7
|
from ..logging import log
|
|
8
8
|
from ..utils.gcp_project import get_gcp_project
|
|
9
9
|
from ..utils.parsers import validate_extension_id
|
|
10
|
+
from ..utils import ConfigManager
|
|
10
11
|
import base64
|
|
11
12
|
import json
|
|
12
13
|
from io import StringIO
|
|
@@ -50,7 +51,7 @@ class VertexAIExtensions:
|
|
|
50
51
|
operation_params = operation_params)
|
|
51
52
|
```
|
|
52
53
|
"""
|
|
53
|
-
def __init__(self):
|
|
54
|
+
def __init__(self, project_id=None):
|
|
54
55
|
if extensions is None:
|
|
55
56
|
raise ImportError("VertexAIExtensions needs vertexai.previewextensions to be installed. Install via `pip install sunholo[gcp]`")
|
|
56
57
|
|
|
@@ -70,6 +71,7 @@ class VertexAIExtensions:
|
|
|
70
71
|
self.manifest = {}
|
|
71
72
|
self.created_extensions = []
|
|
72
73
|
self.bucket_name = os.getenv('EXTENSIONS_BUCKET')
|
|
74
|
+
init_vertex(location=self.location, project_id=project_id)
|
|
73
75
|
|
|
74
76
|
def list_extensions(self, project_id:str=None):
|
|
75
77
|
project_id = project_id or get_gcp_project()
|
|
@@ -113,7 +115,7 @@ class VertexAIExtensions:
|
|
|
113
115
|
raise ValueError('Please specify env var EXTENSIONS_BUCKET for location to upload openapi spec')
|
|
114
116
|
|
|
115
117
|
|
|
116
|
-
self.openapi_file_gcs = self.upload_to_gcs(filename
|
|
118
|
+
self.openapi_file_gcs = self.upload_to_gcs(filename)
|
|
117
119
|
|
|
118
120
|
def load_tool_use_examples(self, filename: str):
|
|
119
121
|
import yaml
|
|
@@ -211,7 +213,7 @@ class VertexAIExtensions:
|
|
|
211
213
|
log.info(f"Setting extension bucket name to {bucket_name}")
|
|
212
214
|
self.bucket_name = bucket_name
|
|
213
215
|
|
|
214
|
-
listed_extensions = self.list_extensions()
|
|
216
|
+
listed_extensions = self.list_extensions(project_id)
|
|
215
217
|
log.info(f"Listing extensions:\n {listed_extensions}")
|
|
216
218
|
for ext in listed_extensions:
|
|
217
219
|
if ext.get('display_name') == display_name:
|
|
@@ -247,8 +249,15 @@ class VertexAIExtensions:
|
|
|
247
249
|
|
|
248
250
|
return extension.resource_name
|
|
249
251
|
|
|
250
|
-
def execute_extension(
|
|
251
|
-
|
|
252
|
+
def execute_extension(
|
|
253
|
+
self,
|
|
254
|
+
operation_id: str,
|
|
255
|
+
operation_params: dict,
|
|
256
|
+
extension_id: str=None,
|
|
257
|
+
project_id: str=None,
|
|
258
|
+
vac: str=None):
|
|
259
|
+
|
|
260
|
+
init_vertex(location=self.location, project_id=project_id)
|
|
252
261
|
|
|
253
262
|
if not extension_id:
|
|
254
263
|
extension_name = self.created_extension.resource_name
|
|
@@ -271,12 +280,21 @@ class VertexAIExtensions:
|
|
|
271
280
|
auth_config=None # on cloud run it sorts itself out via default creds(?)
|
|
272
281
|
|
|
273
282
|
if not is_running_on_cloudrun():
|
|
274
|
-
from ..auth import get_local_gcloud_token
|
|
283
|
+
from ..auth import get_local_gcloud_token, get_cloud_run_token
|
|
275
284
|
log.warning("Using local authentication via gcloud")
|
|
276
285
|
auth_config = {
|
|
277
286
|
"authType": "OAUTH",
|
|
278
287
|
"oauth_config": {"access_token": f"'{get_local_gcloud_token()}'"}
|
|
279
288
|
}
|
|
289
|
+
elif vac:
|
|
290
|
+
log.info(f"Using authentication via Cloud Run via {vac=}")
|
|
291
|
+
|
|
292
|
+
auth_config = {
|
|
293
|
+
"authType": "OAUTH",
|
|
294
|
+
"oauth_config": {"access_token": f"'{get_cloud_run_token(vac)}'"}
|
|
295
|
+
}
|
|
296
|
+
else:
|
|
297
|
+
log.warning("No vac configuration and not running locally so no authentication being set for this extension API call")
|
|
280
298
|
|
|
281
299
|
response = extension.execute(
|
|
282
300
|
operation_id=operation_id,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from ..logging import log
|
|
2
2
|
from ..utils.gcp_project import get_gcp_project
|
|
3
|
+
from ..auth.refresh import get_default_email
|
|
3
4
|
import os
|
|
4
5
|
|
|
5
6
|
def init_genai():
|
|
@@ -19,7 +20,7 @@ def init_genai():
|
|
|
19
20
|
|
|
20
21
|
genai.configure(api_key=GOOGLE_API_KEY)
|
|
21
22
|
|
|
22
|
-
def init_vertex(gcp_config=None, location="eu"):
|
|
23
|
+
def init_vertex(gcp_config=None, location="eu", project_id=None):
|
|
23
24
|
"""
|
|
24
25
|
Initializes the Vertex AI environment using the provided Google Cloud Platform configuration.
|
|
25
26
|
|
|
@@ -62,6 +63,10 @@ def init_vertex(gcp_config=None, location="eu"):
|
|
|
62
63
|
project_id = gcp_config.get('project_id')
|
|
63
64
|
location = gcp_config.get('location') or location
|
|
64
65
|
else:
|
|
65
|
-
project_id = get_gcp_project()
|
|
66
|
+
project_id = project_id or get_gcp_project()
|
|
67
|
+
|
|
68
|
+
log.info(f"Auth with email: {get_default_email()} in {project_id}")
|
|
66
69
|
|
|
67
70
|
vertexai.init(project=project_id, location=location)
|
|
71
|
+
|
|
72
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.76.
|
|
3
|
+
Version: 0.76.4
|
|
4
4
|
Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
|
|
5
5
|
Home-page: https://github.com/sunholo-data/sunholo-py
|
|
6
|
-
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.76.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.76.4.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|