sunholo 0.69.10__py3-none-any.whl → 0.69.13__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.
@@ -51,6 +51,8 @@ def do_discovery_engine(message_data, metadata, vector_name):
51
51
 
52
52
  if message_data.startswith("gs://"):
53
53
  log.info(f"DiscoveryEngineClient.import_files for {message_data}")
54
+ if "/pdf_parts/" in message_data:
55
+ return None
54
56
  for corp in corpuses:
55
57
  try:
56
58
  response = corp.import_documents(
@@ -201,55 +201,63 @@ class DiscoveryEngineClient:
201
201
  ),
202
202
  )
203
203
 
204
+ log.info(f"Discovery engine request: {search_request=}")
204
205
  search_response = self.search_client.search(search_request)
206
+
205
207
 
206
208
  if parse_chunks_to_string:
207
-
208
- return self.process_chunks(search_response)
209
+
210
+ big_string = self.process_chunks(search_response)
211
+ log.info(f"Discovery engine chunks string sample: {big_string[:100]}")
212
+
213
+ return big_string
209
214
 
215
+ log.info("Discovery engine response object")
210
216
  return search_response
211
217
 
212
218
  def process_chunks(self, response):
213
219
  all_chunks = []
214
220
 
215
- if 'results' not in response:
216
- raise ValueError('No results found in response')
221
+ # Check if the response contains results
222
+ if not hasattr(response, 'results') or not response.results:
223
+ raise ValueError(f'No results found in response: {response=}')
217
224
 
218
- for result in response['results']:
219
- chunk = result['chunk']
220
- chunk_metadata = chunk['chunkMetadata']
225
+ # Iterate through each result in the response
226
+ for result in response.results:
227
+ chunk = result.chunk
228
+ chunk_metadata = chunk.chunkMetadata
221
229
 
222
- if 'previousChunks' in chunk_metadata:
230
+ if hasattr(chunk_metadata, 'previousChunks'):
223
231
  # Process previous chunks
224
- for prev_chunk in chunk['chunkMetadata']['previousChunks']:
232
+ for prev_chunk in chunk_metadata.previousChunks:
225
233
  prev_chunk_string = (
226
- f"# {prev_chunk['id']}\n"
227
- f"{prev_chunk['content']}\n"
234
+ f"# {prev_chunk.id}\n"
235
+ f"{prev_chunk.content}\n"
228
236
  f"## metadata\n"
229
- f"Document URI: {prev_chunk['documentMetadata']['uri']}\n"
230
- f"Document Title: {prev_chunk['documentMetadata']['title']}\n"
237
+ f"Document URI: {prev_chunk.documentMetadata.uri}\n"
238
+ f"Document Title: {prev_chunk.documentMetadata.title}\n"
231
239
  )
232
240
  all_chunks.append(prev_chunk_string)
233
241
 
234
242
  # Process fetched chunk
235
243
  fetched_chunk_string = (
236
- f"# {chunk['id']}\n"
237
- f"{chunk['content']}\n"
244
+ f"# {chunk.id}\n"
245
+ f"{chunk.content}\n"
238
246
  f"## metadata\n"
239
- f"Document URI: {chunk['documentMetadata']['uri']}\n"
240
- f"Document Title: {chunk['documentMetadata']['title']}\n"
247
+ f"Document URI: {chunk.documentMetadata.uri}\n"
248
+ f"Document Title: {chunk.documentMetadata.title}\n"
241
249
  )
242
250
  all_chunks.append(fetched_chunk_string)
243
251
 
244
252
  # Process next chunks
245
- if 'nextChunks' in chunk_metadata:
246
- for next_chunk in chunk_metadata['nextChunks']:
253
+ if hasattr(chunk_metadata, 'nextChunks'):
254
+ for next_chunk in chunk_metadata.nextChunks:
247
255
  next_chunk_string = (
248
- f"# {next_chunk['id']}\n"
249
- f"{next_chunk['content']}\n"
256
+ f"# {next_chunk.id}\n"
257
+ f"{next_chunk.content}\n"
250
258
  f"## metadata\n"
251
- f"Document URI: {next_chunk['documentMetadata']['uri']}\n"
252
- f"Document Title: {next_chunk['documentMetadata']['title']}\n"
259
+ f"Document URI: {next_chunk.documentMetadata.uri}\n"
260
+ f"Document Title: {next_chunk.documentMetadata.title}\n"
253
261
  )
254
262
  all_chunks.append(next_chunk_string)
255
263
 
@@ -311,9 +319,9 @@ class DiscoveryEngineClient:
311
319
  try:
312
320
  operation = import_documents_with_retry(self.doc_client, request)
313
321
  except ResourceExhausted as e:
314
- print(f"Operation failed after retries due to quota exceeded: {e}")
322
+ log.error(f"Operation failed after retries due to quota exceeded: {e}")
315
323
  except Exception as e:
316
- print(f"An unexpected error occurred: {e}")
324
+ log.error(f"An unexpected error occurred: {e}")
317
325
 
318
326
  return operation.operation.name
319
327
 
sunholo/logging.py CHANGED
@@ -119,8 +119,14 @@ class GoogleCloudLogging:
119
119
  if log_text:
120
120
  if isinstance(log_struct, dict):
121
121
  logger.log_struct(log_struct, severity=severity, source_location=caller_info)
122
- else:
122
+ elif isinstance(log_struct, str):
123
123
  logger.log_text(log_text, severity=severity, source_location=caller_info)
124
+ else:
125
+ try:
126
+ turn_to_text = str(log_text)
127
+ logger.log_text(turn_to_text, severity=severity, source_location=caller_info)
128
+ except Exception as err:
129
+ print(f"Could not log this: {log_text=} - {str(err)}")
124
130
 
125
131
  elif log_struct:
126
132
  if not isinstance(log_struct, dict):
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.69.10
3
+ Version: 0.69.13
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.69.10.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.69.13.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -61,6 +61,7 @@ Requires-Dist: pypdf ; extra == 'all'
61
61
  Requires-Dist: python-socketio ; extra == 'all'
62
62
  Requires-Dist: rich ; extra == 'all'
63
63
  Requires-Dist: supabase ; extra == 'all'
64
+ Requires-Dist: tantivy ; extra == 'all'
64
65
  Requires-Dist: tiktoken ; extra == 'all'
65
66
  Provides-Extra: anthropic
66
67
  Requires-Dist: langchain-anthropic >=0.1.13 ; extra == 'anthropic'
@@ -75,6 +76,7 @@ Requires-Dist: pg8000 ; extra == 'database'
75
76
  Requires-Dist: pgvector ; extra == 'database'
76
77
  Requires-Dist: psycopg2-binary ; extra == 'database'
77
78
  Requires-Dist: lancedb ; extra == 'database'
79
+ Requires-Dist: tantivy ; extra == 'database'
78
80
  Provides-Extra: gcp
79
81
  Requires-Dist: google-auth-httplib2 ; extra == 'gcp'
80
82
  Requires-Dist: google-auth-oauthlib ; extra == 'gcp'
@@ -1,5 +1,5 @@
1
1
  sunholo/__init__.py,sha256=0CdpufyRKWyZe7J7UKigL6j_qOorM-p0OjHIAuf9M38,864
2
- sunholo/logging.py,sha256=00VGGArfWHbJuHHSJ4kXhHTggWnRfbVYMcZNOYIsqnA,11787
2
+ sunholo/logging.py,sha256=UUBl0_oBrW21O5cNAT5lYZ2OmAnVJ92PnAwtA_2Sz_g,12117
3
3
  sunholo/agents/__init__.py,sha256=Hb4NXy2rN-83Z0-UDRwX-LXv2R29lcbSFPf8G6q4fZg,380
4
4
  sunholo/agents/chat_history.py,sha256=8iX1bgvRW6fdp6r_DQR_caPHYrZ_9QJJgPxCiSDf3q8,5380
5
5
  sunholo/agents/dispatch_to_qa.py,sha256=nFNdxhkr7rVYuUwVoBCBNYBI2Dke6-_z_ZApBEWb_cU,8291
@@ -61,9 +61,9 @@ sunholo/database/sql/sb/delete_source_row.sql,sha256=r6fEuUKdbiLHCDGKSbKINDCpJjs
61
61
  sunholo/database/sql/sb/return_sources.sql,sha256=89KAnxfK8n_qGK9jy1OQT8f9n4uYUtYL5cCxbC2mj_c,255
62
62
  sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3-zZI,89
63
63
  sunholo/discovery_engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- sunholo/discovery_engine/chunker_handler.py,sha256=9zv72CxgKlKpOcSAt-XFtq0Ra-Z6tBTwMuXQhRPE5mY,4425
64
+ sunholo/discovery_engine/chunker_handler.py,sha256=puNnV6vKnjNqk28FLnsIPMNsC-1Y6s20PK7ioi8qwzc,4491
65
65
  sunholo/discovery_engine/create_new.py,sha256=7oZG78T6lW0EspRzlo7-qRyXFSuFxDn2dfSAVEaqlqY,978
66
- sunholo/discovery_engine/discovery_engine_client.py,sha256=xgRv1WMYgjjKE5e2SwV3ZeaodzQ1twSoaRwfQkiTOSo,14687
66
+ sunholo/discovery_engine/discovery_engine_client.py,sha256=3nTiFlYSMps7WEQwm-9oReZH0f07PN6mjJjXrn2BFqA,15015
67
67
  sunholo/embedder/__init__.py,sha256=sI4N_CqgEVcrMDxXgxKp1FsfsB4FpjoXgPGkl4N_u4I,44
68
68
  sunholo/embedder/embed_chunk.py,sha256=P744zUQJgqrjILunzaqtTerB9AwoXFU6tXBtz4rjWgQ,6673
69
69
  sunholo/gcs/__init__.py,sha256=DtVw_AZwQn-IguR5BJuIi2XJeF_FQXizhJikzRNrXiE,50
@@ -111,9 +111,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
111
111
  sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
112
112
  sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
113
113
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
114
- sunholo-0.69.10.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
- sunholo-0.69.10.dist-info/METADATA,sha256=t0FhARCqbXEulRWUtzijoEFrssaFlYtG5dBG8xzEpg4,6157
116
- sunholo-0.69.10.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
- sunholo-0.69.10.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
- sunholo-0.69.10.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
- sunholo-0.69.10.dist-info/RECORD,,
114
+ sunholo-0.69.13.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
115
+ sunholo-0.69.13.dist-info/METADATA,sha256=MaShm5cJCTDR_7FugF5T8rND03p3QymIOkqJcxdPP04,6242
116
+ sunholo-0.69.13.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
117
+ sunholo-0.69.13.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
118
+ sunholo-0.69.13.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
119
+ sunholo-0.69.13.dist-info/RECORD,,