sunholo 0.62.0__tar.gz → 0.62.2__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.62.0 → sunholo-0.62.2}/PKG-INFO +2 -2
- {sunholo-0.62.0 → sunholo-0.62.2}/setup.py +1 -1
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/embedder.py +5 -3
- sunholo-0.62.2/sunholo/llamaindex/get_files.py +19 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/llamaindex/import_files.py +2 -84
- sunholo-0.62.2/sunholo/vertex/__init__.py +2 -0
- sunholo-0.62.2/sunholo/vertex/memory_tools.py +91 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo.egg-info/PKG-INFO +2 -2
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo.egg-info/SOURCES.txt +3 -1
- sunholo-0.62.0/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/LICENSE.txt +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/MANIFEST.in +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/README.md +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/setup.cfg +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/langserve.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/route.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/archive/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/archive/archive.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/auth/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/auth/run.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/bots/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/bots/discord.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/bots/webapp.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/data_to_embed_pubsub.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/images.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/publish.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/cli.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/configs.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/deploy.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/components/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/components/llm.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/components/prompt.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/components/retriever.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/alloydb.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/database.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/lancedb.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/database/uuid.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/llamaindex/generate.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/logging.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/patches/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/patches/langchain/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/patches/langchain/lancedb.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/patches/langchain/vertexai.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/qna/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/qna/parsers.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/qna/retry.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/__init__.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/big_context.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/config.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/gcp.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/parsers.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo/utils/user_ids.py +0 -0
- /sunholo-0.62.0/sunholo/vertex/init_vertex.py → /sunholo-0.62.2/sunholo/vertex/init.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/tests/test_chat_history.py +0 -0
- {sunholo-0.62.0 → sunholo-0.62.2}/tests/test_config.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.62.
|
|
3
|
+
Version: 0.62.2
|
|
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.62.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.62.2.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -9,6 +9,7 @@ from .sun_rich import console
|
|
|
9
9
|
from rich.progress import Progress
|
|
10
10
|
|
|
11
11
|
from .chat_vac import resolve_service_url, invoke_vac
|
|
12
|
+
from .run_proxy import stop_proxy
|
|
12
13
|
|
|
13
14
|
def create_metadata(vac, metadata):
|
|
14
15
|
now_utc = datetime.now(timezone.utc)
|
|
@@ -103,8 +104,8 @@ def embed_command(args):
|
|
|
103
104
|
json_data = encode_data(args.vac_name, args.data, args.metadata, args.local_chunks)
|
|
104
105
|
chunk_res = invoke_vac(f"{chunk_url}/pubsub_to_store", json_data)
|
|
105
106
|
|
|
107
|
+
stop_proxy("chunker")
|
|
106
108
|
if args.only_chunk:
|
|
107
|
-
|
|
108
109
|
return chunk_res
|
|
109
110
|
|
|
110
111
|
if not args.local_chunks:
|
|
@@ -124,13 +125,13 @@ def embed_command(args):
|
|
|
124
125
|
|
|
125
126
|
if not chunk_res:
|
|
126
127
|
console.print(f"[bold red]ERROR: Did not get any chunks from {chunk_url} for {args.data}")
|
|
127
|
-
|
|
128
|
+
stop_proxy("embedder")
|
|
128
129
|
return
|
|
129
130
|
|
|
130
131
|
chunks = chunk_res.get('chunks')
|
|
131
132
|
if not chunks:
|
|
132
133
|
console.print(f"[bold red]ERROR: No chunks found within json data: {str(chunk_res)} [/bold red]")
|
|
133
|
-
|
|
134
|
+
stop_proxy("embedder")
|
|
134
135
|
return
|
|
135
136
|
|
|
136
137
|
embeds = []
|
|
@@ -156,6 +157,7 @@ def embed_command(args):
|
|
|
156
157
|
embeds.append(embed_res)
|
|
157
158
|
progress.advance(task)
|
|
158
159
|
|
|
160
|
+
stop_proxy("embedder")
|
|
159
161
|
console.rule("Embedding pipeline finished")
|
|
160
162
|
|
|
161
163
|
return embed_res
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from vertexai.preview import rag
|
|
3
|
+
except ImportError:
|
|
4
|
+
rag = None
|
|
5
|
+
|
|
6
|
+
# Create a RAG Corpus, Import Files
|
|
7
|
+
def fetch_corpus(project_id, location, rag_id):
|
|
8
|
+
corpus_name = f"projects/{project_id}/locations/{location}/ragCorpora/{rag_id}"
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
return rag.get_corpus(name=corpus_name)
|
|
12
|
+
except Exception as err:
|
|
13
|
+
#log.warning(f"Failed to fetch corpus - creating new corpus {str(err)}")
|
|
14
|
+
# it does not create a unique corpus, display_name can be in multiple rag_ids
|
|
15
|
+
#try:
|
|
16
|
+
# corpus = rag.create_corpus(display_name=vector_name, description=description)
|
|
17
|
+
#except Exception as err:
|
|
18
|
+
# log.error(f"Failed to get or create corpus {str(err)}")
|
|
19
|
+
raise ValueError(f"Failed to get or create corpus: {str(err)}")
|
|
@@ -6,89 +6,7 @@ except ImportError:
|
|
|
6
6
|
from ..logging import log
|
|
7
7
|
from ..utils.config import load_config_key
|
|
8
8
|
from ..vertex import init_vertex
|
|
9
|
-
from
|
|
10
|
-
|
|
11
|
-
# Create a RAG Corpus, Import Files
|
|
12
|
-
|
|
13
|
-
def get_corpus(vector_name):
|
|
14
|
-
"""
|
|
15
|
-
Retrieves a LlamaIndex corpus from Vertex AI based on the provided Google Cloud configuration.
|
|
16
|
-
|
|
17
|
-
This function constructs a corpus name using project details from the configuration and attempts
|
|
18
|
-
to fetch the corresponding corpus. If the corpus cannot be retrieved, it raises an error.
|
|
19
|
-
|
|
20
|
-
Parameters:
|
|
21
|
-
- vector_name: The name of the of VAC
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
- List of corpus objects fetched from Vertex AI.
|
|
25
|
-
|
|
26
|
-
Raises:
|
|
27
|
-
- ValueError: If any of the required configurations (project_id, location, or rag_id) are missing,
|
|
28
|
-
or if the corpus cannot be retrieved.
|
|
29
|
-
|
|
30
|
-
Example:
|
|
31
|
-
```python
|
|
32
|
-
|
|
33
|
-
# Fetch the corpus
|
|
34
|
-
try:
|
|
35
|
-
corpus = get_corpus("edmonbrain")
|
|
36
|
-
print("Corpus fetched successfully:", corpus)
|
|
37
|
-
except ValueError as e:
|
|
38
|
-
print("Error fetching corpus:", str(e))
|
|
39
|
-
```
|
|
40
|
-
"""
|
|
41
|
-
gcp_config = load_config_key("gcp_config", vector_name=vector_name, type="vacConfig")
|
|
42
|
-
|
|
43
|
-
if not rag:
|
|
44
|
-
raise ValueError("Need to install vertexai module via `pip install sunholo[gcp]`")
|
|
45
|
-
|
|
46
|
-
global_project_id = gcp_config.get('project_id')
|
|
47
|
-
global_location = gcp_config.get('location')
|
|
48
|
-
global_rag_id = gcp_config.get('rag_id')
|
|
49
|
-
|
|
50
|
-
memories = load_memories(vector_name)
|
|
51
|
-
corpii = []
|
|
52
|
-
for memory in memories:
|
|
53
|
-
for key, value in memory.items(): # Now iterate over the dictionary
|
|
54
|
-
log.info(f"Found memory {key}")
|
|
55
|
-
vectorstore = value.get('vectorstore')
|
|
56
|
-
if vectorstore == "llamaindex":
|
|
57
|
-
log.info(f"Found vectorstore {vectorstore}")
|
|
58
|
-
rag_id = value.get('rag_id')
|
|
59
|
-
project_id = gcp_config.get('project_id')
|
|
60
|
-
location = gcp_config.get('location')
|
|
61
|
-
corpus = fetch_corpus(
|
|
62
|
-
project_id=project_id or global_project_id,
|
|
63
|
-
location=location or global_location,
|
|
64
|
-
rag_id=rag_id or global_rag_id
|
|
65
|
-
)
|
|
66
|
-
corpii.append(corpus)
|
|
67
|
-
|
|
68
|
-
if not project_id or not global_project_id:
|
|
69
|
-
raise ValueError("Need config.gcp.project_id or config.memory.llamaindex.project_id to configure llamaindex on VertexAI")
|
|
70
|
-
if not rag_id or not global_project_id:
|
|
71
|
-
raise ValueError("Need config.gcp.rag_id or config.memory.llamaindex.rag_id to configure llamaindex on VertexAI. Create via `rag.create_corpus(display_name=vector_name, description=description)`")
|
|
72
|
-
|
|
73
|
-
if not corpii:
|
|
74
|
-
raise ValueError("No llamaindex Vertex corpus configurations could be found")
|
|
75
|
-
|
|
76
|
-
return corpii
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def fetch_corpus(project_id, location, rag_id):
|
|
80
|
-
corpus_name = f"projects/{project_id}/locations/{location}/ragCorpora/{rag_id}"
|
|
81
|
-
|
|
82
|
-
try:
|
|
83
|
-
return rag.get_corpus(name=corpus_name)
|
|
84
|
-
except Exception as err:
|
|
85
|
-
#log.warning(f"Failed to fetch corpus - creating new corpus {str(err)}")
|
|
86
|
-
# it does not create a unique corpus, display_name can be in multiple rag_ids
|
|
87
|
-
#try:
|
|
88
|
-
# corpus = rag.create_corpus(display_name=vector_name, description=description)
|
|
89
|
-
#except Exception as err:
|
|
90
|
-
# log.error(f"Failed to get or create corpus {str(err)}")
|
|
91
|
-
raise ValueError(f"Failed to get or create corpus: {str(err)}")
|
|
9
|
+
from .get_files import fetch_corpus
|
|
92
10
|
|
|
93
11
|
|
|
94
12
|
def do_llamaindex(message_data, metadata, vector_name):
|
|
@@ -127,7 +45,7 @@ def do_llamaindex(message_data, metadata, vector_name):
|
|
|
127
45
|
raise ValueError(f"Need config.{vector_name}.gcp_config to configure llamaindex on VertexAI")
|
|
128
46
|
|
|
129
47
|
init_vertex(gcp_config)
|
|
130
|
-
corpus =
|
|
48
|
+
corpus = fetch_corpus(gcp_config)
|
|
131
49
|
#display_name = load_config_key("display_name", vector_name=vector_name, filename="config/llm_config.yaml")
|
|
132
50
|
#description = load_config_key("description", vector_name=vector_name, filename="config/llm_config.yaml")
|
|
133
51
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from vertexai.preview import rag
|
|
3
|
+
from vertexai.preview.generative_models import Tool, grounding
|
|
4
|
+
except ImportError:
|
|
5
|
+
rag = None
|
|
6
|
+
|
|
7
|
+
from ..logging import log
|
|
8
|
+
from ..utils.config import load_config_key
|
|
9
|
+
from ..components import load_memories
|
|
10
|
+
from ..llamaindex.get_files import fetch_corpus
|
|
11
|
+
|
|
12
|
+
def get_vertex_memories(vector_name):
|
|
13
|
+
"""
|
|
14
|
+
Retrieves a LlamaIndex corpus from Vertex AI based on the provided Google Cloud configuration.
|
|
15
|
+
|
|
16
|
+
This function constructs a corpus name using project details from the configuration and attempts
|
|
17
|
+
to fetch the corresponding corpus. If the corpus cannot be retrieved, it raises an error.
|
|
18
|
+
|
|
19
|
+
Parameters:
|
|
20
|
+
- vector_name: The name of the of VAC
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
- List of corpus objects fetched from Vertex AI.
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
- ValueError: If any of the required configurations (project_id, location, or rag_id) are missing,
|
|
27
|
+
or if the corpus cannot be retrieved.
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
```python
|
|
31
|
+
|
|
32
|
+
# Fetch the corpus
|
|
33
|
+
try:
|
|
34
|
+
corpus = get_corpus("edmonbrain")
|
|
35
|
+
print("Corpus fetched successfully:", corpus)
|
|
36
|
+
except ValueError as e:
|
|
37
|
+
print("Error fetching corpus:", str(e))
|
|
38
|
+
```
|
|
39
|
+
"""
|
|
40
|
+
gcp_config = load_config_key("gcp_config", vector_name=vector_name, type="vacConfig")
|
|
41
|
+
|
|
42
|
+
if not rag:
|
|
43
|
+
raise ValueError("Need to install vertexai module via `pip install sunholo[gcp]`")
|
|
44
|
+
|
|
45
|
+
global_project_id = gcp_config.get('project_id')
|
|
46
|
+
global_location = gcp_config.get('location')
|
|
47
|
+
global_rag_id = gcp_config.get('rag_id')
|
|
48
|
+
global_data_store_id = gcp_config.get('data_store_id')
|
|
49
|
+
|
|
50
|
+
memories = load_memories(vector_name)
|
|
51
|
+
tools = []
|
|
52
|
+
for memory in memories:
|
|
53
|
+
for key, value in memory.items(): # Now iterate over the dictionary
|
|
54
|
+
log.info(f"Found memory {key}")
|
|
55
|
+
vectorstore = value.get('vectorstore')
|
|
56
|
+
if vectorstore == "llamaindex":
|
|
57
|
+
log.info(f"Found vectorstore {vectorstore}")
|
|
58
|
+
rag_id = value.get('rag_id')
|
|
59
|
+
project_id = gcp_config.get('project_id')
|
|
60
|
+
location = gcp_config.get('location')
|
|
61
|
+
corpus = fetch_corpus(
|
|
62
|
+
project_id=project_id or global_project_id,
|
|
63
|
+
location=location or global_location,
|
|
64
|
+
rag_id=rag_id or global_rag_id
|
|
65
|
+
)
|
|
66
|
+
corpus_tool = Tool.from_retrieval(
|
|
67
|
+
retrieval=rag.Retrieval(
|
|
68
|
+
source=rag.VertexRagStore(
|
|
69
|
+
rag_corpora=[corpus.name], # Currently only 1 corpus is allowed.
|
|
70
|
+
similarity_top_k=10, # Optional
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
tools.append(corpus_tool)
|
|
75
|
+
elif vectorstore == "vertexai_agent_builder":
|
|
76
|
+
log.info(f"Found vectorstore {vectorstore}")
|
|
77
|
+
data_store_id = value.get('data_store_id') or global_data_store_id
|
|
78
|
+
project_id = gcp_config.get('project_id') or global_project_id
|
|
79
|
+
location = gcp_config.get('location') or global_location
|
|
80
|
+
data_store_path=f"projects/{project_id}/locations/{location}/collections/default_collection/dataStores/{data_store_id}"
|
|
81
|
+
|
|
82
|
+
corpus_tool = Tool.from_retrieval(
|
|
83
|
+
grounding.Retrieval(grounding.VertexAISearch(datastore=data_store_path))
|
|
84
|
+
)
|
|
85
|
+
tools.append(corpus_tool)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if not tools:
|
|
89
|
+
log.warning("No llamaindex Vertex corpus configurations could be found")
|
|
90
|
+
|
|
91
|
+
return tools
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.62.
|
|
3
|
+
Version: 0.62.2
|
|
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.62.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.62.2.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -79,6 +79,7 @@ sunholo/langfuse/callback.py
|
|
|
79
79
|
sunholo/langfuse/prompts.py
|
|
80
80
|
sunholo/llamaindex/__init__.py
|
|
81
81
|
sunholo/llamaindex/generate.py
|
|
82
|
+
sunholo/llamaindex/get_files.py
|
|
82
83
|
sunholo/llamaindex/import_files.py
|
|
83
84
|
sunholo/lookup/__init__.py
|
|
84
85
|
sunholo/lookup/model_lookup.yaml
|
|
@@ -106,6 +107,7 @@ sunholo/utils/gcp.py
|
|
|
106
107
|
sunholo/utils/parsers.py
|
|
107
108
|
sunholo/utils/user_ids.py
|
|
108
109
|
sunholo/vertex/__init__.py
|
|
109
|
-
sunholo/vertex/
|
|
110
|
+
sunholo/vertex/init.py
|
|
111
|
+
sunholo/vertex/memory_tools.py
|
|
110
112
|
tests/test_chat_history.py
|
|
111
113
|
tests/test_config.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
|