Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,471 changes: 3,452 additions & 19 deletions changai/changai/api/v2/assets/metaschema_clean_v2.json

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions changai/changai/api/v2/auto_gen_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@
{"fieldname": "owner", "fieldtype": "Link", "label": "Owner", "options": "User"},
{"fieldname": "creation", "fieldtype": "Datetime", "label": "Created On"},
{"fieldname": "modified", "fieldtype": "Datetime", "label": "Last Modified"},
{"fieldname": "parent", "fieldtype": "Data", "label": "Parent Document"},
{"fieldname": "parenttype", "fieldtype": "Data", "label": "Parent DocType"},
{"fieldname": "parentfield", "fieldtype": "Data", "label": "Parent Field"},
{"fieldname": "idx", "fieldtype": "Int", "label": "Row Index"},
]

EXCLUDED_FIELDTYPES: Set[str] = {
"Section Break", "Column Break", "Tab Break", "Page Break", "Table Break",
"Fold", "Heading", "HTML", "Button", "Attach Image", "Image", "Signature", "Icon",
Expand Down Expand Up @@ -281,7 +284,6 @@ def sync_master_data_smart() -> Dict[str, Any]:
"fvs_error": None,
}


def _clean_schema_fields(by_table: Dict[str, Dict[str, Any]]) -> None:
for block in by_table.values():
for field in block.get("fields", []) or []:
Expand All @@ -293,7 +295,8 @@ def _clean_schema_fields(by_table: Dict[str, Dict[str, Any]]) -> None:

if field.get("fieldtype") != "Link":
field.pop("join_hint", None)
return "ok"


@frappe.whitelist(allow_guest=True)
def test():
payload = _read_filedoctype("schema.yaml", "Home/RAG Sources")
Expand Down Expand Up @@ -683,6 +686,17 @@ def fill_missing_field_descriptions(



def clear_schema_field_caches() -> None:
"""
Call this when schema_fvs is rebuilt/refreshed.
"""
global _TABLE_FIELD_DOCS_CACHE, _TABLE_FIELD_VS_CACHE, _FULL_FIELDS_VS
with _TABLE_FIELD_CACHE_LOCK:
_TABLE_FIELD_DOCS_CACHE = None
_TABLE_FIELD_VS_CACHE = OrderedDict()
_FULL_FIELDS_VS = None


@frappe.whitelist(allow_guest=False)
def sync_tables_and_schema_smart() -> Dict[str, Any]:
payload = _read_filedoctype(SCHEMA_YAML, RAG_FOLDER)
Expand Down Expand Up @@ -736,7 +750,6 @@ def sync_tables_and_schema_smart() -> Dict[str, Any]:
}


@frappe.whitelist(allow_guest=False)
def _get_claude_client() -> Optional[Anthropic]:

settings = frappe.get_single("ChangAI Settings")
Expand Down Expand Up @@ -1006,6 +1019,7 @@ def sync_schema_and_enqueue_descriptions() -> Dict[str, Any]:
queue="long",
timeout=1800,
)
clear_schema_field_caches()
return {"ok": True, "message": _("Schema updated ✅ Field descriptions running in background 🧠")}


Expand Down
Loading
Loading