in components/webui/src/dpu/components.py [0:0]
def show_agent_document(root_doc_id: str):
logger.info(f"Showing document {root_doc_id}")
# Get document metadata
full_doc = fetch_agent_doc(root_doc_id)
if not full_doc:
logger.info(f"Could not find document {root_doc_id}")
st.write(f"Could not find document {root_doc_id}")
return
objs = full_doc.get("objs", [])
# Find row we're starting with in the objects
initial_value = None
for i in range(len(objs)):
if "objid" in objs[i] and objs[i]["objid"] == root_doc_id:
initial_value = i
# Render document is same as the root
doc_id = root_doc_id
# If there is a list of objects and this is part of it,
# then we should show all of the related documents together
if initial_value is not None:
doc_id = choose_related_document(full_doc["objs"], initial_value)
# If it's an Agent document, fetch metadata for it
if not doc_id.startswith("gs://"):
doc_info = fetch_agent_doc(doc_id)
if not doc_info:
logger.info(f"Could not find document {doc_id}")
st.write(f"Could not find document {doc_id}")
return
uri = doc_info["uri"]
item_metadata = doc_info["metadata"]
else:
uri = doc_id
item_metadata = {}
show_gcs_object(uri, item_metadata)
logger.info("Done rendering gcs object. Nothing more to do!")