sunholo 0.83.0__py3-none-any.whl → 0.83.2__py3-none-any.whl
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/database/alloydb_client.py +47 -17
- sunholo/vertex/memory_tools.py +2 -2
- {sunholo-0.83.0.dist-info → sunholo-0.83.2.dist-info}/METADATA +2 -2
- {sunholo-0.83.0.dist-info → sunholo-0.83.2.dist-info}/RECORD +8 -8
- {sunholo-0.83.0.dist-info → sunholo-0.83.2.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.83.0.dist-info → sunholo-0.83.2.dist-info}/WHEEL +0 -0
- {sunholo-0.83.0.dist-info → sunholo-0.83.2.dist-info}/entry_points.txt +0 -0
- {sunholo-0.83.0.dist-info → sunholo-0.83.2.dist-info}/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@ try:
|
|
|
3
3
|
import pg8000
|
|
4
4
|
import sqlalchemy
|
|
5
5
|
from sqlalchemy.exc import DatabaseError, ProgrammingError
|
|
6
|
-
from
|
|
6
|
+
from langchain_google_alloydb_pg import AlloyDBEngine
|
|
7
7
|
except ImportError:
|
|
8
8
|
AlloyDBEngine = None
|
|
9
9
|
pass
|
|
@@ -42,16 +42,15 @@ class AlloyDBClient:
|
|
|
42
42
|
region: str=None,
|
|
43
43
|
cluster_name:str=None,
|
|
44
44
|
instance_name:str=None,
|
|
45
|
-
user:str=None,
|
|
46
|
-
password=None,
|
|
45
|
+
user:str=None,
|
|
46
|
+
password:str=None,
|
|
47
47
|
db="postgres"):
|
|
48
48
|
"""Initializes the AlloyDB client.
|
|
49
49
|
- project_id (str): GCP project ID where the AlloyDB instance resides.
|
|
50
50
|
- region (str): The region where the AlloyDB instance is located.
|
|
51
51
|
- cluster_name (str): The name of the AlloyDB cluster.
|
|
52
52
|
- instance_name (str): The name of the AlloyDB instance.
|
|
53
|
-
- user (str):
|
|
54
|
-
- password (str): The database user's password.
|
|
53
|
+
- user (str): If user is None will use the default service email
|
|
55
54
|
- db_name (str): The name of the database.
|
|
56
55
|
"""
|
|
57
56
|
if config is None:
|
|
@@ -61,6 +60,7 @@ class AlloyDBClient:
|
|
|
61
60
|
alloydb_config = config.vacConfig("alloydb_config")
|
|
62
61
|
if not alloydb_config:
|
|
63
62
|
raise ValueError("Must specify vac.alloydb_config")
|
|
63
|
+
self.config = alloydb_config
|
|
64
64
|
project_id = alloydb_config["project_id"]
|
|
65
65
|
region = alloydb_config["region"]
|
|
66
66
|
cluster_name = alloydb_config["cluster"]
|
|
@@ -70,18 +70,25 @@ class AlloyDBClient:
|
|
|
70
70
|
if ALLOYDB_DB is None and alloydb_config.get("database") is None:
|
|
71
71
|
log.warning("Could not locate ALLOYDB_DB environment variable or 'alloydb_config.database'")
|
|
72
72
|
|
|
73
|
-
self.database = alloydb_config.get("database") or ALLOYDB_DB
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
self.database = alloydb_config.get("database") or ALLOYDB_DB
|
|
74
|
+
|
|
75
|
+
if user:
|
|
76
|
+
log.info("User specified {user} - using pg8000 engine")
|
|
77
|
+
self.user = user
|
|
78
|
+
self.password = password
|
|
79
|
+
self.inst_url = self._build_instance_uri(project_id, region, cluster_name, instance_name)
|
|
80
|
+
self.engine = self._create_engine_from_pg8000()
|
|
81
|
+
else:
|
|
82
|
+
log.info("Build with Langchain engine - will use default service account for auth")
|
|
83
|
+
self.engine = self._create_engine()
|
|
77
84
|
|
|
78
85
|
def _build_instance_uri(self, project_id, region, cluster_name, instance_name):
|
|
79
86
|
return f"projects/{project_id}/locations/{region}/clusters/{cluster_name}/instances/{instance_name}"
|
|
80
|
-
|
|
81
|
-
def
|
|
87
|
+
|
|
88
|
+
def _create_engine_from_pg8000(self, user, password, db):
|
|
82
89
|
def getconn() -> pg8000.dbapi.Connection:
|
|
83
90
|
conn = self.connector.connect(
|
|
84
|
-
inst_uri,
|
|
91
|
+
self.inst_uri,
|
|
85
92
|
"pg8000",
|
|
86
93
|
user=user,
|
|
87
94
|
password=password,
|
|
@@ -93,10 +100,33 @@ class AlloyDBClient:
|
|
|
93
100
|
engine = sqlalchemy.create_engine(
|
|
94
101
|
"postgresql+pg8000://",
|
|
95
102
|
isolation_level="AUTOCOMMIT",
|
|
96
|
-
creator=getconn
|
|
97
|
-
)
|
|
103
|
+
creator=getconn)
|
|
98
104
|
engine.dialect.description_encoding = None
|
|
99
|
-
|
|
105
|
+
|
|
106
|
+
log.info(f"Created AlloyDB engine for {self.inst_uri} and user: {user}")
|
|
107
|
+
return engine
|
|
108
|
+
|
|
109
|
+
def _create_engine(self):
|
|
110
|
+
if not AlloyDBEngine:
|
|
111
|
+
log.error("Can't create AlloyDBEngine - install via `pip install sunholo[gcp,database]`")
|
|
112
|
+
raise ValueError("Can't import AlloyDBEngine")
|
|
113
|
+
|
|
114
|
+
log.info("Inititaing AlloyDB Langchain engine for database: {self.database}")
|
|
115
|
+
|
|
116
|
+
from google.cloud.alloydb.connector import IPTypes
|
|
117
|
+
engine = AlloyDBEngine.from_instance(
|
|
118
|
+
project_id=self.config["project_id"],
|
|
119
|
+
region=self.config["region"],
|
|
120
|
+
cluster=self.config["cluster"],
|
|
121
|
+
instance=self.config["instance"],
|
|
122
|
+
user=self.user,
|
|
123
|
+
password=self.password,
|
|
124
|
+
database=self.database,
|
|
125
|
+
ip_type=self.config.get("ip_type") or IPTypes.PRIVATE
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
log.info(f"Created AlloyDB engine for {engine}")
|
|
129
|
+
|
|
100
130
|
return engine
|
|
101
131
|
|
|
102
132
|
def execute_sql(self, sql_statement):
|
|
@@ -153,7 +183,7 @@ class AlloyDBClient:
|
|
|
153
183
|
return documents
|
|
154
184
|
|
|
155
185
|
def get_sources_from_docstore(self, sources, vector_name, search_type="OR", just_source_name=False):
|
|
156
|
-
"""Fetches sources from the docstore
|
|
186
|
+
"""Fetches sources from the docstore."""
|
|
157
187
|
if just_source_name:
|
|
158
188
|
query = self._list_sources_from_docstore(sources, vector_name=vector_name, search_type=search_type)
|
|
159
189
|
else:
|
|
@@ -163,7 +193,7 @@ class AlloyDBClient:
|
|
|
163
193
|
return []
|
|
164
194
|
|
|
165
195
|
documents = self.execute_sql(query)
|
|
166
|
-
|
|
196
|
+
|
|
167
197
|
return documents
|
|
168
198
|
|
|
169
199
|
def _get_sources_from_docstore(self, sources, vector_name, search_type="OR"):
|
sunholo/vertex/memory_tools.py
CHANGED
|
@@ -133,8 +133,8 @@ def get_google_search_grounding(vector_name:str=None, config:ConfigManager=None)
|
|
|
133
133
|
config = ConfigManager(vector_name)
|
|
134
134
|
|
|
135
135
|
# can't have this and llamaindex memories?
|
|
136
|
-
|
|
137
|
-
if
|
|
136
|
+
tools = config.vacConfig("tools")
|
|
137
|
+
if tools and tools.get("google_search"):
|
|
138
138
|
gs_tool = Tool.from_google_search_retrieval(grounding.GoogleSearchRetrieval())
|
|
139
139
|
log.info(f"Got Search Tool: {gs_tool}")
|
|
140
140
|
return gs_tool
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.83.
|
|
3
|
+
Version: 0.83.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.83.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.83.2.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -59,7 +59,7 @@ sunholo/components/retriever.py,sha256=bKIVT7_18Ut3OJd0E0jyiISPnD9qkHWVjcQPT4i1_
|
|
|
59
59
|
sunholo/components/vectorstore.py,sha256=xKk7micTRwZckaI7U6PxvFz_ZSjCH48xPTDYiDcv2tc,5913
|
|
60
60
|
sunholo/database/__init__.py,sha256=bpB5Nk21kwqYj-qdVnvNgXjLsbflnH4g-San7OHMqR4,283
|
|
61
61
|
sunholo/database/alloydb.py,sha256=YH8wNPS8gN-TDZEXQcVHxwd1NScHRfAxma3gK4R6KCk,11740
|
|
62
|
-
sunholo/database/alloydb_client.py,sha256=
|
|
62
|
+
sunholo/database/alloydb_client.py,sha256=xqXhzHoh0e5RKz0wc7MwCayL89JdrYG016Oq-ZSNfBc,12731
|
|
63
63
|
sunholo/database/database.py,sha256=VqhZdkXUNdvWn8sUcUV3YNby1JDVf7IykPVXWBtxo9U,7361
|
|
64
64
|
sunholo/database/lancedb.py,sha256=DyfZntiFKBlVPaFooNN1Z6Pl-LAs4nxWKKuq8GBqN58,715
|
|
65
65
|
sunholo/database/static_dbs.py,sha256=8cvcMwUK6c32AS2e_WguKXWMkFf5iN3g9WHzsh0C07Q,442
|
|
@@ -131,12 +131,12 @@ sunholo/vertex/extensions_call.py,sha256=QeQbL3aAHlc4_-SynOzooZ_3xkQWAlcgNmFBSwL
|
|
|
131
131
|
sunholo/vertex/extensions_class.py,sha256=2QGW28lNjoMEnaoVb3QcqEDwphclIsZthnpLUi5_Ivo,21033
|
|
132
132
|
sunholo/vertex/genai_functions.py,sha256=2z6grM9H0Z79Yzx88l8mE1wXck3bRa0TWvnqZZ9ifDc,2051
|
|
133
133
|
sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
134
|
-
sunholo/vertex/memory_tools.py,sha256=
|
|
134
|
+
sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
|
|
135
135
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
|
136
136
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
|
137
|
-
sunholo-0.83.
|
|
138
|
-
sunholo-0.83.
|
|
139
|
-
sunholo-0.83.
|
|
140
|
-
sunholo-0.83.
|
|
141
|
-
sunholo-0.83.
|
|
142
|
-
sunholo-0.83.
|
|
137
|
+
sunholo-0.83.2.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
138
|
+
sunholo-0.83.2.dist-info/METADATA,sha256=L_LY3La6qhCknE_-6il21csG0OjyiikTyiPiJTx2EQQ,7413
|
|
139
|
+
sunholo-0.83.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
140
|
+
sunholo-0.83.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
141
|
+
sunholo-0.83.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
142
|
+
sunholo-0.83.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|