sunholo 0.131.7__py3-none-any.whl → 0.131.9__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/discovery_engine/cli.py +27 -28
- {sunholo-0.131.7.dist-info → sunholo-0.131.9.dist-info}/METADATA +1 -1
- {sunholo-0.131.7.dist-info → sunholo-0.131.9.dist-info}/RECORD +7 -7
- {sunholo-0.131.7.dist-info → sunholo-0.131.9.dist-info}/WHEEL +0 -0
- {sunholo-0.131.7.dist-info → sunholo-0.131.9.dist-info}/entry_points.txt +0 -0
- {sunholo-0.131.7.dist-info → sunholo-0.131.9.dist-info}/licenses/LICENSE.txt +0 -0
- {sunholo-0.131.7.dist-info → sunholo-0.131.9.dist-info}/top_level.txt +0 -0
sunholo/discovery_engine/cli.py
CHANGED
@@ -8,7 +8,7 @@ try:
|
|
8
8
|
# Assuming sun_rich is in your project structure relative to this file
|
9
9
|
from ..cli.sun_rich import console
|
10
10
|
from google.protobuf.json_format import MessageToDict
|
11
|
-
|
11
|
+
import proto
|
12
12
|
except ImportError:
|
13
13
|
# Fallback if rich is not available or path is wrong
|
14
14
|
class ConsoleFallback:
|
@@ -31,6 +31,26 @@ else:
|
|
31
31
|
discoveryengine = None # Set to None if import failed
|
32
32
|
|
33
33
|
|
34
|
+
def convert_composite_to_native(value):
|
35
|
+
"""
|
36
|
+
Recursively converts a proto MapComposite or RepeatedComposite object to native Python types.
|
37
|
+
|
38
|
+
Args:
|
39
|
+
value: The proto object, which could be a MapComposite, RepeatedComposite, or a primitive.
|
40
|
+
|
41
|
+
Returns:
|
42
|
+
The equivalent Python dictionary, list, or primitive type.
|
43
|
+
"""
|
44
|
+
if isinstance(value, proto.marshal.collections.maps.MapComposite):
|
45
|
+
# Convert MapComposite to a dictionary, recursively processing its values
|
46
|
+
return {key: convert_composite_to_native(val) for key, val in value.items()}
|
47
|
+
elif isinstance(value, proto.marshal.collections.repeated.RepeatedComposite):
|
48
|
+
# Convert RepeatedComposite to a list, recursively processing its elements
|
49
|
+
return [convert_composite_to_native(item) for item in value]
|
50
|
+
else:
|
51
|
+
# If it's a primitive value, return it as is
|
52
|
+
return value
|
53
|
+
|
34
54
|
# --- Command Handler Functions ---
|
35
55
|
|
36
56
|
def discovery_engine_command(args):
|
@@ -382,33 +402,12 @@ def search_engine_command(args):
|
|
382
402
|
console.print(f" Name: {doc.name}")
|
383
403
|
# Display structData if present
|
384
404
|
if doc.struct_data:
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
except TypeError: # In case to_json doesn't accept indent
|
392
|
-
metadata_output = doc.struct_data.to_json()
|
393
|
-
# Optionally re-parse and indent if needed, but often okay as is
|
394
|
-
# parsed_json = json.loads(metadata_output)
|
395
|
-
# metadata_output = json.dumps(parsed_json, indent=2)
|
396
|
-
|
397
|
-
|
398
|
-
# Attempt 2: Use proto-plus .to_dict() then json.dumps
|
399
|
-
elif hasattr(doc.struct_data, 'to_dict'):
|
400
|
-
console.print(f"[yellow] to_dict[/yellow]")
|
401
|
-
|
402
|
-
struct_dict = doc.struct_data.to_dict()
|
403
|
-
metadata_output = json.dumps(struct_dict, indent=2)
|
404
|
-
else:
|
405
|
-
try:
|
406
|
-
# Convert Struct to dict for nice printing
|
407
|
-
struct_dict = str(doc.struct_data)
|
408
|
-
metadata_output = json.dumps(struct_dict, indent=2)
|
409
|
-
except Exception as json_err:
|
410
|
-
console.print(f"[yellow] Warning: Could not convert metadata Struct to JSON: {json_err}[/yellow]")
|
411
|
-
metadata_output = doc.struct_data
|
405
|
+
try:
|
406
|
+
struct_dict = convert_composite_to_native(doc.struct_data)
|
407
|
+
metadata_output = struct_dict.get("structData", {})
|
408
|
+
except Exception as json_err:
|
409
|
+
console.print(f"[yellow] Warning: Could not convert metadata Struct to JSON: {json_err}[/yellow]")
|
410
|
+
metadata_output = doc.struct_data
|
412
411
|
console.print(f" Metadata: {json.dumps(metadata_output, indent=2)}")
|
413
412
|
# Display Snippets if requested and available
|
414
413
|
if args.return_snippet and 'snippets' in doc.derived_struct_data:
|
@@ -73,7 +73,7 @@ sunholo/database/sql/sb/return_sources.sql,sha256=89KAnxfK8n_qGK9jy1OQT8f9n4uYUt
|
|
73
73
|
sunholo/database/sql/sb/setup.sql,sha256=CvoFvZQev2uWjmFa3aj3m3iuPFzAAJZ0S7Qi3L3-zZI,89
|
74
74
|
sunholo/discovery_engine/__init__.py,sha256=hLgqRDJ22Aov9o2QjAEfsVgnL3kMdM-g5p8RJ9OyKdQ,130
|
75
75
|
sunholo/discovery_engine/chunker_handler.py,sha256=wkvXl4rFtYfN6AZUKdW9_QD49Whf77BukDbO82UwlAg,7480
|
76
|
-
sunholo/discovery_engine/cli.py,sha256=
|
76
|
+
sunholo/discovery_engine/cli.py,sha256=sFPBQ7DLX-ra-oJyArkeZlpZDZB6uJQ897euOKim79g,32345
|
77
77
|
sunholo/discovery_engine/create_new.py,sha256=WUi4_xh_dFaGX3xA9jkNKZhaR6LCELjMPeRb0hyj4FU,1226
|
78
78
|
sunholo/discovery_engine/discovery_engine_client.py,sha256=nV4loBBnOqGPRlEbFIFRJEB6cXKDVgJOMRMdf4-v510,51775
|
79
79
|
sunholo/discovery_engine/get_ai_search_chunks.py,sha256=I6Dt1CznqEvE7XIZ2PkLqopmjpO96iVEWJJqL5cJjOU,5554
|
@@ -168,9 +168,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
168
168
|
sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
|
169
169
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
170
170
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
171
|
-
sunholo-0.131.
|
172
|
-
sunholo-0.131.
|
173
|
-
sunholo-0.131.
|
174
|
-
sunholo-0.131.
|
175
|
-
sunholo-0.131.
|
176
|
-
sunholo-0.131.
|
171
|
+
sunholo-0.131.9.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
172
|
+
sunholo-0.131.9.dist-info/METADATA,sha256=ont3YhP76bAiAr3Gt4KUjTbrLciKG6m67su-Yj-pwOA,10067
|
173
|
+
sunholo-0.131.9.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
174
|
+
sunholo-0.131.9.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
175
|
+
sunholo-0.131.9.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
176
|
+
sunholo-0.131.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|