sunholo 0.76.7__tar.gz → 0.76.9__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.7 → sunholo-0.76.9}/PKG-INFO +2 -2
- {sunholo-0.76.7 → sunholo-0.76.9}/setup.py +1 -1
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/vertex/__init__.py +2 -0
- sunholo-0.76.9/sunholo/vertex/extensions_call.py +284 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/vertex/extensions_class.py +4 -4
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo.egg-info/PKG-INFO +2 -2
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo.egg-info/SOURCES.txt +1 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/LICENSE.txt +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/MANIFEST.in +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/README.md +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/setup.cfg +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/flask/vac_routes.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/langserve.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/route.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/agents/swagger.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/archive/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/archive/archive.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/auth/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/auth/refresh.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/auth/run.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/azure/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/bots/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/bots/discord.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/bots/webapp.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/azure.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/images.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/publish.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/cli.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/configs.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/deploy.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/embedder.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/swagger.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/cli/vertex.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/components/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/components/llm.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/components/retriever.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/alloydb.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/database.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/lancedb.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/database/uuid.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/llamaindex/generate.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/logging.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/patches/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/patches/langchain/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/patches/langchain/lancedb.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/patches/langchain/vertexai.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/qna/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/qna/parsers.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/qna/retry.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/tools/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/__init__.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/api_key.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/big_context.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/config.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/config_class.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/gcp.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/parsers.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/utils/version.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/vertex/init.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo/vertex/safety.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/tests/test_chat_history.py +0 -0
- {sunholo-0.76.7 → sunholo-0.76.9}/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.9
|
|
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.9.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -2,3 +2,5 @@ from .init import init_vertex, init_genai
|
|
|
2
2
|
from .memory_tools import get_vertex_memories, print_grounding_response, get_google_search_grounding
|
|
3
3
|
from .safety import vertex_safety, genai_safety
|
|
4
4
|
from .extensions_class import VertexAIExtensions
|
|
5
|
+
from .extensions_call import get_extension_content
|
|
6
|
+
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
from .extensions_class import VertexAIExtensions
|
|
2
|
+
from ..utils import ConfigManager
|
|
3
|
+
from ..logging import log
|
|
4
|
+
import collections.abc
|
|
5
|
+
|
|
6
|
+
def get_extension_content(question: str, config: ConfigManager, project_id:str=None, **kwargs):
|
|
7
|
+
"""
|
|
8
|
+
Fetches content from extensions based on the provided question and configuration.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
question (str): The question to be processed by the extensions.
|
|
12
|
+
config (ConfigManager): The configuration manager instance.
|
|
13
|
+
**kwargs: Additional parameters to be passed to the extension.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
list: A list of responses from the extensions.
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
Assuming a YAML configuration file as follows:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
kind: vacConfig
|
|
23
|
+
vac:
|
|
24
|
+
my_vac:
|
|
25
|
+
extensions:
|
|
26
|
+
- extension_id: 8524997435263549440
|
|
27
|
+
operation_id: post_our_new_energy_invoke_one_generic
|
|
28
|
+
vac: our_generic
|
|
29
|
+
operation_params:
|
|
30
|
+
input:
|
|
31
|
+
question: ""
|
|
32
|
+
chat_history: []
|
|
33
|
+
source_filters: []
|
|
34
|
+
source_filters_and_or: false
|
|
35
|
+
search_kwargs:
|
|
36
|
+
k: 0
|
|
37
|
+
filter: ""
|
|
38
|
+
fetch_k: 0
|
|
39
|
+
private_docs: []
|
|
40
|
+
whole_document: false
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The function can be called as:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
config = ConfigManager()
|
|
47
|
+
question = "What is the capital of France?"
|
|
48
|
+
|
|
49
|
+
responses = get_extension_content(
|
|
50
|
+
question=question,
|
|
51
|
+
config=config,
|
|
52
|
+
input={
|
|
53
|
+
"chat_history": [{"role": "user", "content": "Hello"}],
|
|
54
|
+
"source_filters": ["PPA/"],
|
|
55
|
+
"search_kwargs": {"k": 50, "filter": "source ILIKE '%GermanPolicyforPPA/%'", "fetch_k": 100}
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
In this example, `operation_params` will be updated to:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
{
|
|
64
|
+
"input": {
|
|
65
|
+
"question": "What is the capital of France?",
|
|
66
|
+
"chat_history": [{"role": "user", "content": "Hello"}],
|
|
67
|
+
"source_filters": ["PPA/"],
|
|
68
|
+
"source_filters_and_or": false,
|
|
69
|
+
"search_kwargs": {
|
|
70
|
+
"k": 50,
|
|
71
|
+
"filter": "source ILIKE '%GermanPolicyforPPA/%'",
|
|
72
|
+
"fetch_k": 100
|
|
73
|
+
},
|
|
74
|
+
"private_docs": [],
|
|
75
|
+
"whole_document": false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
"""
|
|
80
|
+
extensions = config.vacConfig('extensions')
|
|
81
|
+
responses = []
|
|
82
|
+
for tool in extensions:
|
|
83
|
+
try:
|
|
84
|
+
ve = VertexAIExtensions(project_id)
|
|
85
|
+
|
|
86
|
+
# Merge operation_params from tool config and **kwargs
|
|
87
|
+
operation_params = tool.get('operation_params', {})
|
|
88
|
+
log.info(f'{operation_params=}')
|
|
89
|
+
operation_params_input = update_nested_params(operation_params, kwargs)
|
|
90
|
+
|
|
91
|
+
# Update the question in operation_params if it exists
|
|
92
|
+
operation_params_input = inject_question(question, operation_params)
|
|
93
|
+
|
|
94
|
+
response = ve.execute_extension(
|
|
95
|
+
operation_id=tool['operation_id'],
|
|
96
|
+
operation_params=operation_params_input,
|
|
97
|
+
extension_id=tool.get('extension_id'),
|
|
98
|
+
extension_display_name=tool.get('extension_display_name'),
|
|
99
|
+
vac=tool.get('vac')
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Dynamically get keys for answer and metadata from YAML configuration
|
|
103
|
+
output_config = operation_params.get('output', {})
|
|
104
|
+
answer_key = output_config.get('answer', 'answer')
|
|
105
|
+
metadata_key = output_config.get('metadata', 'metadata')
|
|
106
|
+
|
|
107
|
+
# Extract answer and metadata based on the specified keys
|
|
108
|
+
log.info(f'{answer_key} {metadata_key}')
|
|
109
|
+
|
|
110
|
+
answer = extract_nested_value(response, answer_key)
|
|
111
|
+
metadata = extract_nested_value(response, metadata_key)
|
|
112
|
+
|
|
113
|
+
log.info(f'{answer=} {metadata=}')
|
|
114
|
+
|
|
115
|
+
if answer and metadata:
|
|
116
|
+
responses.append(f"{answer}\nMetadata: {metadata}")
|
|
117
|
+
elif answer:
|
|
118
|
+
responses.append(answer)
|
|
119
|
+
|
|
120
|
+
except Exception as err:
|
|
121
|
+
log.error(f'Could not find vertex-extension response: {str(err)}')
|
|
122
|
+
answer = None
|
|
123
|
+
|
|
124
|
+
log.info(f'Vertex extension responses: {responses=}')
|
|
125
|
+
|
|
126
|
+
answers = "\n\n".join([resp for resp in responses if resp is not None])
|
|
127
|
+
|
|
128
|
+
return answers
|
|
129
|
+
|
|
130
|
+
def update_nested_params(original, updates):
|
|
131
|
+
"""
|
|
132
|
+
Recursively update nested dictionaries with new values.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
original (dict): The original dictionary to be updated.
|
|
136
|
+
updates (dict): The new values to be merged into the original dictionary.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
dict: The updated dictionary.
|
|
140
|
+
|
|
141
|
+
Example:
|
|
142
|
+
```python
|
|
143
|
+
original = {
|
|
144
|
+
"param1": "value1",
|
|
145
|
+
"nested_param": {
|
|
146
|
+
"sub_param1": "sub_value1"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
updates = {
|
|
151
|
+
"param1": "new_value1",
|
|
152
|
+
"nested_param": {
|
|
153
|
+
"sub_param1": "new_sub_value1"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
updated_params = update_nested_params(original, updates)
|
|
158
|
+
|
|
159
|
+
# updated_params will be:
|
|
160
|
+
# {
|
|
161
|
+
# "param1": "new_value1",
|
|
162
|
+
# "nested_param": {
|
|
163
|
+
# "sub_param1": "new_sub_value1"
|
|
164
|
+
# }
|
|
165
|
+
# }
|
|
166
|
+
```
|
|
167
|
+
"""
|
|
168
|
+
for key, value in updates.items():
|
|
169
|
+
if isinstance(value, collections.abc.Mapping):
|
|
170
|
+
original[key] = update_nested_params(original.get(key, {}), value)
|
|
171
|
+
else:
|
|
172
|
+
original[key] = value
|
|
173
|
+
return original
|
|
174
|
+
|
|
175
|
+
def inject_question(question, params):
|
|
176
|
+
"""
|
|
177
|
+
Recursively injects the question into nested dictionaries where the key is 'question' and the value is empty.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
question (str): The question to be injected.
|
|
181
|
+
params (dict): The dictionary where the question should be injected.
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
dict: The dictionary with the question injected.
|
|
185
|
+
|
|
186
|
+
Example:
|
|
187
|
+
```python
|
|
188
|
+
params = {
|
|
189
|
+
"input": {
|
|
190
|
+
"question": "",
|
|
191
|
+
"chat_history": [],
|
|
192
|
+
"source_filters": [],
|
|
193
|
+
"search_kwargs": {
|
|
194
|
+
"k": 0,
|
|
195
|
+
"filter": "",
|
|
196
|
+
"fetch_k": 0
|
|
197
|
+
},
|
|
198
|
+
"private_docs": [],
|
|
199
|
+
"whole_document": false
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
question = "What is the capital of France?"
|
|
204
|
+
|
|
205
|
+
updated_params = inject_question(question, params)
|
|
206
|
+
|
|
207
|
+
# updated_params will be:
|
|
208
|
+
# {
|
|
209
|
+
# "input": {
|
|
210
|
+
# "question": "What is the capital of France?",
|
|
211
|
+
# "chat_history": [],
|
|
212
|
+
# "source_filters": [],
|
|
213
|
+
# "search_kwargs": {
|
|
214
|
+
# "k": 0,
|
|
215
|
+
# "filter": "",
|
|
216
|
+
# "fetch_k": 0
|
|
217
|
+
# },
|
|
218
|
+
# "private_docs": [],
|
|
219
|
+
# "whole_document": false
|
|
220
|
+
# }
|
|
221
|
+
# }
|
|
222
|
+
```
|
|
223
|
+
"""
|
|
224
|
+
if isinstance(params, collections.abc.Mapping):
|
|
225
|
+
for key, value in params.items():
|
|
226
|
+
if isinstance(value, collections.abc.Mapping):
|
|
227
|
+
params[key] = inject_question(question, value)
|
|
228
|
+
elif key == 'question' and not value:
|
|
229
|
+
params[key] = question
|
|
230
|
+
return params
|
|
231
|
+
|
|
232
|
+
def extract_nested_value(data, key):
|
|
233
|
+
"""
|
|
234
|
+
Recursively extract a value from nested dictionaries based on the specified key or a dot-separated key path.
|
|
235
|
+
If the key is not dot-separated, it will find the first occurrence of that key in the nested dictionaries.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
data (dict): The dictionary to extract the value from.
|
|
239
|
+
key (str): The key or dot-separated key path to extract the value.
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
Any: The extracted value, or None if the key or key path is not found.
|
|
243
|
+
|
|
244
|
+
Example:
|
|
245
|
+
```python
|
|
246
|
+
data = {
|
|
247
|
+
"output": {
|
|
248
|
+
"content": "Some content",
|
|
249
|
+
"metadata": {"key1": "value1"}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
value = extract_nested_value(data, "content")
|
|
254
|
+
# value will be "Some content"
|
|
255
|
+
|
|
256
|
+
value = extract_nested_value(data, "output.metadata")
|
|
257
|
+
# value will be {"key1": "value1"}
|
|
258
|
+
```
|
|
259
|
+
"""
|
|
260
|
+
def search_key(data, key):
|
|
261
|
+
if isinstance(data, dict):
|
|
262
|
+
if key in data:
|
|
263
|
+
return data[key]
|
|
264
|
+
for k, v in data.items():
|
|
265
|
+
if isinstance(v, dict):
|
|
266
|
+
result = search_key(v, key)
|
|
267
|
+
if result is not None:
|
|
268
|
+
return result
|
|
269
|
+
return None
|
|
270
|
+
|
|
271
|
+
if '.' in key:
|
|
272
|
+
keys = key.split('.')
|
|
273
|
+
for k in keys:
|
|
274
|
+
if isinstance(data, dict) and k in data:
|
|
275
|
+
data = data[k]
|
|
276
|
+
else:
|
|
277
|
+
return None
|
|
278
|
+
return data
|
|
279
|
+
else:
|
|
280
|
+
return search_key(data, key)
|
|
281
|
+
|
|
282
|
+
if __name__ == "__main__":
|
|
283
|
+
config = ConfigManager("one_ai")
|
|
284
|
+
get_extension_content("What are PPAs in france like?", config=config)
|
|
@@ -276,11 +276,11 @@ class VertexAIExtensions:
|
|
|
276
276
|
vac: str=None):
|
|
277
277
|
|
|
278
278
|
if extension_display_name:
|
|
279
|
-
|
|
280
|
-
for
|
|
281
|
-
if
|
|
279
|
+
exts = self.list_extensions()
|
|
280
|
+
for ext in exts:
|
|
281
|
+
if ext.get('display_name') == extension_display_name:
|
|
282
282
|
log.info(f"Found extension_id for '{extension_display_name}'")
|
|
283
|
-
extension_id =
|
|
283
|
+
extension_id = ext['resource_name']
|
|
284
284
|
break
|
|
285
285
|
|
|
286
286
|
if extension_id:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.76.
|
|
3
|
+
Version: 0.76.9
|
|
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.9.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -131,6 +131,7 @@ sunholo/utils/timedelta.py
|
|
|
131
131
|
sunholo/utils/user_ids.py
|
|
132
132
|
sunholo/utils/version.py
|
|
133
133
|
sunholo/vertex/__init__.py
|
|
134
|
+
sunholo/vertex/extensions_call.py
|
|
134
135
|
sunholo/vertex/extensions_class.py
|
|
135
136
|
sunholo/vertex/init.py
|
|
136
137
|
sunholo/vertex/memory_tools.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|