sunholo 0.76.5__tar.gz → 0.76.7__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.5 → sunholo-0.76.7}/PKG-INFO +2 -2
- {sunholo-0.76.5 → sunholo-0.76.7}/setup.py +1 -1
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/auth/run.py +3 -3
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/azure/event_grid.py +6 -4
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/vertex.py +3 -4
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/vertex/extensions_class.py +60 -41
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo.egg-info/PKG-INFO +2 -2
- {sunholo-0.76.5 → sunholo-0.76.7}/LICENSE.txt +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/MANIFEST.in +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/README.md +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/setup.cfg +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/langserve.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/route.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/agents/swagger.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/archive/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/archive/archive.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/auth/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/auth/refresh.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/azure/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/bots/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/bots/discord.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/bots/webapp.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/azure.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/images.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/publish.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/cli.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/configs.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/deploy.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/embedder.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/cli/swagger.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/components/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/components/llm.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/components/retriever.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/alloydb.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/database.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/lancedb.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/database/uuid.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/llamaindex/generate.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/logging.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/patches/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/patches/langchain/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/patches/langchain/lancedb.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/patches/langchain/vertexai.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/qna/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/qna/parsers.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/qna/retry.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/tools/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/api_key.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/big_context.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/config.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/config_class.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/gcp.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/parsers.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/utils/version.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/vertex/init.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo/vertex/safety.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/tests/test_chat_history.py +0 -0
- {sunholo-0.76.5 → sunholo-0.76.7}/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.7
|
|
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.7.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -66,12 +66,12 @@ def get_cloud_run_token(vector_name):
|
|
|
66
66
|
}
|
|
67
67
|
log.info(f"Authenticating for run_url {run_url} from {caller_frame.f_code.co_name}")
|
|
68
68
|
id_token = get_id_token(run_url)
|
|
69
|
-
|
|
69
|
+
#log.info(f"id_token {id_token}")
|
|
70
70
|
return id_token
|
|
71
71
|
|
|
72
72
|
def get_header(vector_name) -> Optional[dict]:
|
|
73
73
|
id_token = get_cloud_run_token(vector_name)
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
headers = {"Authorization": f"Bearer {id_token}"}
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
return headers
|
|
@@ -12,9 +12,10 @@ def process_azure_blob_event(events: list) -> tuple:
|
|
|
12
12
|
tuple: A tuple containing the blob URL, attributes as metadata, and the vector name.
|
|
13
13
|
|
|
14
14
|
Example of Event Grid schema:
|
|
15
|
+
```
|
|
15
16
|
{
|
|
16
|
-
"topic": "/subscriptions/
|
|
17
|
-
"subject": "/blobServices/default/containers/
|
|
17
|
+
"topic": "/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.Storage/storageAccounts/storage-account",
|
|
18
|
+
"subject": "/blobServices/default/containers/container/blobs/blob",
|
|
18
19
|
"eventType": "Microsoft.Storage.BlobCreated",
|
|
19
20
|
"eventTime": "2021-01-01T12:34:56.789Z",
|
|
20
21
|
"id": "event-id",
|
|
@@ -26,8 +27,8 @@ def process_azure_blob_event(events: list) -> tuple:
|
|
|
26
27
|
"contentType": "application/octet-stream",
|
|
27
28
|
"contentLength": 524288,
|
|
28
29
|
"blobType": "BlockBlob",
|
|
29
|
-
"url": "https://
|
|
30
|
-
"sequencer": "
|
|
30
|
+
"url": "https://storage-account.blob.core.windows.net/container/blob",
|
|
31
|
+
"sequencer": "0000000000000000000000000",
|
|
31
32
|
"storageDiagnostics": {
|
|
32
33
|
"batchId": "batch-id"
|
|
33
34
|
}
|
|
@@ -35,6 +36,7 @@ def process_azure_blob_event(events: list) -> tuple:
|
|
|
35
36
|
"dataVersion": "",
|
|
36
37
|
"metadataVersion": "1"
|
|
37
38
|
}
|
|
39
|
+
```
|
|
38
40
|
"""
|
|
39
41
|
storage_blob_created_event = "Microsoft.Storage.BlobCreated"
|
|
40
42
|
|
|
@@ -12,15 +12,14 @@ def deploy_extension(args):
|
|
|
12
12
|
tool_example_file=args.tool_example_file,
|
|
13
13
|
open_api_file=args.open_api_file,
|
|
14
14
|
service_account=args.service_account,
|
|
15
|
-
project_id=args.project,
|
|
16
15
|
bucket_name=args.bucket_name
|
|
17
16
|
)
|
|
18
|
-
extensions = vex.list_extensions(
|
|
17
|
+
extensions = vex.list_extensions()
|
|
19
18
|
console.print(extensions)
|
|
20
19
|
|
|
21
20
|
def list_extensions(args):
|
|
22
|
-
vex = VertexAIExtensions()
|
|
23
|
-
extensions = vex.list_extensions(
|
|
21
|
+
vex = VertexAIExtensions(args.project)
|
|
22
|
+
extensions = vex.list_extensions()
|
|
24
23
|
console.print(extensions)
|
|
25
24
|
|
|
26
25
|
def setup_vertex_subparser(subparsers):
|
|
@@ -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.gcp import is_running_on_cloudrun
|
|
10
11
|
from ..auth import get_local_gcloud_token, get_cloud_run_token
|
|
11
12
|
import base64
|
|
12
13
|
import json
|
|
@@ -19,7 +20,7 @@ class VertexAIExtensions:
|
|
|
19
20
|
|
|
20
21
|
```python
|
|
21
22
|
from sunholo.vertex import VertexAIExtensions
|
|
22
|
-
vex = VertexAIExtensions()
|
|
23
|
+
vex = VertexAIExtensions(project_id='your-project')
|
|
23
24
|
vex.list_extensions()
|
|
24
25
|
# [{'resource_name': 'projects/374404277595/locations/us-central1/extensions/770924776838397952',
|
|
25
26
|
# 'display_name': 'Code Interpreter',
|
|
@@ -53,7 +54,7 @@ class VertexAIExtensions:
|
|
|
53
54
|
"""
|
|
54
55
|
def __init__(self, project_id=None):
|
|
55
56
|
if extensions is None:
|
|
56
|
-
raise ImportError("VertexAIExtensions needs vertexai.
|
|
57
|
+
raise ImportError("VertexAIExtensions needs vertexai.preview extensions to be installed. Install via `pip install sunholo'[gcp]'`")
|
|
57
58
|
|
|
58
59
|
self.CODE_INTERPRETER_WRITTEN_FILES = []
|
|
59
60
|
self.css_styles = """
|
|
@@ -71,12 +72,13 @@ class VertexAIExtensions:
|
|
|
71
72
|
self.manifest = {}
|
|
72
73
|
self.created_extensions = []
|
|
73
74
|
self.bucket_name = os.getenv('EXTENSIONS_BUCKET')
|
|
74
|
-
|
|
75
|
+
self.project_id = project_id or get_gcp_project()
|
|
76
|
+
self.access_token = None
|
|
77
|
+
init_vertex(location=self.location, project_id=self.project_id)
|
|
75
78
|
|
|
76
|
-
def list_extensions(self
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
the_list = extensions.Extension.list(project=project_id)
|
|
79
|
+
def list_extensions(self):
|
|
80
|
+
log.info(f"Creating extension within {self.project_id=}")
|
|
81
|
+
the_list = extensions.Extension.list(project=self.project_id)
|
|
80
82
|
|
|
81
83
|
extensions_list = []
|
|
82
84
|
for ext in the_list:
|
|
@@ -109,12 +111,25 @@ class VertexAIExtensions:
|
|
|
109
111
|
|
|
110
112
|
return self_uri
|
|
111
113
|
|
|
112
|
-
def upload_openapi_file(self, filename: str):
|
|
114
|
+
def upload_openapi_file(self, filename: str, vac:str=None):
|
|
115
|
+
if vac:
|
|
116
|
+
from ..agents.route import route_vac
|
|
117
|
+
import yaml
|
|
118
|
+
|
|
119
|
+
new_url = route_vac(vac)
|
|
120
|
+
|
|
121
|
+
log.info(f'Overwriting extension URL with VAC url for {vac=} - {new_url=}')
|
|
122
|
+
|
|
123
|
+
openapi = yaml.safe_load(filename)
|
|
124
|
+
|
|
125
|
+
openapi['servers'][0]['url'] = new_url
|
|
126
|
+
with open(filename, 'w') as file:
|
|
127
|
+
yaml.dump(openapi, file, sort_keys=False)
|
|
128
|
+
|
|
113
129
|
self.validate_openapi(filename)
|
|
114
130
|
if not self.bucket_name:
|
|
115
131
|
raise ValueError('Please specify env var EXTENSIONS_BUCKET for location to upload openapi spec')
|
|
116
132
|
|
|
117
|
-
|
|
118
133
|
self.openapi_file_gcs = self.upload_to_gcs(filename)
|
|
119
134
|
|
|
120
135
|
def load_tool_use_examples(self, filename: str):
|
|
@@ -126,21 +141,25 @@ class VertexAIExtensions:
|
|
|
126
141
|
# google.cloud.aiplatform_v1beta1.types.ToolUseExample
|
|
127
142
|
return self.tool_use_examples
|
|
128
143
|
|
|
144
|
+
def get_auth_token(self):
|
|
145
|
+
from google.auth import default
|
|
146
|
+
from google.auth.transport.requests import Request
|
|
147
|
+
|
|
148
|
+
credentials, project_id = default()
|
|
149
|
+
credentials.refresh(Request())
|
|
150
|
+
self.access_token = credentials.token
|
|
151
|
+
|
|
152
|
+
return self.access_token
|
|
129
153
|
|
|
130
154
|
def update_tool_use_examples_via_patch(self):
|
|
131
155
|
import requests
|
|
132
156
|
import json
|
|
133
|
-
from google.auth import default
|
|
134
|
-
from google.auth.transport.requests import Request
|
|
135
157
|
|
|
136
158
|
extension = self.created_extension
|
|
137
159
|
if extension is None:
|
|
138
160
|
raise ValueError("Need to create the extension first")
|
|
139
161
|
|
|
140
|
-
|
|
141
|
-
credentials, project_id = default()
|
|
142
|
-
credentials.refresh(Request())
|
|
143
|
-
access_token = credentials.token
|
|
162
|
+
self.get_auth_token()
|
|
144
163
|
|
|
145
164
|
ENDPOINT=f"{self.location}-aiplatform.googleapis.com"
|
|
146
165
|
URL=f"https://{ENDPOINT}/v1beta1"
|
|
@@ -151,7 +170,7 @@ class VertexAIExtensions:
|
|
|
151
170
|
url = f"{URL}/{extension_id}"
|
|
152
171
|
log.info(f"PATCH {url}")
|
|
153
172
|
headers = {
|
|
154
|
-
"Authorization": f"Bearer {access_token}",
|
|
173
|
+
"Authorization": f"Bearer {self.access_token}",
|
|
155
174
|
"Content-Type": "application/json"
|
|
156
175
|
}
|
|
157
176
|
|
|
@@ -202,25 +221,24 @@ class VertexAIExtensions:
|
|
|
202
221
|
tool_example_file: str = None,
|
|
203
222
|
runtime_config: dict = None,
|
|
204
223
|
service_account: str = None,
|
|
205
|
-
|
|
206
|
-
|
|
224
|
+
bucket_name: str = None,
|
|
225
|
+
vac: str = None):
|
|
207
226
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
extension_name = f"projects/{project_id}/locations/us-central1/extensions/{validate_extension_id(display_name)}"
|
|
227
|
+
log.info(f"Creating extension within {self.project_id=}")
|
|
228
|
+
extension_name = f"projects/{self.project_id}/locations/us-central1/extensions/{validate_extension_id(display_name)}"
|
|
211
229
|
|
|
212
230
|
if bucket_name:
|
|
213
231
|
log.info(f"Setting extension bucket name to {bucket_name}")
|
|
214
232
|
self.bucket_name = bucket_name
|
|
215
233
|
|
|
216
|
-
listed_extensions = self.list_extensions(
|
|
234
|
+
listed_extensions = self.list_extensions()
|
|
217
235
|
log.info(f"Listing extensions:\n {listed_extensions}")
|
|
218
236
|
for ext in listed_extensions:
|
|
219
237
|
if ext.get('display_name') == display_name:
|
|
220
238
|
raise NameError(f"display_name {display_name} already exists. Delete it or rename your new extension")
|
|
221
239
|
|
|
222
240
|
if open_api_file:
|
|
223
|
-
self.upload_openapi_file(open_api_file)
|
|
241
|
+
self.upload_openapi_file(open_api_file, vac)
|
|
224
242
|
|
|
225
243
|
manifest = self.create_extension_manifest(
|
|
226
244
|
display_name,
|
|
@@ -254,48 +272,49 @@ class VertexAIExtensions:
|
|
|
254
272
|
operation_id: str,
|
|
255
273
|
operation_params: dict,
|
|
256
274
|
extension_id: str=None,
|
|
257
|
-
|
|
275
|
+
extension_display_name: str=None,
|
|
258
276
|
vac: str=None):
|
|
259
|
-
|
|
260
|
-
init_vertex(location=self.location, project_id=project_id)
|
|
261
277
|
|
|
262
|
-
if
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
278
|
+
if extension_display_name:
|
|
279
|
+
extensions = self.list_extensions()
|
|
280
|
+
for extension in extensions:
|
|
281
|
+
if extension.get('display_name') == extension_display_name:
|
|
282
|
+
log.info(f"Found extension_id for '{extension_display_name}'")
|
|
283
|
+
extension_id = extension['resource_name']
|
|
284
|
+
break
|
|
285
|
+
|
|
286
|
+
if extension_id:
|
|
267
287
|
extension_id = str(extension_id)
|
|
268
288
|
if not extension_id.startswith("projects/"):
|
|
269
|
-
|
|
270
|
-
extension_name = f"projects/{project_id}/locations/{self.location}/extensions/{extension_id}"
|
|
289
|
+
extension_name = f"projects/{self.project_id}/locations/{self.location}/extensions/{extension_id}"
|
|
271
290
|
else:
|
|
272
291
|
extension_name = extension_id
|
|
292
|
+
else:
|
|
293
|
+
extension_name = self.created_extension.resource_name
|
|
294
|
+
if not extension_name:
|
|
295
|
+
raise ValueError("Must specify extension_id or extension_name - both were None")
|
|
273
296
|
|
|
274
297
|
extension = extensions.Extension(extension_name)
|
|
275
298
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
# local testing auth
|
|
279
|
-
from ..utils.gcp import is_running_on_cloudrun
|
|
280
|
-
auth_config=None # on cloud run it sorts itself out via default creds(?)
|
|
281
|
-
|
|
299
|
+
auth_config=None
|
|
282
300
|
if not is_running_on_cloudrun():
|
|
283
301
|
|
|
284
302
|
log.warning("Using local authentication via gcloud")
|
|
285
303
|
auth_config = {
|
|
286
304
|
"authType": "OAUTH",
|
|
287
|
-
"oauth_config": {"access_token": f"
|
|
305
|
+
"oauth_config": {"access_token": f"{get_local_gcloud_token()}"}
|
|
288
306
|
}
|
|
289
307
|
elif vac:
|
|
290
308
|
log.info(f"Using authentication via Cloud Run via {vac=}")
|
|
291
309
|
|
|
292
310
|
auth_config = {
|
|
293
311
|
"authType": "OAUTH",
|
|
294
|
-
"oauth_config": {"access_token": f"
|
|
312
|
+
"oauth_config": {"access_token": f"{get_cloud_run_token(vac)}"}
|
|
295
313
|
}
|
|
296
314
|
else:
|
|
297
315
|
log.warning("No vac configuration and not running locally so no authentication being set for this extension API call")
|
|
298
316
|
|
|
317
|
+
log.info(f"Executing extension {extension_name=} with {operation_id=} and {operation_params=}")
|
|
299
318
|
response = extension.execute(
|
|
300
319
|
operation_id=operation_id,
|
|
301
320
|
operation_params=operation_params,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.76.
|
|
3
|
+
Version: 0.76.7
|
|
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.7.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|