Spaces:
Running
Running
Download src/services/api/controllers/meta.py from Leon4gr45/brain: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/src/services/api/controllers/meta.py
- Command line
-
hf download hf://spaces/Leon4gr45/brain/src/services/api/controllers/meta.py
-
curl -L -o meta.py https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/src/services/api/controllers/meta.py
1.54 kB
| """ | |
| File: /meta.py | |
| Created Date: Friday November 7th 2025 | |
| Author: Christian Nonis <alch.infoemail@gmail.com> | |
| ----- | |
| Last Modified: Saturday December 27th 2025 | |
| Modified By: the developer formerly known as Christian Nonis at <alch.infoemail@gmail.com> | |
| ----- | |
| """ | |
| import asyncio | |
| import os | |
| from fastapi import HTTPException, Request | |
| from src.services.data.main import data_adapter | |
| from src.services.kg_agent.main import graph_adapter | |
| async def get_login_info(request: Request): | |
| principal = request.state.principal | |
| return {"is_system_pat": principal.is_system, "brain_id": principal.brain_id} | |
| async def get_entities_labels(brain_id: str): | |
| """ | |
| Retrieve node labels (types) for the graph identified by `brain_id`. | |
| """ | |
| try: | |
| result = await asyncio.to_thread(graph_adapter.get_graph_node_types, brain_id) | |
| return result or [] | |
| except Exception: | |
| return [] | |
| async def get_relationships_properties(brain_id: str): | |
| """ | |
| Retrieve relationship types for the graph associated with the given brain. | |
| """ | |
| try: | |
| result = await asyncio.to_thread(graph_adapter.get_graph_relationship_types, brain_id) | |
| return result or [] | |
| except Exception: | |
| return [] | |
| async def get_entity_properties(brain_id: str): | |
| """ | |
| Retrieve all unique property keys for node entities in the specified graph. | |
| """ | |
| try: | |
| result = await asyncio.to_thread(graph_adapter.get_graph_node_properties, brain_id) | |
| return result or [] | |
| except Exception: | |
| return [] | |